hirefire-resource 1.0.1 → 1.1.0

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/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
- ## HEAD
1
+ ## v1.1.0
2
+
3
+ - Add support for [Fastify](https://fastify.dev).
4
+
5
+ ## v1.0.1
2
6
 
3
7
  - Add support for dashes in `Worker` names to match the Procfile process naming format. `Worker` is implicitly used when configuring HireFire using the `Configuration#dyno` method.
4
8
 
package/README.md CHANGED
@@ -7,6 +7,7 @@ This library integrates Node.js applications with HireFire's Dyno Managers (Hero
7
7
  - Express
8
8
  - Koa
9
9
  - Connect
10
+ - Fastify
10
11
  - Sails
11
12
  - Nest
12
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hirefire-resource",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "HireFire integration library for Node.js applications",
5
5
  "keywords": [
6
6
  "hirefire",
@@ -24,6 +24,7 @@
24
24
  "./middleware/connect": "./src/middleware/connect.js",
25
25
  "./middleware/express": "./src/middleware/express.js",
26
26
  "./middleware/koa": "./src/middleware/koa.js",
27
+ "./middleware/fastify": "./src/middleware/fastify.js",
27
28
  "./macro/bullmq": "./src/macro/bullmq.js"
28
29
  },
29
30
  "repository": {
@@ -52,6 +53,8 @@
52
53
  "bullmq": "^4.13.2",
53
54
  "connect": "^3.7.0",
54
55
  "express": "^4.18.2",
56
+ "fastify": "^4.26.2",
57
+ "fastify-plugin": "^4.5.1",
55
58
  "jest": "^29.3.1",
56
59
  "jsdoc": "^4.0.2",
57
60
  "koa": "^2.14.2",
@@ -0,0 +1,26 @@
1
+ const fp = require("fastify-plugin")
2
+ const { RequestInfo, request } = require("../middleware")
3
+
4
+ async function HireFireMiddlewareFastify(fastify, options) {
5
+ fastify.addHook("onRequest", async (request_, reply) => {
6
+ const response = await request(
7
+ new RequestInfo(
8
+ request_.url,
9
+ request_.headers["x-request-start"],
10
+ request_.headers["hirefire-token"],
11
+ ),
12
+ )
13
+
14
+ if (response) {
15
+ reply
16
+ .status(response.status)
17
+ .headers(response.headers)
18
+ .send(response.body)
19
+ }
20
+ })
21
+ }
22
+
23
+ module.exports = fp(HireFireMiddlewareFastify, {
24
+ fastify: ">=3.x",
25
+ name: "hirefire-middleware-fastify",
26
+ })