@superhero/http-server 4.7.2 → 4.7.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.
@@ -1,13 +1,13 @@
1
1
  export default
2
2
  {
3
- isValid(request, session)
3
+ isValid(request, route)
4
4
  {
5
5
  const
6
6
  header = request.headers['accept'],
7
7
  lowerCased = header.toLowerCase(),
8
8
  accept = lowerCased.split(';')[0].split('*')[0].trim()
9
9
 
10
- return [session.route['condition.accept']].flat().some(supported =>
10
+ return [route['condition.accept']].flat().some(supported =>
11
11
  supported.startsWith(accept) || accept.startsWith(supported.split('*')[0]))
12
12
  }
13
13
  }
@@ -1,13 +1,13 @@
1
1
  export default
2
2
  {
3
- isValid(request, session)
3
+ isValid(request, route)
4
4
  {
5
5
  const
6
6
  header = request.headers['content-type'],
7
7
  lowerCased = header.toLowerCase(),
8
8
  contentType = lowerCased.split(';')[0].split('*')[0].trim()
9
9
 
10
- return [session.route['condition.content-type']].flat().some(supported =>
10
+ return [route['condition.content-type']].flat().some(supported =>
11
11
  supported.startsWith(contentType) || contentType.startsWith(supported.split('*')[0]))
12
12
  }
13
13
  }
@@ -0,0 +1,12 @@
1
+ export default
2
+ {
3
+ isValid(request, route)
4
+ {
5
+ const
6
+ methods = [route['condition.method']].flat(),
7
+ mapped = methods.map(method => method.toLowerCase()),
8
+ isValid = mapped.includes(request.method.toLowerCase())
9
+
10
+ return isValid
11
+ }
12
+ }
package/config.json CHANGED
@@ -6,10 +6,14 @@
6
6
  "locator":
7
7
  {
8
8
  "@superhero/http-server": true,
9
+
9
10
  "@superhero/http-server/dispatcher/*": "./dispatcher/*.js",
10
11
  "@superhero/http-server/dispatcher/*/*": "./dispatcher/*/*.js",
11
12
  "@superhero/http-server/dispatcher/*/*/*": "./dispatcher/*/*/*.js",
12
- "@superhero/http-server/dispatcher/*/*/*/*/*": "./dispatcher/*/*/*/*/*.js"
13
+ "@superhero/http-server/dispatcher/*/*/*/*/*": "./dispatcher/*/*/*/*/*.js",
14
+
15
+ "@superhero/http-server/condition/*/*": "./condition/*/*.js",
16
+ "@superhero/http-server/condition/*/*/*": "./condition/*/*/*.js"
13
17
  },
14
18
  "http-server":
15
19
  {
@@ -27,8 +27,8 @@ export default new class ContentTypeHeaderUpstreamDispatcher
27
27
  {
28
28
  const
29
29
  dispatcher = session.route[route],
30
- dispatchers = Array.isArray(dispatcher) ? dispatcher : [dispatcher],
31
- uniqueList = dispatchers.filter((item) => false === session.chain.dispatchers.includes(item))
30
+ dispatchers = [ dispatcher ].flat(),
31
+ uniqueList = dispatchers.filter(item => false === session.chain.dispatchers.includes(item))
32
32
 
33
33
  // insert the forward routed dispatcher(s) after the current dispatcher in the chain
34
34
  // for the dispatcher chain iterator to dispatch it/them next
package/index.test.js CHANGED
@@ -418,7 +418,7 @@ suite('@superhero/http-server', () =>
418
418
  {
419
419
  for(const algorithm in algorithms)
420
420
  {
421
- test(algorithm, async (sub) =>
421
+ test(algorithm, async sub =>
422
422
  {
423
423
  fs.mkdirSync('test', { recursive: true })
424
424
  execSync(algorithms[algorithm], { stdio: ['ignore', 'ignore', 'pipe'] })
@@ -433,7 +433,7 @@ suite('@superhero/http-server', () =>
433
433
  { dispatch: (_, session) => session.view.body.dispatched = true })
434
434
 
435
435
  await assert.doesNotReject(server.bootstrap(
436
- { server: { cert, key, minVersion: tlsVersion, maxVersion: tlsVersion },
436
+ { server: { cert, key, minVersion: tlsVersion, maxVersion: tlsVersion },
437
437
  router:
438
438
  { routes:
439
439
  { 'test':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superhero/http-server",
3
- "version": "4.7.2",
3
+ "version": "4.7.3",
4
4
  "description": "HTTP(S) server component supporting both HTTP 1.1 and HTTP 2.0",
5
5
  "keywords": [
6
6
  "http server",
@@ -27,16 +27,16 @@
27
27
  "test": "syntax-check; node --test --test-reporter=@superhero/audit/reporter --experimental-test-coverage"
28
28
  },
29
29
  "dependencies": {
30
- "@superhero/router": "4.7.2",
31
- "@superhero/deep": "4.7.2",
32
- "@superhero/log": "4.7.2",
33
- "@superhero/id-name-generator": "4.7.2"
30
+ "@superhero/router": "4.7.3",
31
+ "@superhero/deep": "4.7.3",
32
+ "@superhero/log": "4.7.3",
33
+ "@superhero/id-name-generator": "4.7.3"
34
34
  },
35
35
  "devDependencies": {
36
- "@superhero/audit": "4.7.2",
36
+ "@superhero/audit": "4.7.3",
37
37
  "@superhero/syntax-check": "0.0.2",
38
- "@superhero/locator": "4.7.2",
39
- "@superhero/http-request": "4.7.2"
38
+ "@superhero/locator": "4.7.3",
39
+ "@superhero/http-request": "4.7.3"
40
40
  },
41
41
  "author": {
42
42
  "name": "Erik Landvall",
@@ -1,7 +0,0 @@
1
- export default
2
- {
3
- isValid(request, session)
4
- {
5
- return [session.route['condition.method']].flat().includes(request.method)
6
- }
7
- }