@kne/fastify-puppeteer 1.1.9 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/libs/controllers.js +27 -0
- package/package.json +1 -1
package/libs/controllers.js
CHANGED
|
@@ -278,6 +278,33 @@ module.exports = fp(async (fastify, options) => {
|
|
|
278
278
|
}
|
|
279
279
|
);
|
|
280
280
|
|
|
281
|
+
fastify.post(
|
|
282
|
+
`${options.prefix}/parseUrlToPdfBatch`,
|
|
283
|
+
{
|
|
284
|
+
onRequest: options.authenticate,
|
|
285
|
+
schema: {
|
|
286
|
+
description: '接口说明',
|
|
287
|
+
summary: 'url生成pdf文件流',
|
|
288
|
+
body: {
|
|
289
|
+
type: 'object',
|
|
290
|
+
required: ['urlList'],
|
|
291
|
+
properties: {
|
|
292
|
+
options: pdfSchema,
|
|
293
|
+
urlList: { type: 'array', items: { type: 'string' } }
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
async (request, reply) => {
|
|
299
|
+
const filename = await services.parseUrlToPdfBatch({
|
|
300
|
+
urlList: request.body.urlList,
|
|
301
|
+
options: request.body.options
|
|
302
|
+
});
|
|
303
|
+
request.body.filename && reply.header('Content-Disposition', `attachment; filename=${encodeURIComponent(request.body.filename)}`);
|
|
304
|
+
return reply.sendFile(filename, { root: options.root });
|
|
305
|
+
}
|
|
306
|
+
);
|
|
307
|
+
|
|
281
308
|
fastify.get(
|
|
282
309
|
`${options.prefix}/parseUrlToPdfBatch`,
|
|
283
310
|
{
|