@athenna/http 5.6.0 → 5.8.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.
- package/package.json +16 -12
- package/src/kernels/HttpKernel.d.ts +4 -0
- package/src/kernels/HttpKernel.js +19 -0
- package/src/server/ServerImpl.d.ts +4 -0
- package/src/server/ServerImpl.js +13 -0
- package/src/vite/index.d.ts +2 -0
- package/src/vite/index.js +31 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@athenna/http",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.8.0",
|
|
4
4
|
"description": "The Athenna Http server. Built on top of fastify.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "João Lenon <lenon@athenna.io>",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"./types": "./src/types/index.js",
|
|
52
52
|
"./package": "./package.json",
|
|
53
53
|
"./package.json": "./package.json",
|
|
54
|
+
"./vite": "./src/vite/index.js",
|
|
54
55
|
"./testing/plugins": "./src/testing/plugins/index.js",
|
|
55
56
|
"./kernels/HttpKernel": "./src/kernels/HttpKernel.js",
|
|
56
57
|
"./handlers/HttpExceptionHandler": "./src/handlers/HttpExceptionHandler.js",
|
|
@@ -73,37 +74,40 @@
|
|
|
73
74
|
"#tests": "./tests/index.js"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
|
-
"@athenna/artisan": "^5.
|
|
77
|
-
"@athenna/common": "^5.
|
|
78
|
-
"@athenna/config": "^5.
|
|
77
|
+
"@athenna/artisan": "^5.3.0",
|
|
78
|
+
"@athenna/common": "^5.3.0",
|
|
79
|
+
"@athenna/config": "^5.1.0",
|
|
79
80
|
"@athenna/ioc": "^5.0.0",
|
|
80
|
-
"@athenna/logger": "^5.
|
|
81
|
-
"@athenna/test": "^5.
|
|
81
|
+
"@athenna/logger": "^5.1.0",
|
|
82
|
+
"@athenna/test": "^5.2.0",
|
|
82
83
|
"@athenna/tsconfig": "^5.0.0",
|
|
83
|
-
"@athenna/view": "^5.
|
|
84
|
+
"@athenna/view": "^5.1.0",
|
|
84
85
|
"@fastify/cors": "^8.5.0",
|
|
85
86
|
"@fastify/helmet": "^11.1.1",
|
|
86
87
|
"@fastify/rate-limit": "^8.1.1",
|
|
87
88
|
"@fastify/static": "^7.0.4",
|
|
88
89
|
"@fastify/swagger": "^8.15.0",
|
|
89
90
|
"@fastify/swagger-ui": "^3.1.0",
|
|
91
|
+
"@fastify/vite": "^7.0.1",
|
|
90
92
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
91
93
|
"@typescript-eslint/parser": "^7.18.0",
|
|
92
94
|
"autocannon": "^7.15.0",
|
|
93
|
-
"commitizen": "^4.3.
|
|
95
|
+
"commitizen": "^4.3.1",
|
|
94
96
|
"cz-conventional-changelog": "^3.3.0",
|
|
95
|
-
"eslint": "^8.57.
|
|
97
|
+
"eslint": "^8.57.1",
|
|
96
98
|
"eslint-config-prettier": "^8.10.0",
|
|
97
99
|
"eslint-config-standard": "^17.1.0",
|
|
98
|
-
"eslint-plugin-import": "^2.
|
|
100
|
+
"eslint-plugin-import": "^2.31.0",
|
|
99
101
|
"eslint-plugin-n": "^15.7.0",
|
|
100
102
|
"eslint-plugin-prettier": "^4.2.1",
|
|
101
103
|
"eslint-plugin-promise": "^6.6.0",
|
|
102
104
|
"foreground-child": "^2.0.0",
|
|
103
105
|
"husky": "^3.1.0",
|
|
104
106
|
"lint-staged": "^12.5.0",
|
|
105
|
-
"ora": "^8.1.
|
|
106
|
-
"prettier": "^2.8.8"
|
|
107
|
+
"ora": "^8.1.1",
|
|
108
|
+
"prettier": "^2.8.8",
|
|
109
|
+
"vite": "^6.0.6",
|
|
110
|
+
"vite-plugin-restart": "^0.4.2"
|
|
107
111
|
},
|
|
108
112
|
"c8": {
|
|
109
113
|
"all": true,
|
|
@@ -32,6 +32,10 @@ export declare class HttpKernel {
|
|
|
32
32
|
* Register the cls-rtracer plugin in the Http server.
|
|
33
33
|
*/
|
|
34
34
|
registerRTracer(trace?: boolean): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* Register the @fastify/vite plugin in the Http server.
|
|
37
|
+
*/
|
|
38
|
+
registerVite(trace?: boolean): Promise<void>;
|
|
35
39
|
/**
|
|
36
40
|
* Register the global log terminator in the Http server.
|
|
37
41
|
*/
|
|
@@ -22,6 +22,7 @@ const swaggerUiPlugin = await Module.safeImport('@fastify/swagger-ui');
|
|
|
22
22
|
const rateLimitPlugin = await Module.safeImport('@fastify/rate-limit');
|
|
23
23
|
const staticPlugin = await Module.safeImport('@fastify/static');
|
|
24
24
|
const rTracerPlugin = await Module.safeImport('cls-rtracer');
|
|
25
|
+
const vitePlugin = await Module.safeImport('@fastify/vite');
|
|
25
26
|
export class HttpKernel {
|
|
26
27
|
/**
|
|
27
28
|
* Register the @fastify/cors plugin in the Http server.
|
|
@@ -128,6 +129,24 @@ export class HttpKernel {
|
|
|
128
129
|
Server.middleware(async (ctx) => (ctx.data.traceId = rTracerPlugin.id()));
|
|
129
130
|
await Server.plugin(rTracerPlugin.fastifyPlugin, this.getConfig('http.rTracer'));
|
|
130
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Register the @fastify/vite plugin in the Http server.
|
|
134
|
+
*/
|
|
135
|
+
async registerVite(trace) {
|
|
136
|
+
if (trace === false) {
|
|
137
|
+
debug('Not able to register vite plugin. Set the trace option as true in your http server options.');
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (trace === undefined && Config.is('http.vite.enabled', false)) {
|
|
141
|
+
debug('Not able to register vite plugin. Set the http.vite.enabled configuration as true.');
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (!vitePlugin) {
|
|
145
|
+
debug('Not able to register vite plugin. Install @fastify/vite package.');
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
await Server.plugin(vitePlugin, this.getConfig('http.vite'));
|
|
149
|
+
}
|
|
131
150
|
/**
|
|
132
151
|
* Register the global log terminator in the Http server.
|
|
133
152
|
*/
|
package/src/server/ServerImpl.js
CHANGED
|
@@ -119,6 +119,19 @@ export class ServerImpl {
|
|
|
119
119
|
async listen(options) {
|
|
120
120
|
return this.fastify.listen(options).then(() => (this.isListening = true));
|
|
121
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Start vite server.
|
|
124
|
+
*/
|
|
125
|
+
async viteReady() {
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
127
|
+
// @ts-ignore
|
|
128
|
+
if (!this.fastify.vite) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
return this.fastify.vite.ready();
|
|
134
|
+
}
|
|
122
135
|
/**
|
|
123
136
|
* Close the server,
|
|
124
137
|
*/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Path } from '@athenna/common';
|
|
2
|
+
import { mergeConfig, defineConfig } from 'vite';
|
|
3
|
+
export function defineAthennaConfig(config) {
|
|
4
|
+
const defaultConfig = {
|
|
5
|
+
root: Path.pwd(),
|
|
6
|
+
assetsUrl: '/assets',
|
|
7
|
+
buildDirectory: 'public/assets',
|
|
8
|
+
css: {
|
|
9
|
+
preprocessorOptions: {
|
|
10
|
+
scss: {
|
|
11
|
+
api: 'modern'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
build: {
|
|
16
|
+
assetsDir: '',
|
|
17
|
+
manifest: true,
|
|
18
|
+
emptyOutDir: true,
|
|
19
|
+
outDir: 'public/assets',
|
|
20
|
+
assetsInlineLimit: 0,
|
|
21
|
+
rollupOptions: {
|
|
22
|
+
output: {
|
|
23
|
+
entryFileNames: '[name].js',
|
|
24
|
+
chunkFileNames: '[name].js',
|
|
25
|
+
assetFileNames: '[name].[ext]'
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
return defineConfig(mergeConfig(defaultConfig, config));
|
|
31
|
+
}
|