hirefire-resource 1.0.1 → 1.1.1

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,12 @@
1
- ## HEAD
1
+ ## v1.1.1
2
+
3
+ - Add connectionOptions to BullMQ jobQueueSize
4
+
5
+ ## v1.1.0
6
+
7
+ - Add support for [Fastify](https://fastify.dev).
8
+
9
+ ## v1.0.1
2
10
 
3
11
  - 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
12
 
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.1",
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",
@@ -25,7 +25,11 @@ async function jobQueueLatency(...args) {
25
25
  * function will use the value of the `REDIS_TLS_URL`, `REDIS_URL`,
26
26
  * `REDISTOGO_URL`, `REDISCLOUD_URL`, `OPENREDIS_URL` environment
27
27
  * variables, in the order specified. If none of these environment
28
- * variables are set, it defaults to `redis://localhost:6379/0`.
28
+ * variables are set, it defaults to `redis://localhost:6379/0`. The
29
+ * `options` object can also include a `connectionOptions` property,
30
+ * which is passed as the second argument to the `IORedis` constructor,
31
+ * allowing for further customization of the Redis connection (e.g., TLS
32
+ * options, retry strategies).
29
33
  * @returns {Promise<number>} Cumulative job queue size across the specified queues.
30
34
  * @example
31
35
  * // Calculate size across all queues
@@ -39,6 +43,9 @@ async function jobQueueLatency(...args) {
39
43
  * @example
40
44
  * // Calculate Size using the options.connection property
41
45
  * await jobQueueSize("default", { connection: "redis://localhost:6379/0" })
46
+ * @example
47
+ * // Calculate Size using the options.connectionOptions property
48
+ * await jobQueueSize("default", { connectionOptions: { tls: { rejectUnauthorized: false } } })
42
49
  */
43
50
  async function jobQueueSize(...args) {
44
51
  let { queues, options } = unpack(args)
@@ -51,6 +58,7 @@ async function jobQueueSize(...args) {
51
58
  process.env.REDISCLOUD_URL ||
52
59
  process.env.OPENREDIS_URL ||
53
60
  "redis://localhost:6379/0",
61
+ options.connectionOptions,
54
62
  )
55
63
 
56
64
  if (queues.length === 0) {
@@ -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
+ })