@gasket/plugin-fastify 7.3.5 → 7.4.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.
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { vi, expect } from 'vitest';
|
|
2
|
+
import { defaultHandler } from '../plugins/routes-plugin.js';
|
|
3
|
+
|
|
4
|
+
describe('Routes', () => {
|
|
5
|
+
let mockRequest, mockResponse;
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
mockRequest = {};
|
|
9
|
+
mockResponse = {
|
|
10
|
+
statusCode: 200,
|
|
11
|
+
send: vi.fn()
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('defaultHeader should use expected message', async () => {
|
|
16
|
+
await defaultHandler(mockRequest, mockResponse);
|
|
17
|
+
expect(mockResponse.send).toHaveBeenCalledWith({
|
|
18
|
+
message: 'Welcome to your default route...'
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
2
|
+
import { defaultHandler } from '../plugins/routes-plugin.js';
|
|
3
|
+
|
|
4
|
+
describe('Routes', () => {
|
|
5
|
+
let mockRequest, mockResponse;
|
|
6
|
+
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
mockRequest = {};
|
|
9
|
+
mockResponse = {
|
|
10
|
+
statusCode: 200,
|
|
11
|
+
send: vi.fn()
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('defaultHeader should use expected message', async () => {
|
|
16
|
+
await defaultHandler(mockRequest, mockResponse);
|
|
17
|
+
expect(mockResponse.send).toHaveBeenCalledWith({
|
|
18
|
+
message: 'Welcome to your default route...'
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
});
|
package/lib/create-servers.js
CHANGED
|
@@ -8,17 +8,19 @@ const { getAppInstance } = require('./utils.js');
|
|
|
8
8
|
* use the same middleware lifecycles.
|
|
9
9
|
* @type {import('@gasket/core').HookHandler<'createServers'>}
|
|
10
10
|
*/
|
|
11
|
-
// eslint-disable-next-line max-statements
|
|
12
11
|
module.exports = async function createServers(gasket, serverOpts) {
|
|
13
|
-
|
|
12
|
+
/** Cast to Fastify + Express hybrid because Gasket adds `.use()` via @fastify/express plugin */
|
|
13
|
+
const app = /** @type {import('fastify').FastifyInstance & { use: Function }} */ (getAppInstance(gasket));
|
|
14
14
|
|
|
15
15
|
// allow consuming apps to directly append options to their server
|
|
16
|
-
// @ts-ignore
|
|
17
16
|
await gasket.exec('fastify', app);
|
|
18
17
|
|
|
19
18
|
const postRenderingStacks = (await gasket.exec('errorMiddleware')).filter(Boolean);
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
postRenderingStacks.forEach((stack) => {
|
|
20
|
+
/** @type {import('connect').NextHandleFunction} */
|
|
21
|
+
const middleware = stack;
|
|
22
|
+
app.use(middleware);
|
|
23
|
+
});
|
|
22
24
|
|
|
23
25
|
return {
|
|
24
26
|
...serverOpts,
|
package/lib/create.js
CHANGED
|
@@ -5,7 +5,7 @@ const { name, version, devDependencies } = require('../package.json');
|
|
|
5
5
|
|
|
6
6
|
const createTestFiles = ({ files, generatorDir, testPlugins, globIgnore }) => {
|
|
7
7
|
if (!testPlugins || testPlugins.length === 0) return;
|
|
8
|
-
const unit = ['jest', 'mocha'];
|
|
8
|
+
const unit = ['jest', 'mocha', 'vitest'];
|
|
9
9
|
const integration = ['cypress'];
|
|
10
10
|
const frameworks = [...unit, ...integration];
|
|
11
11
|
const frameworksRegex = new RegExp(frameworks.join('|'));
|
package/lib/index.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export interface FastifyConfig {
|
|
|
20
20
|
disableRequestLogging?: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export type FastifyOptions = FastifyServerOptions & {
|
|
24
|
+
https?: any,
|
|
25
|
+
http2?: boolean | object
|
|
26
|
+
}
|
|
27
|
+
|
|
23
28
|
declare module '@gasket/core' {
|
|
24
29
|
export interface GasketActions {
|
|
25
30
|
/** @deprecated */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gasket/plugin-fastify",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"description": "Adds fastify support to your application",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -22,9 +22,11 @@
|
|
|
22
22
|
"bugs": "https://github.com/godaddy/gasket/issues",
|
|
23
23
|
"homepage": "https://github.com/godaddy/gasket/tree/main/packages/gasket-plugin-fastify",
|
|
24
24
|
"dependencies": {
|
|
25
|
+
"@fastify/express": "^3.0.0",
|
|
25
26
|
"fastify": "^4.29.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
29
|
+
"@types/connect": "^3.4.38",
|
|
28
30
|
"@types/jest": "^29.5.14",
|
|
29
31
|
"@types/node": "^20.17.19",
|
|
30
32
|
"cross-env": "^7.0.3",
|
|
@@ -35,12 +37,12 @@
|
|
|
35
37
|
"eslint-plugin-unicorn": "^55.0.0",
|
|
36
38
|
"fastify": "^4.29.0",
|
|
37
39
|
"jest": "^29.7.0",
|
|
38
|
-
"typescript": "^5.
|
|
39
|
-
"@gasket/core": "7.
|
|
40
|
-
"@gasket/plugin-https": "7.3.
|
|
41
|
-
"@gasket/plugin-logger": "7.3.
|
|
42
|
-
"@gasket/plugin-metadata": "7.
|
|
43
|
-
"create-gasket-app": "7.
|
|
40
|
+
"typescript": "^5.8.2",
|
|
41
|
+
"@gasket/core": "7.5.0",
|
|
42
|
+
"@gasket/plugin-https": "7.3.5",
|
|
43
|
+
"@gasket/plugin-logger": "7.3.4",
|
|
44
|
+
"@gasket/plugin-metadata": "7.4.0",
|
|
45
|
+
"create-gasket-app": "7.4.0"
|
|
44
46
|
},
|
|
45
47
|
"peerDependencies": {
|
|
46
48
|
"fastify": "^4.29.0"
|