just-another-http-api 1.2.2 → 1.2.4
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/api.js +12 -4
- package/package.json +2 -2
package/api.js
CHANGED
|
@@ -25,6 +25,7 @@ async function createServer ( config ) {
|
|
|
25
25
|
const app = fastify ( {
|
|
26
26
|
logger: config.logs || false,
|
|
27
27
|
name: config.name || packageJson.name,
|
|
28
|
+
...( config?.fastify || {} )
|
|
28
29
|
} );
|
|
29
30
|
|
|
30
31
|
try {
|
|
@@ -109,17 +110,24 @@ function translateLegacyMethods ( method ) {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
function fastifyHandlerWrapper ( handler, config, globalConfig, method ) {
|
|
112
|
-
if ( config?.[ method ]
|
|
113
|
+
if ( config?.[ method ]?.websocket ){
|
|
113
114
|
return handler;
|
|
114
115
|
}
|
|
115
116
|
else {
|
|
116
117
|
return async ( req, reply ) => {
|
|
117
118
|
try {
|
|
118
|
-
let response
|
|
119
|
+
let response;
|
|
120
|
+
if ( globalConfig?.cache?.enabled ){
|
|
121
|
+
const request = { method: req.method, query: JSON.parse ( JSON.stringify ( req.query ) ), routeOptions: req.routeOptions };
|
|
122
|
+
response = await caching.checkRequestCache ( app, request, reply, config, globalConfig );
|
|
119
123
|
|
|
120
|
-
|
|
124
|
+
if ( !response ){
|
|
125
|
+
response = await handler ( req );
|
|
126
|
+
await caching.setRequestCache ( app, request, response, config, globalConfig );
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
121
130
|
response = await handler ( req );
|
|
122
|
-
await caching.setRequestCache ( app, req, response, config, globalConfig );
|
|
123
131
|
}
|
|
124
132
|
|
|
125
133
|
handleResponse ( reply, response, req.method, req.routeOptions.url );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "just-another-http-api",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "A framework built on top of fastify aimed at removing the need for any network or server configuration. ",
|
|
5
5
|
"homepage": "https://github.com/OllieEdge/just-another-http-api#readme",
|
|
6
6
|
"repository": {
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
"eip-cloud-services": "^1.1.0",
|
|
44
44
|
"mocha": "^10.2.0"
|
|
45
45
|
}
|
|
46
|
-
}
|
|
46
|
+
}
|