@gasket/plugin-fastify 6.0.1 → 6.10.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,5 +1,13 @@
1
1
  # `@gasket/plugin-fastify`
2
2
 
3
+ ### 6.10.0
4
+
5
+ - TypeScript definitions for config & lifecycles ([#311])
6
+
7
+ ### 6.0.5
8
+
9
+ - Filter falsy middleware ([#255])
10
+
3
11
  ### 6.0.1
4
12
 
5
13
  - Fix to add `res.locals` for attaching data ([#250])
@@ -22,3 +30,5 @@ Enable middleware support ([#172])
22
30
  [#88]: https://github.com/godaddy/gasket/pull/88
23
31
  [#172]: https://github.com/godaddy/gasket/pull/172
24
32
  [#250]: https://github.com/godaddy/gasket/pull/250
33
+ [#255]: https://github.com/godaddy/gasket/pull/255
34
+ [#311]: https://github.com/godaddy/gasket/pull/311
package/index.d.ts ADDED
@@ -0,0 +1,28 @@
1
+ import type { GasketConfig, HookExecTypes, MaybeAsync, MaybeMultiple } from '@gasket/engine';
2
+ import type { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
3
+
4
+ declare module '@gasket/engine' {
5
+ export interface GasketConfig {
6
+ compression?: boolean,
7
+ excludedRoutesRegex?: RegExp
8
+ }
9
+
10
+ // The middie middleware is added for express compatibility
11
+ type Handler = (
12
+ req: FastifyRequest,
13
+ res: FastifyReply,
14
+ next: (error?: Error) => void
15
+ ) => void;
16
+ type ErrorHandler = (
17
+ error: Error,
18
+ req: FastifyRequest,
19
+ res: FastifyReply,
20
+ next: (error?: Error) => void
21
+ ) => void;
22
+
23
+ export interface HookExecTypes {
24
+ middleware(fastify: FastifyInstance): MaybeAsync<MaybeMultiple<Handler>>,
25
+ fastify(fastify: FastifyInstance): MaybeAsync<void>,
26
+ errorMiddleware(fastify: FastifyInstance): MaybeAsync<MaybeMultiple<ErrorHandler>>
27
+ }
28
+ }
package/index.js CHANGED
@@ -58,7 +58,7 @@ module.exports = {
58
58
  app.use(compression());
59
59
  }
60
60
 
61
- const middlewares = await gasket.exec('middleware', app);
61
+ const middlewares = (await gasket.exec('middleware', app)).filter(Boolean);
62
62
 
63
63
  debug('applied %s middleware layers to fastify', middlewares.length);
64
64
  middlewares.forEach(layer => {
@@ -72,7 +72,7 @@ module.exports = {
72
72
  // allow consuming apps to directly append options to their server
73
73
  await gasket.exec('fastify', app);
74
74
 
75
- const postRenderingStacks = await gasket.exec('errorMiddleware');
75
+ const postRenderingStacks = (await gasket.exec('errorMiddleware')).filter(Boolean);
76
76
  postRenderingStacks.forEach(stack => app.use(stack));
77
77
 
78
78
  return {
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@gasket/plugin-fastify",
3
- "version": "6.0.1",
3
+ "version": "6.10.1",
4
4
  "description": "Adds fastify support to your application",
5
5
  "main": "index.js",
6
+ "types": "index.d.ts",
6
7
  "scripts": {
7
8
  "lint": "eslint index.js test",
8
9
  "lint:fix": "npm run lint -- --fix",
@@ -33,7 +34,7 @@
33
34
  "bugs": {
34
35
  "url": "https://github.com/godaddy/gasket/issues"
35
36
  },
36
- "homepage": "https://github.com/godaddy/gasket/tree/master/packages/gasket-plugin-fastify",
37
+ "homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-plugin-fastify",
37
38
  "dependencies": {
38
39
  "compression": "^1.7.2",
39
40
  "cookie-parser": "^1.4.3",
@@ -41,12 +42,14 @@
41
42
  "middie": "5.1.0"
42
43
  },
43
44
  "devDependencies": {
45
+ "@gasket/engine": "^6.10.1",
44
46
  "assume": "^2.3.0",
45
47
  "assume-sinon": "^1.1.0",
46
48
  "eslint": "^7.17.0",
47
49
  "eslint-config-godaddy": "^4.0.1",
48
50
  "eslint-plugin-json": "^2.1.2",
49
51
  "eslint-plugin-mocha": "^8.0.0",
52
+ "eslint-plugin-unicorn": "^39.0.0",
50
53
  "fastify": "^3.3.0",
51
54
  "mocha": "^8.2.1",
52
55
  "nyc": "^15.1.0",
@@ -56,5 +59,16 @@
56
59
  "peerDependencies": {
57
60
  "fastify": "^3.0.0"
58
61
  },
59
- "gitHead": "f2098bdfad67493f771c7c00879806efb1dc056d"
62
+ "eslintConfig": {
63
+ "extends": [
64
+ "godaddy"
65
+ ],
66
+ "plugins": [
67
+ "unicorn"
68
+ ],
69
+ "rules": {
70
+ "unicorn/filename-case": "error"
71
+ }
72
+ },
73
+ "gitHead": "7418b4eb588213009c2806dd58af3b968f6bafb6"
60
74
  }