diff --git a/README.md b/README.md index a58d723..36aa87c 100644 --- a/README.md +++ b/README.md @@ -54,9 +54,9 @@ Star Micronics provides a [Star Document Markup Designer](https://star-document- _@autotelic/fastify-cloudprnt_ exports a fastify plugin. When registered the plugin expects a configuration object: * `queueJob: (token, jobData) => any`: method that takes a url-safe string `token` and an object of data `jobData`, to be passed to [point-of-view](https://github.com/fastify/point-of-view#quick-start) for template rendering, and adds the job to the print queue. -* `getJob: () => token`: method that returns the url-safe string `token` for the next available print job on the queue. -* `getJobData: (token) => object`: method that returns the data object for the job enqueued with the url-safe string `token`. -* `deleteJob: (token) => any`: method that deletes the job enqueued with the url-safe string `token` from the print queue. +* `getJob: (request) => token`: method that returns the url-safe string `token` for the next available print job on the queue. `request` is the fastify request object. +* `getJobData: (token, request) => object`: method that returns the data object for the job enqueued with the url-safe string `token`. `request` is the fastify request object. +* `deleteJob: (token, request) => any`: method that deletes the job enqueued with the url-safe string `token` from the print queue. `request` is the fastify request object. * `routePrefix: string`: string which will configure a prefix for all cloudprnt routes. * `defaultTemplate`: string which will configure the default template to be joined with `templatesDir` and used by [`@fastify/point-of-view`](https://github.com/fastify/point-of-view/tree/v3.x) to render the template (default to `receipt.stm`). If `jobData` contains a `template` value, it will be used instead of the `defaultTemplate`. * `templatesDir`: string which will configure the directory to be joined with either the `defaultTemplate` or `jobData.template` and used by [`@fastify/point-of-view`](https://github.com/fastify/point-of-view/tree/v3.x) to render the template (default to an empty string). @@ -74,4 +74,4 @@ An [example](./examples/basic/) fastify app using [node-cache](https://github.co An [example](./examples/redis/) fastify app using [redis](https://www.npmjs.com/package/redis). To run the redis example, use the following command: ```sh npm run example:redis -``` \ No newline at end of file +``` diff --git a/package.json b/package.json index f3363da..839932e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@autotelic/fastify-cloudprnt", - "version": "0.3.2-rc.1", + "version": "0.5.0", "description": "Fastify plugin to run a server following the Star Micronics CloudPRNT protocol.", "keywords": [ "fastify", diff --git a/routes/main/delete.js b/routes/main/delete.js index 210104e..cea8b92 100644 --- a/routes/main/delete.js +++ b/routes/main/delete.js @@ -22,7 +22,7 @@ module.exports = { }, handler: async function queueJobHandler (request, reply) { const { token } = request.query - const deleted = await this.cloudPrnt.deleteJob(token) + const deleted = await this.cloudPrnt.deleteJob(token, request) const code = deleted ? 200 : 404 diff --git a/routes/main/get.js b/routes/main/get.js index 04decc7..3c5ac32 100644 --- a/routes/main/get.js +++ b/routes/main/get.js @@ -30,7 +30,7 @@ module.exports = { formatPrntCommandData } = this.cloudPrnt - const jobData = await getJobData(token) + const jobData = await getJobData(token, request) if (jobData === null) { return reply.code(404).send('Job not found') } diff --git a/routes/main/post.js b/routes/main/post.js index 347f478..ee737ec 100644 --- a/routes/main/post.js +++ b/routes/main/post.js @@ -23,7 +23,7 @@ module.exports = { } }, handler: async function pollHandler (request, reply) { - const jobToken = await this.cloudPrnt.getJob() + const jobToken = await this.cloudPrnt.getJob(request) const jobReady = jobToken !== null let jobReadyResponse = {}