tr-apisrv 0.1.4 → 0.2.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/index.js +9 -2
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -207,8 +207,15 @@ var ApiSrv = function(opts) {
|
|
|
207
207
|
}
|
|
208
208
|
r.headers = req.headers;
|
|
209
209
|
r.res = res;
|
|
210
|
-
r.jsonResponse = function(data, code) {
|
|
211
|
-
|
|
210
|
+
r.jsonResponse = function(data, code, excludeNoCacheHeaders) {
|
|
211
|
+
var headers = { 'Content-Type': 'application/json; charset=utf-8' };
|
|
212
|
+
if (! excludeNoCacheHeaders) {
|
|
213
|
+
headers = Object.assign(headers,
|
|
214
|
+
{ 'Cache-Control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0',
|
|
215
|
+
'Expires': 'Wed, 01 Jan 2020 12:00:00 GMT',
|
|
216
|
+
'Pragma': 'no-cache' });
|
|
217
|
+
}
|
|
218
|
+
res.writeHead(code ? code : 200, headers);
|
|
212
219
|
if (this.prettyPrintJsonResponses) {
|
|
213
220
|
res.write(JSON.stringify(data, null, 2));
|
|
214
221
|
res.write("\n");
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tr-apisrv",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A simple asynchronous API server class",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "node ./test/test.js"
|
|
8
8
|
},
|
|
9
9
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
10
|
+
"node": ">=10.0.0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
},
|