@thzero/library_server_fastify 0.16.9 → 0.16.11
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 +2 -2
- package/package.json +6 -6
- package/routes/admin/index.js +8 -4
- package/routes/baseNews.js +2 -1
- package/routes/baseUsers.js +10 -5
- package/routes/index.js +2 -2
- package/routes/plans.js +2 -1
- package/routes/utility.js +2 -1
- package/routes/version.js +2 -1
package/boot/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'path';
|
|
|
3
3
|
import Fastify from 'fastify';
|
|
4
4
|
// import fastifyAuth from '@fastify/auth';
|
|
5
5
|
import fastifyAuth from '../plugins/auth.js';
|
|
6
|
-
import
|
|
6
|
+
import fastifyCompression from '@fastify/compress';
|
|
7
7
|
import fastifyCors from '@fastify/cors';
|
|
8
8
|
import fastifyHelmet from '@fastify/helmet';
|
|
9
9
|
import fastifyRoutes from '@fastify/routes';
|
|
@@ -94,7 +94,7 @@ class FastifyBootMain extends BootMain {
|
|
|
94
94
|
requestEncodings: [ 'br', 'gzip' ]
|
|
95
95
|
});
|
|
96
96
|
await fastify.register(
|
|
97
|
-
|
|
97
|
+
fastifyCompression,
|
|
98
98
|
compressionOptions
|
|
99
99
|
);
|
|
100
100
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thzero/library_server_fastify",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.11",
|
|
5
5
|
"version_major": 0,
|
|
6
6
|
"version_minor": 16,
|
|
7
|
-
"version_patch":
|
|
8
|
-
"version_date": "12/
|
|
7
|
+
"version_patch": 11,
|
|
8
|
+
"version_date": "12/20/2022",
|
|
9
9
|
"description": "An opinionated library of common functionality to bootstrap a Fastify based API application.",
|
|
10
10
|
"author": "thZero",
|
|
11
11
|
"license": "MIT",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@fastify/auth": "^4.
|
|
28
|
+
"@fastify/auth": "^4.2.0",
|
|
29
29
|
"@fastify/compress": "^6.2.0",
|
|
30
30
|
"@fastify/cors": "^8.2.0",
|
|
31
31
|
"@fastify/helmet": "^10.1.0",
|
|
32
|
-
"@fastify/routes": "^5.
|
|
33
|
-
"@fastify/static": "^6.
|
|
32
|
+
"@fastify/routes": "^5.1.0",
|
|
33
|
+
"@fastify/static": "^6.6.0",
|
|
34
34
|
"async-mutex": "^0.4.0",
|
|
35
35
|
"fastify": "^4.10.2"
|
|
36
36
|
},
|
package/routes/admin/index.js
CHANGED
|
@@ -50,7 +50,8 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
50
50
|
// eslint-disable-next-line
|
|
51
51
|
async (request, reply) => {
|
|
52
52
|
const response = (await router[this._options.serviceKey].create(request.correlationId, request.user, request.body)).check(request);
|
|
53
|
-
|
|
53
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
54
|
+
return this._jsonResponse(reply, response);
|
|
54
55
|
}
|
|
55
56
|
);
|
|
56
57
|
}
|
|
@@ -72,7 +73,8 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
72
73
|
// eslint-disable-next-line
|
|
73
74
|
async (request, reply) => {
|
|
74
75
|
const response = (await router[this._options.serviceKey].delete(request.correlationId, request.user, request.params.id)).check(request);
|
|
75
|
-
|
|
76
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
77
|
+
return this._jsonResponse(reply, response);
|
|
76
78
|
}
|
|
77
79
|
);
|
|
78
80
|
}
|
|
@@ -94,7 +96,8 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
94
96
|
// eslint-disable-next-line
|
|
95
97
|
async (request, reply) => {
|
|
96
98
|
const response = (await router[this._options.serviceKey].update(request.correlationId, request.user, request.params.id, request.body)).check(request);
|
|
97
|
-
|
|
99
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
100
|
+
return this._jsonResponse(reply, response);
|
|
98
101
|
}
|
|
99
102
|
);
|
|
100
103
|
}
|
|
@@ -119,7 +122,8 @@ class AdminBaseRoute extends BaseRoute {
|
|
|
119
122
|
// eslint-disable-next-line
|
|
120
123
|
async (request, reply) => {
|
|
121
124
|
const response = (await router[this._options.serviceKey].search(request.correlationId, request.user, request.body)).check(request);
|
|
122
|
-
|
|
125
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
126
|
+
return this._jsonResponse(reply, response);
|
|
123
127
|
}
|
|
124
128
|
);
|
|
125
129
|
|
package/routes/baseNews.js
CHANGED
|
@@ -36,7 +36,8 @@ class BaseNewsRoute extends BaseRoute {
|
|
|
36
36
|
async (request, reply) => {
|
|
37
37
|
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_NEWS);
|
|
38
38
|
const response = (await router[LibraryConstants.InjectorKeys.SERVICE_NEWS].latest(request.correlationId, request.user, parseInt(request.params.date))).check(request);
|
|
39
|
-
|
|
39
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
40
|
+
return this._jsonResponse(reply, response);
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
}
|
package/routes/baseUsers.js
CHANGED
|
@@ -46,7 +46,8 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
46
46
|
async (request, reply) => {
|
|
47
47
|
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
48
48
|
const response = (await router[LibraryConstants.InjectorKeys.SERVICE_USERS].fetchByGamerId(request.correlationId, request.params.gamerId)).check(request);
|
|
49
|
-
|
|
49
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
50
|
+
return this._jsonResponse(reply, response);
|
|
50
51
|
}
|
|
51
52
|
);
|
|
52
53
|
}
|
|
@@ -70,7 +71,8 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
70
71
|
async (request, reply) => {
|
|
71
72
|
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
72
73
|
const response = (await router[LibraryConstants.InjectorKeys.SERVICE_USERS].fetchByGamerTag(request.correlationId, request.params.gamerTag)).check(request);
|
|
73
|
-
|
|
74
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
75
|
+
return this._jsonResponse(reply, response);
|
|
74
76
|
}
|
|
75
77
|
);
|
|
76
78
|
}
|
|
@@ -93,7 +95,8 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
93
95
|
async (request, reply) => {
|
|
94
96
|
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
95
97
|
const response = (await router[LibraryConstants.InjectorKeys.SERVICE_USERS].refreshSettings(request.correlationId, request.body)).check(request);
|
|
96
|
-
|
|
98
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
99
|
+
return this._jsonResponse(reply, response);
|
|
97
100
|
}
|
|
98
101
|
);
|
|
99
102
|
}
|
|
@@ -116,7 +119,8 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
116
119
|
async (request, reply) => {
|
|
117
120
|
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
118
121
|
const response = (await router[LibraryConstants.InjectorKeys.SERVICE_USERS].update(request.correlationId, request.body)).check(request);
|
|
119
|
-
|
|
122
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
123
|
+
return this._jsonResponse(reply, response);
|
|
120
124
|
}
|
|
121
125
|
);
|
|
122
126
|
}
|
|
@@ -139,7 +143,8 @@ class BaseUsersRoute extends BaseRoute {
|
|
|
139
143
|
async (request, reply) => {
|
|
140
144
|
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_USERS);
|
|
141
145
|
const response = (await router[LibraryConstants.InjectorKeys.SERVICE_USERS].updateSettings(request.correlationId, request.body)).check(request);
|
|
142
|
-
|
|
146
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
147
|
+
return this._jsonResponse(reply, response);
|
|
143
148
|
}
|
|
144
149
|
);
|
|
145
150
|
}
|
package/routes/index.js
CHANGED
|
@@ -31,10 +31,10 @@ class FastifyBaseRoute extends BaseRoute {
|
|
|
31
31
|
if (!reply)
|
|
32
32
|
throw Error('Invalid context for response.');
|
|
33
33
|
|
|
34
|
-
reply
|
|
34
|
+
return reply
|
|
35
35
|
.code(200)
|
|
36
36
|
.header('Content-Type', 'application/json; charset=utf-8')
|
|
37
|
-
.send((typeof
|
|
37
|
+
.send((typeof json === 'string') ? json : Utility.stringify(json));
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
package/routes/plans.js
CHANGED
|
@@ -25,7 +25,8 @@ class PlansRoute extends BaseRoute {
|
|
|
25
25
|
async (request, reply) => {
|
|
26
26
|
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_PLANS);
|
|
27
27
|
const response = (await router[LibraryConstants.InjectorKeys.SERVICE_PLANS].listing(request.correlationId, request.body)).check(request);
|
|
28
|
-
|
|
28
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
29
|
+
return this._jsonResponse(reply, response);
|
|
29
30
|
}
|
|
30
31
|
);
|
|
31
32
|
}
|
package/routes/utility.js
CHANGED
|
@@ -38,7 +38,8 @@ class UtilityRoute extends BaseRoute {
|
|
|
38
38
|
async (request, reply) => {
|
|
39
39
|
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_UTILITY);
|
|
40
40
|
const response = (await router[LibraryConstants.InjectorKeys.SERVICE_UTILITY].logger(request.correlationId, request.body)).check(request);
|
|
41
|
-
|
|
41
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
42
|
+
return this._jsonResponse(reply, response);
|
|
42
43
|
}
|
|
43
44
|
);
|
|
44
45
|
}
|
package/routes/version.js
CHANGED
|
@@ -25,7 +25,8 @@ class VersionRoute extends BaseRoute {
|
|
|
25
25
|
async (request, reply) => {
|
|
26
26
|
// const service = this._injector.getService(LibraryConstants.InjectorKeys.SERVICE_VERSION);
|
|
27
27
|
const response = (await router[LibraryConstants.InjectorKeys.SERVICE_VERSION].version(request.correlationId)).check(request);
|
|
28
|
-
|
|
28
|
+
// https://github.com/fastify/fastify-compress/issues/215#issuecomment-1210598312
|
|
29
|
+
return this._jsonResponse(reply, response);
|
|
29
30
|
}
|
|
30
31
|
);
|
|
31
32
|
}
|