@thzero/library_server_fastify 0.17.17 → 0.17.19
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/boot/index.js +18 -5
- package/package.json +4 -4
package/boot/index.js
CHANGED
|
@@ -25,6 +25,7 @@ import authorizationDefault from '../middleware/authorization.js';
|
|
|
25
25
|
|
|
26
26
|
class FastifyBootMain extends BootMain {
|
|
27
27
|
async _initApp(args, plugins) {
|
|
28
|
+
const __dirname = path.resolve();
|
|
28
29
|
|
|
29
30
|
// const serverFactory = (handler, opts) => {
|
|
30
31
|
// const server = http.createServer((req, res) => {
|
|
@@ -34,13 +35,26 @@ class FastifyBootMain extends BootMain {
|
|
|
34
35
|
// return server;
|
|
35
36
|
// };
|
|
36
37
|
|
|
37
|
-
let http2 = this._appConfig.get('http2', false);
|
|
38
|
-
|
|
39
|
-
this.loggerServiceI.info2(`config.http2.override: ${
|
|
38
|
+
let http2 = this._appConfig.get('http2', { enabled: false });
|
|
39
|
+
const http2_enabled = http2 && http2.enabled === 'true' ? true : false;
|
|
40
|
+
this.loggerServiceI.info2(`config.http2.override: ${http2_enabled}`);
|
|
41
|
+
let https = null;
|
|
42
|
+
if (http2_enabled) {
|
|
43
|
+
let http2 = this._appConfig.get('http2', false);
|
|
44
|
+
if (!http2.key)
|
|
45
|
+
throw Error('Invalid key, required by http2');
|
|
46
|
+
if (!http2.cert)
|
|
47
|
+
throw Error('Invalid cert, required by http2');
|
|
48
|
+
https = {
|
|
49
|
+
key: http2.key,
|
|
50
|
+
cert: http2.cert
|
|
51
|
+
}
|
|
52
|
+
}
|
|
40
53
|
|
|
41
54
|
// const fastify = Fastify({ serverFactory, logger: true });
|
|
42
55
|
const fastify = Fastify({
|
|
43
|
-
http2:
|
|
56
|
+
http2: http2_enabled,
|
|
57
|
+
https: https,
|
|
44
58
|
logger: true
|
|
45
59
|
});
|
|
46
60
|
const serverHttp = fastify.server;
|
|
@@ -180,7 +194,6 @@ class FastifyBootMain extends BootMain {
|
|
|
180
194
|
|
|
181
195
|
// app.use(koaStatic('./public'));
|
|
182
196
|
// https://github.com/fastify/fastify-static
|
|
183
|
-
const __dirname = path.resolve();
|
|
184
197
|
await fastify.register(fastifyStatic, {
|
|
185
198
|
root: path.join(__dirname, 'public'),
|
|
186
199
|
prefix: '/public/', // optional: default '/'
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thzero/library_server_fastify",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.17.
|
|
4
|
+
"version": "0.17.19",
|
|
5
5
|
"version_major": 0,
|
|
6
6
|
"version_minor": 17,
|
|
7
|
-
"version_patch":
|
|
8
|
-
"version_date": "
|
|
7
|
+
"version_patch": 19,
|
|
8
|
+
"version_date": "12/31/2023",
|
|
9
9
|
"description": "An opinionated library of common functionality to bootstrap a Fastify based API application.",
|
|
10
10
|
"author": "thZero",
|
|
11
11
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@fastify/auth": "^4.4.0",
|
|
29
29
|
"@fastify/compress": "^6.5.0",
|
|
30
|
-
"@fastify/cors": "^8.4.
|
|
30
|
+
"@fastify/cors": "^8.4.2",
|
|
31
31
|
"@fastify/helmet": "^11.1.1",
|
|
32
32
|
"@fastify/routes": "^5.1.0",
|
|
33
33
|
"@fastify/static": "^6.12.0",
|