@gasket/plugin-fastify 7.3.4 → 7.3.5
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/README.md +0 -1
- package/lib/actions.js +17 -0
- package/lib/create-servers.js +2 -8
- package/lib/create.js +2 -9
- package/lib/index.js +3 -22
- package/lib/utils.js +26 -2
- package/package.json +12 -4
package/README.md
CHANGED
package/lib/actions.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const { getAppInstance } = require('./utils.js');
|
|
2
|
+
|
|
3
|
+
const actions = {
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated
|
|
6
|
+
* @param {import('@gasket/core').Gasket} gasket - Gasket instance
|
|
7
|
+
* @returns {import('fastify').FastifyInstance} - Fastify instance
|
|
8
|
+
*/
|
|
9
|
+
getFastifyApp(gasket) {
|
|
10
|
+
gasket.logger.warn(
|
|
11
|
+
`DEPRECATED \`getFastifyApp\` action will not be support in future major release.`
|
|
12
|
+
);
|
|
13
|
+
return getAppInstance(gasket);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
module.exports = actions;
|
package/lib/create-servers.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="@gasket/plugin-https" />
|
|
2
2
|
/// <reference types="@gasket/plugin-logger" />
|
|
3
3
|
|
|
4
|
+
const { getAppInstance } = require('./utils.js');
|
|
4
5
|
/**
|
|
5
6
|
* Create the Fastify instance and setup the lifecycle hooks.
|
|
6
7
|
* Fastify is compatible with express middleware out of the box, so we can
|
|
@@ -9,14 +10,7 @@
|
|
|
9
10
|
*/
|
|
10
11
|
// eslint-disable-next-line max-statements
|
|
11
12
|
module.exports = async function createServers(gasket, serverOpts) {
|
|
12
|
-
const
|
|
13
|
-
const { alignLogger } = require('./utils');
|
|
14
|
-
const { fastify: fastifyConfig = {}, http2, https } = gasket.config;
|
|
15
|
-
const { trustProxy = false, disableRequestLogging = true } = fastifyConfig;
|
|
16
|
-
const fastifyLogger = alignLogger(gasket.logger);
|
|
17
|
-
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
const app = fastify({ logger: fastifyLogger, trustProxy, https, http2, disableRequestLogging });
|
|
13
|
+
const app = getAppInstance(gasket);
|
|
20
14
|
|
|
21
15
|
// allow consuming apps to directly append options to their server
|
|
22
16
|
// @ts-ignore
|
package/lib/create.js
CHANGED
|
@@ -3,14 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
const { name, version, devDependencies } = require('../package.json');
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* createTestFiles
|
|
8
|
-
* @property {Files} files - The Gasket Files API.
|
|
9
|
-
* @property {generatorDir} - The directory of the generator.
|
|
10
|
-
* @property {testPlugins} - Array of selected test plugins
|
|
11
|
-
* @property {globIgnore} - Extension pattern to ignore
|
|
12
|
-
*/
|
|
13
|
-
function createTestFiles({ files, generatorDir, testPlugins, globIgnore }) {
|
|
6
|
+
const createTestFiles = ({ files, generatorDir, testPlugins, globIgnore }) => {
|
|
14
7
|
if (!testPlugins || testPlugins.length === 0) return;
|
|
15
8
|
const unit = ['jest', 'mocha'];
|
|
16
9
|
const integration = ['cypress'];
|
|
@@ -28,7 +21,7 @@ function createTestFiles({ files, generatorDir, testPlugins, globIgnore }) {
|
|
|
28
21
|
}
|
|
29
22
|
}
|
|
30
23
|
});
|
|
31
|
-
}
|
|
24
|
+
};
|
|
32
25
|
|
|
33
26
|
/**
|
|
34
27
|
* Add files & extend package.json for new apps.
|
package/lib/index.js
CHANGED
|
@@ -1,36 +1,17 @@
|
|
|
1
1
|
/// <reference types="@gasket/core" />
|
|
2
2
|
/// <reference types="@gasket/plugin-metadata" />
|
|
3
3
|
|
|
4
|
-
const {
|
|
5
|
-
name,
|
|
6
|
-
version,
|
|
7
|
-
description
|
|
8
|
-
} = require('../package.json');
|
|
4
|
+
const { name, version, description } = require('../package.json');
|
|
9
5
|
const create = require('./create');
|
|
10
6
|
const createServers = require('./create-servers');
|
|
11
|
-
const
|
|
12
|
-
const { alignLogger } = require('./utils');
|
|
13
|
-
|
|
14
|
-
let app;
|
|
7
|
+
const actions = require('./actions');
|
|
15
8
|
|
|
16
9
|
/** @type {import('@gasket/core').Plugin} */
|
|
17
10
|
const plugin = {
|
|
18
11
|
name,
|
|
19
12
|
version,
|
|
20
13
|
description,
|
|
21
|
-
actions
|
|
22
|
-
/** @deprecated */
|
|
23
|
-
getFastifyApp(gasket) {
|
|
24
|
-
const { fastify: fastifyConfig = {}, http2, https } = gasket.config;
|
|
25
|
-
const { trustProxy = false, disableRequestLogging = true } = fastifyConfig;
|
|
26
|
-
const fastifyLogger = alignLogger(gasket.logger);
|
|
27
|
-
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
app ??= fastify({ logger: fastifyLogger, trustProxy, https, http2, disableRequestLogging });
|
|
30
|
-
|
|
31
|
-
return app;
|
|
32
|
-
}
|
|
33
|
-
},
|
|
14
|
+
actions,
|
|
34
15
|
hooks: {
|
|
35
16
|
create,
|
|
36
17
|
createServers,
|
package/lib/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
const fallbackMap = {
|
|
4
4
|
fatal: 'error',
|
|
5
5
|
trace: 'debug'
|
|
@@ -21,6 +21,30 @@ function alignLogger(logger) {
|
|
|
21
21
|
return fastifyLogger;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
let instance = null;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get the Fastify instance.
|
|
28
|
+
* @param {import('@gasket/core').Gasket} gasket - Gasket instance
|
|
29
|
+
* @returns {import('fastify').FastifyInstance} - Fastify instance
|
|
30
|
+
*/
|
|
31
|
+
function getAppInstance(gasket) {
|
|
32
|
+
if (!instance) {
|
|
33
|
+
const fastify = require('fastify');
|
|
34
|
+
const { fastify: fastifyConfig = {}, http2, https } = gasket.config;
|
|
35
|
+
const { trustProxy = false, disableRequestLogging = true } = fastifyConfig;
|
|
36
|
+
const fastifyLogger = alignLogger(gasket.logger);
|
|
37
|
+
|
|
38
|
+
instance = fastify({ logger: fastifyLogger, trustProxy, https, http2, disableRequestLogging });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return instance;
|
|
42
|
+
}
|
|
43
|
+
|
|
24
44
|
module.exports = {
|
|
25
|
-
alignLogger
|
|
45
|
+
alignLogger,
|
|
46
|
+
getAppInstance,
|
|
47
|
+
testClearAppInstance: () => {
|
|
48
|
+
instance = null;
|
|
49
|
+
}
|
|
26
50
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gasket/plugin-fastify",
|
|
3
|
-
"version": "7.3.
|
|
3
|
+
"version": "7.3.5",
|
|
4
4
|
"description": "Adds fastify support to your application",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"fastify": "^4.29.0",
|
|
37
37
|
"jest": "^29.7.0",
|
|
38
38
|
"typescript": "^5.7.3",
|
|
39
|
-
"@gasket/core": "7.
|
|
39
|
+
"@gasket/core": "7.4.0",
|
|
40
40
|
"@gasket/plugin-https": "7.3.4",
|
|
41
41
|
"@gasket/plugin-logger": "7.3.3",
|
|
42
|
-
"@gasket/plugin-metadata": "7.3.
|
|
43
|
-
"create-gasket-app": "7.3.
|
|
42
|
+
"@gasket/plugin-metadata": "7.3.6",
|
|
43
|
+
"create-gasket-app": "7.3.5"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"fastify": "^4.29.0"
|
|
@@ -69,6 +69,14 @@
|
|
|
69
69
|
"rules": {
|
|
70
70
|
"jsdoc/*": "off"
|
|
71
71
|
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"files": [
|
|
75
|
+
"test/**/*.js"
|
|
76
|
+
],
|
|
77
|
+
"rules": {
|
|
78
|
+
"jsdoc/require-jsdoc": "off"
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
81
|
]
|
|
74
82
|
},
|