mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add JWT token to the request
This commit is contained in:
parent
a91cf9ef63
commit
761f2ff8f2
2 changed files with 14 additions and 1 deletions
|
|
@ -464,7 +464,10 @@ export const getArticleResolver: ResolverFn<
|
|||
if (!page.originalHtml) {
|
||||
return { errorCodes: [ArticleErrorCode.BadData] }
|
||||
}
|
||||
const distillerResult = await getDistillerResult(page.originalHtml)
|
||||
const distillerResult = await getDistillerResult(
|
||||
claims.uid,
|
||||
page.originalHtml
|
||||
)
|
||||
if (!distillerResult) {
|
||||
return { errorCodes: [ArticleErrorCode.BadData] }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,11 @@ import {
|
|||
findEmbeddedHighlight,
|
||||
} from './highlightGenerator'
|
||||
import { NodeHtmlMarkdown } from 'node-html-markdown'
|
||||
import { promisify } from 'util'
|
||||
import * as jwt from 'jsonwebtoken'
|
||||
|
||||
const logger = buildLogger('utils.parse')
|
||||
const signToken = promisify(jwt.sign)
|
||||
|
||||
export const ALLOWED_CONTENT_TYPES = [
|
||||
'text/html',
|
||||
|
|
@ -487,6 +490,7 @@ export const htmlToMarkdown = (html: string) => {
|
|||
}
|
||||
|
||||
export const getDistillerResult = async (
|
||||
uid: string,
|
||||
html: string
|
||||
): Promise<string | undefined> => {
|
||||
try {
|
||||
|
|
@ -496,7 +500,13 @@ export const getDistillerResult = async (
|
|||
return undefined
|
||||
}
|
||||
|
||||
const token = await signToken({ uid }, '1h')
|
||||
|
||||
console.debug('Parsing by distiller', url)
|
||||
const response = await axios.post<string>(url, html, {
|
||||
headers: {
|
||||
Authorization: token as string,
|
||||
},
|
||||
timeout: 5000,
|
||||
})
|
||||
return response.data
|
||||
|
|
|
|||
Loading…
Reference in a new issue