just-another-http-api 1.0.1 → 1.0.3
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/README.md +1 -1
- package/api.js +5 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-

|
|
2
2
|
|
|
3
3
|
[](https://github.com/OllieEdge/just-another-http-api/actions/workflows/main.yml)
|
|
4
4
|
[](https://github.com/Naereen/badges/)
|
package/api.js
CHANGED
|
@@ -73,9 +73,12 @@ module.exports = async ( config, every = null, _server = null ) => {
|
|
|
73
73
|
} //
|
|
74
74
|
else if ( response.hasOwnProperty ( 'json' ) || response.hasOwnProperty ( 'body' ) || response.hasOwnProperty ( 'response' ) || typeof response === 'string' ){
|
|
75
75
|
data = response?.json || response?.body || response?.response || response;
|
|
76
|
+
res.setHeader ( 'Content-Type', 'application/json' );
|
|
76
77
|
res.send ( method === 'post' ? 201 : 200, data );
|
|
77
78
|
}
|
|
78
79
|
else if ( response.hasOwnProperty ( 'error' ) ){
|
|
80
|
+
console.error ( error );
|
|
81
|
+
res.setHeader ( 'Content-Type', 'application/json' );
|
|
79
82
|
res.send ( new restifyErrors.makeErrFromCode ( response?.error?.statusCode, response?.error?.message ) );
|
|
80
83
|
}
|
|
81
84
|
else if ( response.hasOwnProperty ( 'file' ) ){
|
|
@@ -88,12 +91,14 @@ module.exports = async ( config, every = null, _server = null ) => {
|
|
|
88
91
|
res.send ( 204 );
|
|
89
92
|
}
|
|
90
93
|
else {
|
|
94
|
+
res.setHeader ( 'Content-Type', 'application/json' );
|
|
91
95
|
res.send ( new restifyErrors.makeErrFromCode ( 500, `Just Another Http API did not understand the response provided for request: ${ method } to ${ endpoint.path }. Check your return value.` ) );
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
return;
|
|
95
99
|
}
|
|
96
100
|
catch ( error ){
|
|
101
|
+
res.setHeader ( 'Content-Type', 'application/json' );
|
|
97
102
|
if ( error instanceof Error ) {
|
|
98
103
|
res.send ( new restifyErrors.InternalServerError ( { code: 500 }, error.stack.replace ( /\n/g, ' ' ) ) );
|
|
99
104
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "just-another-http-api",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A framework built on top of restify 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": {
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"multer": "^1.4.2",
|
|
29
|
-
"recursive-readdir": "^2.2.
|
|
30
|
-
"restify": "
|
|
31
|
-
"restify-cors-middleware2": "^2.
|
|
29
|
+
"recursive-readdir": "^2.2.3",
|
|
30
|
+
"restify": "^10.0.0",
|
|
31
|
+
"restify-cors-middleware2": "^2.2.0",
|
|
32
32
|
"restify-errors": "^8.0.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"chai": "^4.3.
|
|
35
|
+
"chai": "^4.3.7",
|
|
36
36
|
"chai-as-promised": "^7.1.1",
|
|
37
|
-
"mocha": "^10.
|
|
37
|
+
"mocha": "^10.2.0"
|
|
38
38
|
}
|
|
39
39
|
}
|