tr-apisrv 0.1.1 → 0.1.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/index.js +7 -4
- package/package.json +2 -2
- package/test/test.js +1 -0
package/index.js
CHANGED
|
@@ -66,7 +66,9 @@ var ApiSrv = function(opts) {
|
|
|
66
66
|
} else {
|
|
67
67
|
this.bodyReadTimeoutMs = 2 * 1000;
|
|
68
68
|
}
|
|
69
|
-
srvOpts.
|
|
69
|
+
srvOpts.headersTimeout = this.bodyReadTimeoutMs;
|
|
70
|
+
srvOpts.requestTimeout = this.bodyReadTimeoutMs + 1;
|
|
71
|
+
|
|
70
72
|
var upgradeCb = function(req, s, head) {
|
|
71
73
|
var m, r = {};
|
|
72
74
|
r.method = req.method;
|
|
@@ -142,8 +144,9 @@ var ApiSrv = function(opts) {
|
|
|
142
144
|
}
|
|
143
145
|
switch (req.method) {
|
|
144
146
|
case 'POST':
|
|
147
|
+
case 'PUT':
|
|
145
148
|
if (req.url.match(/\?/)) {
|
|
146
|
-
error(res, 400, 'URL for POST must not contain query parameters.');
|
|
149
|
+
error(res, 400, 'URL for POST or PUT must not contain query parameters.');
|
|
147
150
|
return;
|
|
148
151
|
}
|
|
149
152
|
r.url = req.url;
|
|
@@ -175,7 +178,7 @@ var ApiSrv = function(opts) {
|
|
|
175
178
|
// RFC6749 anyways says that application/x-www-form-urlencoded
|
|
176
179
|
// is the "correct" way to go.
|
|
177
180
|
default:
|
|
178
|
-
error(res, 400, 'POST body must be in JSON or www-form-urlencoded format.');
|
|
181
|
+
error(res, 400, 'POST or PUT body must be in JSON or www-form-urlencoded format.');
|
|
179
182
|
return;
|
|
180
183
|
}
|
|
181
184
|
break;
|
|
@@ -199,7 +202,7 @@ var ApiSrv = function(opts) {
|
|
|
199
202
|
r.method = req.method;
|
|
200
203
|
break;
|
|
201
204
|
default:
|
|
202
|
-
error(res, 405, 'Only GET, POST, and DELETE are allowed.');
|
|
205
|
+
error(res, 405, 'Only GET, POST, PUT, and DELETE are allowed.');
|
|
203
206
|
return;
|
|
204
207
|
}
|
|
205
208
|
r.headers = req.headers;
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tr-apisrv",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
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.00.0"
|
|
10
|
+
"node": ">= 10.00.0"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
},
|
package/test/test.js
CHANGED