@gasket/plugin-fastify 7.0.0-next.37 → 7.0.0-next.39

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/lib/create.js ADDED
@@ -0,0 +1,34 @@
1
+ /// <reference types="@gasket/core" />
2
+
3
+ const { name, version, devDependencies } = require('../package.json');
4
+
5
+ /**
6
+ * Add files & extend package.json for new apps.
7
+ * @type {import('@gasket/core').HookHandler<'create'>}
8
+ */
9
+ module.exports = async function create(gasket, context) {
10
+ const generatorDir = `${__dirname}/../generator`;
11
+
12
+ context.gasketConfig.addPlugin('pluginFastify', name);
13
+
14
+ context.pkg.add('dependencies', {
15
+ [name]: `^${version}`,
16
+ fastify: devDependencies.fastify
17
+ });
18
+
19
+ if ('apiApp' in context && context.apiApp) {
20
+ context.gasketConfig.add('fastify', {
21
+ routes: []
22
+ });
23
+
24
+ if ('typescript' in context && context.typescript) {
25
+ context.files.add(`${generatorDir}/**/!(*.js)`);
26
+ } else {
27
+ context.files.add(`${generatorDir}/**/!(*.ts)`);
28
+ }
29
+
30
+ context.gasketConfig
31
+ .addImport('{ routes }', './routes/index.js')
32
+ .injectValue('fastify.routes', 'routes');
33
+ }
34
+ };
package/lib/index.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import type { MaybeAsync, MaybeMultiple } from '@gasket/core';
2
2
  import type {
3
- Fastify,
3
+ FastifyInstance,
4
4
  FastifyRequest,
5
5
  FastifyReply,
6
6
  FastifyServerOptions
7
7
  } from 'fastify';
8
8
 
9
+ export type AppRoutes = Array<MaybeAsync<(app: FastifyInstance) => void>>;
10
+
9
11
  declare module '@gasket/core' {
10
12
  export interface GasketConfig {
11
13
  fastify?: {
@@ -18,7 +20,7 @@ declare module '@gasket/core' {
18
20
  /** Trust proxy configuration */
19
21
  trustProxy?: FastifyServerOptions['trustProxy'];
20
22
  /** Glob pattern for source files setting up fastify routes */
21
- routes?: Array<MaybeAsync<(app: Fastify) => void>>;
23
+ routes?: Array<MaybeAsync<(app: FastifyInstance) => void>>;
22
24
  };
23
25
  /** Middleware configuration */
24
26
  middleware?: {
@@ -47,7 +49,7 @@ declare module '@gasket/core' {
47
49
  middleware(
48
50
  fastify: Fastify
49
51
  ): MaybeAsync<MaybeMultiple<Handler> & { paths?: (string | RegExp)[] }>;
50
- fastify(fastify: Fastify): MaybeAsync<void>;
52
+ fastify(fastify: FastifyInstance): MaybeAsync<void>;
51
53
  errorMiddleware(): MaybeAsync<MaybeMultiple<ErrorHandler>>;
52
54
  }
53
55
  }
package/lib/index.js CHANGED
@@ -4,9 +4,9 @@
4
4
  const {
5
5
  name,
6
6
  version,
7
- description,
8
- peerDependencies
7
+ description
9
8
  } = require('../package.json');
9
+ const create = require('./create');
10
10
  const createServers = require('./create-servers');
11
11
 
12
12
  /** @type {import('@gasket/core').Plugin} */
@@ -15,21 +15,7 @@ const plugin = {
15
15
  version,
16
16
  description,
17
17
  hooks: {
18
- create: async function create(gasket, context) {
19
- const generatorDir = `${__dirname}/../generator`;
20
-
21
- context.pkg.add('dependencies', {
22
- fastify: peerDependencies.fastify
23
- });
24
-
25
- if ('apiApp' in context && context.apiApp) {
26
- context.files.add(`${generatorDir}/**/*`);
27
-
28
- context.gasketConfig.add('fastify', {
29
- routes: []
30
- });
31
- }
32
- },
18
+ create,
33
19
  createServers,
34
20
  metadata(gasket, meta) {
35
21
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gasket/plugin-fastify",
3
- "version": "7.0.0-next.37",
3
+ "version": "7.0.0-next.39",
4
4
  "description": "Adds fastify support to your application",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-plugin-fastify",
41
41
  "devDependencies": {
42
- "@gasket/core": "^7.0.0-next.37",
42
+ "@gasket/core": "^7.0.0-next.39",
43
43
  "cross-env": "^7.0.3",
44
44
  "eslint": "^8.56.0",
45
45
  "eslint-config-godaddy": "^7.1.0",
@@ -70,5 +70,5 @@
70
70
  "eslintIgnore": [
71
71
  "generator"
72
72
  ],
73
- "gitHead": "5bf71e70be11a36fd53df3ab535a7199c9d0f320"
73
+ "gitHead": "e430121c9d5ad5d2a27f62272f53fe3eb595a4e4"
74
74
  }