@superhero/http-server 4.4.6 → 4.7.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/conditions/upstream/header/accept.js +13 -0
- package/conditions/upstream/header/content-type.js +13 -0
- package/conditions/upstream/method.js +7 -0
- package/dispatcher/status.js +1 -4
- package/dispatcher/upstream/header/accept.js +0 -3
- package/dispatcher/upstream/header/content-type/application/json.js +0 -2
- package/dispatcher/upstream/header/content-type.js +0 -3
- package/dispatcher/upstream/method.js +0 -3
- package/index.js +1 -4
- package/package.json +14 -11
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default
|
|
2
|
+
{
|
|
3
|
+
isValid(request, session)
|
|
4
|
+
{
|
|
5
|
+
const
|
|
6
|
+
header = request.headers['accept'],
|
|
7
|
+
lowerCased = header.toLowerCase(),
|
|
8
|
+
accept = lowerCased.split(';')[0].split('*')[0].trim()
|
|
9
|
+
|
|
10
|
+
return [session.route['criteria.accept']].flat().some(supported =>
|
|
11
|
+
supported.startsWith(accept) || accept.startsWith(supported.split('*')[0]))
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default
|
|
2
|
+
{
|
|
3
|
+
isValid(request, session)
|
|
4
|
+
{
|
|
5
|
+
const
|
|
6
|
+
header = request.headers['content-type'],
|
|
7
|
+
lowerCased = header.toLowerCase(),
|
|
8
|
+
contentType = lowerCased.split(';')[0].split('*')[0].trim()
|
|
9
|
+
|
|
10
|
+
return [session.route['criteria.content-type']].flat().some(supported =>
|
|
11
|
+
supported.startsWith(contentType) || contentType.startsWith(supported.split('*')[0]))
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dispatcher/status.js
CHANGED
|
@@ -6,9 +6,6 @@ export function locate(locator)
|
|
|
6
6
|
return new StatusDispatcher(server)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
* @memberof @superhero/http-server:dispatcher
|
|
11
|
-
*/
|
|
12
9
|
export default class StatusDispatcher
|
|
13
10
|
{
|
|
14
11
|
started = new Date()
|
|
@@ -24,7 +21,7 @@ export default class StatusDispatcher
|
|
|
24
21
|
session.view.body.name = this.server.name
|
|
25
22
|
session.view.body.started = this.started_json
|
|
26
23
|
|
|
27
|
-
// Statistics
|
|
24
|
+
// Statistics
|
|
28
25
|
if(request.url.searchParams.get('stats'))
|
|
29
26
|
{
|
|
30
27
|
session.view.body.dispatched = String(this.server.dispatched)
|
package/index.js
CHANGED
|
@@ -15,9 +15,6 @@ export function locate(locator)
|
|
|
15
15
|
return new HttpServer(router)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* @memberof @superhero/http-server
|
|
20
|
-
*/
|
|
21
18
|
export default class HttpServer
|
|
22
19
|
{
|
|
23
20
|
// Name the server to easier be able to identify what logs
|
|
@@ -257,7 +254,7 @@ export default class HttpServer
|
|
|
257
254
|
// non enumerable and non-configurable session properties
|
|
258
255
|
downstream : { value:downstream },
|
|
259
256
|
upstream : { value:upstream },
|
|
260
|
-
abortion : { value:abortion }
|
|
257
|
+
abortion : { value:abortion },
|
|
261
258
|
})
|
|
262
259
|
|
|
263
260
|
Object.defineProperty(session, 'view', { enumerable: true, value: new View(session) })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superhero/http-server",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"description": "HTTP(S) server component supporting both HTTP 1.1 and HTTP 2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"http server",
|
|
@@ -22,18 +22,21 @@
|
|
|
22
22
|
"./*/*/*/*/*": "./*/*/*/*/*.js",
|
|
23
23
|
"./*/*/*/*/*/*": "./*/*/*/*/*/*.js"
|
|
24
24
|
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"syntax-check": "syntax-check",
|
|
27
|
+
"test": "syntax-check; node --test --test-reporter=@superhero/audit/reporter --experimental-test-coverage"
|
|
28
|
+
},
|
|
25
29
|
"dependencies": {
|
|
26
|
-
"@superhero/router": "
|
|
27
|
-
"@superhero/deep": "
|
|
28
|
-
"@superhero/log": "
|
|
29
|
-
"@superhero/id-name-generator": "
|
|
30
|
+
"@superhero/router": "4.7.0",
|
|
31
|
+
"@superhero/deep": "4.7.0",
|
|
32
|
+
"@superhero/log": "4.7.0",
|
|
33
|
+
"@superhero/id-name-generator": "4.7.0"
|
|
30
34
|
},
|
|
31
35
|
"devDependencies": {
|
|
32
|
-
"@superhero/
|
|
33
|
-
"@superhero/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"test": "node --trace-warnings --test --experimental-test-coverage"
|
|
36
|
+
"@superhero/audit": "4.7.0",
|
|
37
|
+
"@superhero/syntax-check": "0.0.2",
|
|
38
|
+
"@superhero/locator": "4.7.0",
|
|
39
|
+
"@superhero/http-request": "4.7.0"
|
|
37
40
|
},
|
|
38
41
|
"author": {
|
|
39
42
|
"name": "Erik Landvall",
|
|
@@ -41,6 +44,6 @@
|
|
|
41
44
|
},
|
|
42
45
|
"repository": {
|
|
43
46
|
"type": "git",
|
|
44
|
-
"url": "
|
|
47
|
+
"url": "https://github.com/superhero/http-server.git"
|
|
45
48
|
}
|
|
46
49
|
}
|