Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var htmlPdf = require('html-pdf-chrome')
var createS3Config = require('../src/storage/s3')
var pgsql = require('../src/db/pgsql')
module.exports = {
api: {
token: 'api-token'
},
db: pgsql({
user: 'pdfbot',
password: 'pdfbot',
database: 'pdfbot'
}),
// html-pdf-chrome options
generator: {
completionTrigger: new htmlPdf.CompletionTrigger.Timer(1000), // waits for 1 sec
//port: 50 // chrome port
},
queue: {
},
storage: {
/*'s3': createS3Config({
bucket: '',
accessKeyId: '',
region: '',
secretAccessKey: ''
})*/
},
// storagePath: '',
webhook: {
headerNamespace: 'X-PDF-',
export default async function documentPdfHandler(req: Request, res: Response) {
const { document } = req.body;
try {
const completionTrigger = new htmlPdf.CompletionTrigger.Timer(2000);
const documentHtml = generateHtmlFromDocument(document as any);
const { width, height } = document.pages[0] as PubPage;
const isLandscape = width > height;
const pdf = await htmlPdf.create(
`
${baseHtml}
<div>
${documentHtml}
</div>
`,
{
port: 9922,
completionTrigger,
printOptions: {