@toa.io/extensions.exposition 0.24.0-alpha.17 → 0.24.0-alpha.19
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/components/context.toa.yaml +12 -0
- package/components/identity.bans/manifest.toa.yaml +1 -1
- package/components/identity.basic/manifest.toa.yaml +1 -1
- package/components/identity.basic/operations/authenticate.js +1 -2
- package/components/identity.basic/operations/authenticate.js.map +1 -1
- package/components/identity.basic/operations/transit.js.map +1 -1
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/source/authenticate.ts +0 -1
- package/components/identity.federation/events/principal.js +22 -0
- package/components/identity.federation/manifest.toa.yaml +88 -0
- package/components/identity.federation/operations/assertions-as-values.cjs +45 -0
- package/components/identity.federation/operations/assertions-as-values.cjs.map +1 -0
- package/components/identity.federation/operations/assertions-as-values.d.cts +4 -0
- package/components/identity.federation/operations/authenticate.d.ts +3 -0
- package/components/identity.federation/operations/authenticate.js +20 -0
- package/components/identity.federation/operations/authenticate.js.map +1 -0
- package/components/identity.federation/operations/create.d.ts +10 -0
- package/components/identity.federation/operations/create.js +15 -0
- package/components/identity.federation/operations/create.js.map +1 -0
- package/components/identity.federation/operations/jwt.cjs +112 -0
- package/components/identity.federation/operations/jwt.cjs.map +1 -0
- package/components/identity.federation/operations/jwt.d.cts +19 -0
- package/components/identity.federation/operations/schemas.d.ts +43 -0
- package/components/identity.federation/operations/schemas.js +9 -0
- package/components/identity.federation/operations/schemas.js.map +1 -0
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -0
- package/components/identity.federation/operations/types.d.ts +51 -0
- package/components/identity.federation/operations/types.js +3 -0
- package/components/identity.federation/operations/types.js.map +1 -0
- package/components/identity.federation/source/assertions-as-values.cts +20 -0
- package/components/identity.federation/source/authenticate.ts +28 -0
- package/components/identity.federation/source/create.ts +26 -0
- package/components/identity.federation/source/jwt.cts +143 -0
- package/components/identity.federation/source/schemas.ts +45 -0
- package/components/identity.federation/source/types.ts +56 -0
- package/components/identity.federation/tsconfig.json +9 -0
- package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/manifest.toa.yaml +1 -1
- package/components/identity.tokens/operations/authenticate.js.map +1 -1
- package/components/identity.tokens/operations/decrypt.js.map +1 -1
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
- package/cucumber.js +0 -1
- package/documentation/components.md +24 -1
- package/documentation/identity.md +7 -7
- package/documentation/protocol.md +20 -1
- package/documentation/query.md +1 -1
- package/documentation/vary.md +69 -0
- package/features/cors.feature +6 -26
- package/features/identity.feature +17 -1
- package/features/identity.federation.feature +125 -0
- package/features/response.feature +0 -0
- package/features/steps/Captures.ts +5 -0
- package/features/steps/Components.ts +5 -0
- package/features/steps/HTTP.ts +33 -5
- package/features/steps/IdP.ts +120 -0
- package/features/steps/Parameters.ts +8 -2
- package/features/steps/Workspace.ts +5 -7
- package/features/vary.feature +120 -0
- package/package.json +17 -18
- package/source/Directive.test.ts +8 -2
- package/source/Directive.ts +19 -16
- package/source/Factory.ts +8 -7
- package/source/Gateway.ts +22 -8
- package/source/HTTP/Server.fixtures.ts +0 -1
- package/source/HTTP/Server.test.ts +61 -138
- package/source/HTTP/Server.ts +45 -31
- package/source/HTTP/formats/text.ts +1 -1
- package/source/HTTP/formats/yaml.ts +1 -1
- package/source/HTTP/messages.ts +8 -2
- package/source/Interception.ts +24 -0
- package/source/RTD/Directives.ts +2 -2
- package/source/RTD/syntax/parse.ts +6 -6
- package/source/RTD/syntax/types.ts +1 -1
- package/source/directives/auth/{Family.ts → Authorization.ts} +29 -33
- package/source/directives/auth/Incept.ts +1 -1
- package/source/directives/auth/Rule.ts +2 -2
- package/source/directives/auth/index.ts +2 -2
- package/source/directives/auth/schemes.ts +2 -1
- package/source/directives/auth/types.ts +9 -6
- package/source/directives/cache/{Family.ts → Cache.ts} +4 -5
- package/source/directives/cache/index.ts +2 -2
- package/source/directives/cache/types.ts +1 -1
- package/source/directives/cors/CORS.ts +52 -0
- package/source/directives/cors/index.ts +3 -0
- package/source/directives/dev/{Family.ts → Development.ts} +3 -4
- package/source/directives/dev/Stub.ts +4 -4
- package/source/directives/dev/Throw.ts +4 -4
- package/source/directives/dev/index.ts +2 -2
- package/source/directives/dev/types.ts +1 -1
- package/source/directives/index.ts +10 -6
- package/source/directives/octets/Context.ts +1 -1
- package/source/directives/octets/Delete.ts +1 -2
- package/source/directives/octets/Fetch.ts +1 -1
- package/source/directives/octets/List.ts +1 -1
- package/source/directives/octets/{Family.ts → Octets.ts} +3 -4
- package/source/directives/octets/Permute.ts +1 -1
- package/source/directives/octets/Store.ts +3 -3
- package/source/directives/octets/index.ts +2 -2
- package/source/directives/octets/types.ts +3 -3
- package/source/directives/vary/Directive.ts +6 -0
- package/source/directives/vary/Embed.ts +62 -0
- package/source/directives/vary/Properties.ts +17 -0
- package/source/directives/vary/Vary.ts +48 -0
- package/source/directives/vary/embeddings/Embedding.ts +6 -0
- package/source/directives/vary/embeddings/Header.ts +30 -0
- package/source/directives/vary/embeddings/Language.ts +31 -0
- package/source/directives/vary/embeddings/index.ts +11 -0
- package/source/directives/vary/index.ts +3 -0
- package/source/io.ts +4 -0
- package/transpiled/Composition.js.map +1 -1
- package/transpiled/Directive.d.ts +6 -7
- package/transpiled/Directive.js +12 -10
- package/transpiled/Directive.js.map +1 -1
- package/transpiled/Factory.d.ts +0 -1
- package/transpiled/Factory.js +7 -6
- package/transpiled/Factory.js.map +1 -1
- package/transpiled/Gateway.d.ts +8 -5
- package/transpiled/Gateway.js +12 -2
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Server.d.ts +4 -2
- package/transpiled/HTTP/Server.fixtures.d.ts +0 -1
- package/transpiled/HTTP/Server.fixtures.js +1 -2
- package/transpiled/HTTP/Server.fixtures.js.map +1 -1
- package/transpiled/HTTP/Server.js +33 -22
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/HTTP/formats/text.d.ts +3 -1
- package/transpiled/HTTP/formats/text.js.map +1 -1
- package/transpiled/HTTP/formats/yaml.js +1 -1
- package/transpiled/HTTP/formats/yaml.js.map +1 -1
- package/transpiled/HTTP/messages.d.ts +4 -0
- package/transpiled/HTTP/messages.js +4 -2
- package/transpiled/HTTP/messages.js.map +1 -1
- package/transpiled/Interception.d.ts +9 -0
- package/transpiled/Interception.js +19 -0
- package/transpiled/Interception.js.map +1 -0
- package/transpiled/Query.js.map +1 -1
- package/transpiled/RTD/Directives.d.ts +2 -2
- package/transpiled/RTD/Node.js.map +1 -1
- package/transpiled/RTD/Route.js.map +1 -1
- package/transpiled/RTD/syntax/parse.js +1 -1
- package/transpiled/RTD/syntax/parse.js.map +1 -1
- package/transpiled/RTD/syntax/types.js +1 -1
- package/transpiled/RTD/syntax/types.js.map +1 -1
- package/transpiled/deployment.js.map +1 -1
- package/transpiled/directives/auth/{Family.d.ts → Authorization.d.ts} +4 -4
- package/transpiled/directives/auth/{Family.js → Authorization.js} +15 -8
- package/transpiled/directives/auth/Authorization.js.map +1 -0
- package/transpiled/directives/auth/Incept.js.map +1 -1
- package/transpiled/directives/auth/Role.js.map +1 -1
- package/transpiled/directives/auth/Rule.d.ts +2 -2
- package/transpiled/directives/auth/Rule.js.map +1 -1
- package/transpiled/directives/auth/index.d.ts +2 -2
- package/transpiled/directives/auth/index.js +4 -5
- package/transpiled/directives/auth/index.js.map +1 -1
- package/transpiled/directives/auth/schemes.js +2 -1
- package/transpiled/directives/auth/schemes.js.map +1 -1
- package/transpiled/directives/auth/types.d.ts +4 -4
- package/transpiled/directives/cache/{Family.d.ts → Cache.d.ts} +4 -5
- package/transpiled/directives/cache/{Family.js → Cache.js} +4 -2
- package/transpiled/directives/cache/{Family.js.map → Cache.js.map} +1 -1
- package/transpiled/directives/cache/index.d.ts +2 -2
- package/transpiled/directives/cache/index.js +4 -5
- package/transpiled/directives/cache/index.js.map +1 -1
- package/transpiled/directives/cache/types.d.ts +1 -1
- package/transpiled/directives/cors/CORS.d.ts +14 -0
- package/transpiled/directives/cors/CORS.js +42 -0
- package/transpiled/directives/cors/CORS.js.map +1 -0
- package/transpiled/directives/cors/index.d.ts +2 -0
- package/transpiled/directives/cors/index.js +6 -0
- package/transpiled/directives/cors/index.js.map +1 -0
- package/transpiled/directives/dev/{Family.d.ts → Development.d.ts} +3 -4
- package/transpiled/directives/dev/{Family.js → Development.js} +4 -2
- package/transpiled/directives/dev/Development.js.map +1 -0
- package/transpiled/directives/dev/Stub.d.ts +3 -3
- package/transpiled/directives/dev/Stub.js.map +1 -1
- package/transpiled/directives/dev/Throw.d.ts +3 -3
- package/transpiled/directives/dev/Throw.js.map +1 -1
- package/transpiled/directives/dev/index.d.ts +2 -2
- package/transpiled/directives/dev/index.js +4 -5
- package/transpiled/directives/dev/index.js.map +1 -1
- package/transpiled/directives/dev/types.d.ts +1 -1
- package/transpiled/directives/index.d.ts +3 -1
- package/transpiled/directives/index.js +9 -9
- package/transpiled/directives/index.js.map +1 -1
- package/transpiled/directives/octets/Context.d.ts +1 -1
- package/transpiled/directives/octets/Delete.d.ts +1 -1
- package/transpiled/directives/octets/Delete.js.map +1 -1
- package/transpiled/directives/octets/Fetch.d.ts +1 -1
- package/transpiled/directives/octets/List.d.ts +1 -1
- package/transpiled/directives/octets/{Family.d.ts → Octets.d.ts} +3 -4
- package/transpiled/directives/octets/{Family.js → Octets.js} +4 -2
- package/transpiled/directives/octets/Octets.js.map +1 -0
- package/transpiled/directives/octets/Permute.d.ts +1 -1
- package/transpiled/directives/octets/Store.d.ts +1 -1
- package/transpiled/directives/octets/Store.js.map +1 -1
- package/transpiled/directives/octets/index.d.ts +2 -2
- package/transpiled/directives/octets/index.js +4 -5
- package/transpiled/directives/octets/index.js.map +1 -1
- package/transpiled/directives/octets/types.d.ts +3 -3
- package/transpiled/directives/vary/Directive.d.ts +5 -0
- package/transpiled/directives/vary/Directive.js +3 -0
- package/transpiled/directives/vary/Directive.js.map +1 -0
- package/transpiled/directives/vary/Embed.d.ts +10 -0
- package/transpiled/directives/vary/Embed.js +49 -0
- package/transpiled/directives/vary/Embed.js.map +1 -0
- package/transpiled/directives/vary/Properties.d.ts +9 -0
- package/transpiled/directives/vary/Properties.js +16 -0
- package/transpiled/directives/vary/Properties.js.map +1 -0
- package/transpiled/directives/vary/Vary.d.ts +10 -0
- package/transpiled/directives/vary/Vary.js +36 -0
- package/transpiled/directives/vary/Vary.js.map +1 -0
- package/transpiled/directives/vary/embeddings/Embedding.d.ts +5 -0
- package/transpiled/directives/vary/embeddings/Embedding.js +3 -0
- package/transpiled/directives/vary/embeddings/Embedding.js.map +1 -0
- package/transpiled/directives/vary/embeddings/Header.d.ts +7 -0
- package/transpiled/directives/vary/embeddings/Header.js +26 -0
- package/transpiled/directives/vary/embeddings/Header.js.map +1 -0
- package/transpiled/directives/vary/embeddings/Language.d.ts +7 -0
- package/transpiled/directives/vary/embeddings/Language.js +28 -0
- package/transpiled/directives/vary/embeddings/Language.js.map +1 -0
- package/transpiled/directives/vary/embeddings/index.d.ts +5 -0
- package/transpiled/directives/vary/embeddings/index.js +10 -0
- package/transpiled/directives/vary/embeddings/index.js.map +1 -0
- package/transpiled/directives/vary/index.d.ts +2 -0
- package/transpiled/directives/vary/index.js +6 -0
- package/transpiled/directives/vary/index.js.map +1 -0
- package/transpiled/io.d.ts +3 -0
- package/transpiled/io.js +3 -0
- package/transpiled/io.js.map +1 -0
- package/transpiled/manifest.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
- package/transpiled/directives/auth/Family.js.map +0 -1
- package/transpiled/directives/dev/Family.js.map +0 -1
- package/transpiled/directives/octets/Family.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Properties {
|
|
2
|
+
languages?: string[]
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export class Property<K extends keyof Properties = keyof Properties> {
|
|
6
|
+
public readonly name: K
|
|
7
|
+
public readonly value: Properties[K]
|
|
8
|
+
|
|
9
|
+
public constructor (name: K, value: Properties[K]) {
|
|
10
|
+
this.name = name
|
|
11
|
+
this.value = value
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const properties: Properties = {
|
|
16
|
+
languages: []
|
|
17
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { match } from 'matchacho'
|
|
2
|
+
import { properties, Property } from './Properties'
|
|
3
|
+
import { Embed } from './Embed'
|
|
4
|
+
import type { Properties } from './Properties'
|
|
5
|
+
import type { Directive } from './Directive'
|
|
6
|
+
import type { Family } from '../../Directive'
|
|
7
|
+
import type { Input, Output } from '../../io'
|
|
8
|
+
|
|
9
|
+
export class Vary implements Family {
|
|
10
|
+
public readonly name = 'vary'
|
|
11
|
+
public readonly mandatory = false
|
|
12
|
+
|
|
13
|
+
public create (name: string, value: unknown): Property | Directive {
|
|
14
|
+
return match(name,
|
|
15
|
+
() => name in properties, (name: PN) => new Property(name, value as PV),
|
|
16
|
+
() => name in directives, (name: keyof typeof directives) => new directives[name](value),
|
|
17
|
+
() => {
|
|
18
|
+
throw new Error(`Unknown directive 'vary:${name}'`)
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public preflight (instances: Array<Directive | Property>, request: Input): Output {
|
|
23
|
+
/*
|
|
24
|
+
To stop consructing `properties` object on each request, Directive Families must be refactored
|
|
25
|
+
from singleton factories to per-Node instances on the Tree.
|
|
26
|
+
*/
|
|
27
|
+
const properties: Properties = {}
|
|
28
|
+
const directives: Directive[] = []
|
|
29
|
+
|
|
30
|
+
for (const instance of instances)
|
|
31
|
+
if (instance instanceof Property)
|
|
32
|
+
properties[instance.name] = instance.value
|
|
33
|
+
else
|
|
34
|
+
directives.push(instance)
|
|
35
|
+
|
|
36
|
+
for (const directive of directives)
|
|
37
|
+
directive.preflight(request, properties)
|
|
38
|
+
|
|
39
|
+
return null
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type PN = keyof Properties
|
|
44
|
+
type PV = Properties[PN]
|
|
45
|
+
|
|
46
|
+
const directives: Record<string, new (value: any) => Directive> = {
|
|
47
|
+
embed: Embed
|
|
48
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { cors } from '../../cors'
|
|
2
|
+
import type { Input } from '../../../io'
|
|
3
|
+
import type { Embedding } from './Embedding'
|
|
4
|
+
|
|
5
|
+
export class Header implements Embedding {
|
|
6
|
+
private readonly name: string
|
|
7
|
+
|
|
8
|
+
public constructor (name: string) {
|
|
9
|
+
this.name = name
|
|
10
|
+
|
|
11
|
+
cors.allowHeader(this.name)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public resolve (input: Input): string | undefined {
|
|
15
|
+
const value = input.headers[this.name]
|
|
16
|
+
|
|
17
|
+
if (value === undefined)
|
|
18
|
+
return value
|
|
19
|
+
|
|
20
|
+
input.pipelines.response.push((response) => {
|
|
21
|
+
response.headers ??= new Headers()
|
|
22
|
+
response.headers.append('vary', this.name)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
if (Array.isArray(value))
|
|
26
|
+
return value.join(', ')
|
|
27
|
+
else
|
|
28
|
+
return value
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
2
|
+
import Negotiator from 'negotiator'
|
|
3
|
+
import { cors } from '../../cors'
|
|
4
|
+
import type { Properties } from '../Properties'
|
|
5
|
+
import type { Embedding } from './Embedding'
|
|
6
|
+
import type { Input } from '../../../io'
|
|
7
|
+
|
|
8
|
+
export class Language implements Embedding {
|
|
9
|
+
public constructor () {
|
|
10
|
+
cors.allowHeader('accept-language')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public resolve (input: Input, properties: Properties): string | undefined {
|
|
14
|
+
assert.ok(properties.languages !== undefined,
|
|
15
|
+
'Supported languages are not defined. Use `vary:languages` directive.')
|
|
16
|
+
|
|
17
|
+
assert.ok(properties.languages.length > 0,
|
|
18
|
+
'List of supported languages is empty.')
|
|
19
|
+
|
|
20
|
+
const negotiator = new Negotiator(input)
|
|
21
|
+
const language = negotiator.language(properties.languages) ?? properties.languages[0]
|
|
22
|
+
|
|
23
|
+
input.pipelines.response.push((response) => {
|
|
24
|
+
response.headers ??= new Headers()
|
|
25
|
+
response.headers.set('content-language', language)
|
|
26
|
+
response.headers.append('vary', 'accept-language')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
return language
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Language } from './Language'
|
|
2
|
+
import { Header } from './Header'
|
|
3
|
+
|
|
4
|
+
import type { Embedding } from './Embedding'
|
|
5
|
+
|
|
6
|
+
export const embeddings: Record<string, new () => Embedding> = {
|
|
7
|
+
language: Language
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { Header }
|
|
11
|
+
export type { Embedding }
|
package/source/io.ts
ADDED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Composition.js","sourceRoot":"","sources":["../source/Composition.ts"],"names":[],"mappings":";;;AAAA,qCAAkD;AAClD,yCAAmC;AACnC,uCAAwC;AAGxC,MAAa,WAAY,SAAQ,gBAAS;IACvB,IAAI,CAAY;IAEjC,YAAoB,IAAgB;QAClC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEkB,KAAK,CAAC,IAAI;QAC3B,MAAM,KAAK,GAAG,IAAI,EAAE,CAAA;QACpB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QAEtD,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;QAE3B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;QAEzB,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAA;IACvC,CAAC;IAEkB,OAAO;QACxB,OAAO,CA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AAgC,CAAC,CAAA;IAChD,CAAC;CACF;AAtBD,kCAsBC;AAED,SAAS,IAAI;IACX,OAAO,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,mBAAO,EAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AAC5D,CAAC;AAED,SAAS,OAAO;IACd,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IAE1D,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAA;AACvD,CAAC;AAED,SAAgB,UAAU;IACxB,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,EAAE,CAAC;QAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAA;QACzC,KAAK,CAAC,IAAI,CAAC,IAAA,mBAAO,EAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;IACvC,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,CAAA;AAC1B,CAAC;AAVD,gCAUC;AAOD,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { IncomingMessage, OutgoingMessage } from './HTTP';
|
|
2
|
+
import type { Remotes } from './Remotes';
|
|
3
|
+
import type { Output } from './io';
|
|
3
4
|
import type * as RTD from './RTD';
|
|
4
5
|
export declare class Directives implements RTD.Directives<Directives> {
|
|
5
|
-
private readonly
|
|
6
|
-
constructor(
|
|
6
|
+
private readonly sets;
|
|
7
|
+
constructor(sets: DirectiveSet[]);
|
|
7
8
|
preflight(request: IncomingMessage, parameters: RTD.Parameter[]): Promise<Output>;
|
|
8
9
|
settle(request: IncomingMessage, response: OutgoingMessage): Promise<void>;
|
|
9
10
|
merge(directives: Directives): void;
|
|
@@ -20,13 +21,11 @@ export interface Family<TDirective = any, TExtension = any> {
|
|
|
20
21
|
readonly name: string;
|
|
21
22
|
readonly mandatory: boolean;
|
|
22
23
|
create: (name: string, value: any, remotes: Remotes) => TDirective;
|
|
23
|
-
preflight
|
|
24
|
+
preflight?: (directives: TDirective[], request: IncomingMessage & TExtension, parameters: RTD.Parameter[]) => Output | Promise<Output>;
|
|
24
25
|
settle?: (directives: TDirective[], request: IncomingMessage & TExtension, response: OutgoingMessage) => void | Promise<void>;
|
|
25
26
|
}
|
|
26
27
|
interface DirectiveSet {
|
|
27
28
|
family: Family;
|
|
28
29
|
directives: any[];
|
|
29
30
|
}
|
|
30
|
-
export type Input = IncomingMessage;
|
|
31
|
-
export type Output = OutgoingMessage | null;
|
|
32
31
|
export {};
|
package/transpiled/Directive.js
CHANGED
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.shortcuts = exports.DirectivesFactory = exports.Directives = void 0;
|
|
4
4
|
class Directives {
|
|
5
|
-
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
5
|
+
sets;
|
|
6
|
+
constructor(sets) {
|
|
7
|
+
this.sets = sets;
|
|
8
8
|
}
|
|
9
9
|
async preflight(request, parameters) {
|
|
10
|
-
for (const
|
|
11
|
-
|
|
10
|
+
for (const set of this.sets) {
|
|
11
|
+
if (set.family.preflight === undefined)
|
|
12
|
+
continue;
|
|
13
|
+
const output = await set.family.preflight(set.directives, request, parameters);
|
|
12
14
|
if (output !== null) {
|
|
13
15
|
await this.settle(request, output);
|
|
14
16
|
return output;
|
|
@@ -17,12 +19,12 @@ class Directives {
|
|
|
17
19
|
return null;
|
|
18
20
|
}
|
|
19
21
|
async settle(request, response) {
|
|
20
|
-
for (const
|
|
21
|
-
if (
|
|
22
|
-
await
|
|
22
|
+
for (const set of this.sets)
|
|
23
|
+
if (set.family.settle !== undefined)
|
|
24
|
+
await set.family.settle(set.directives, request, response);
|
|
23
25
|
}
|
|
24
26
|
merge(directives) {
|
|
25
|
-
this.
|
|
27
|
+
this.sets.push(...directives.sets);
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
exports.Directives = Directives;
|
|
@@ -45,7 +47,7 @@ class DirectivesFactory {
|
|
|
45
47
|
for (const declaration of declarations) {
|
|
46
48
|
const family = this.families[declaration.family];
|
|
47
49
|
if (family === undefined)
|
|
48
|
-
throw new Error(`Directive family '${declaration.family}' not found.`);
|
|
50
|
+
throw new Error(`Directive family '${declaration.family}' is not found.`);
|
|
49
51
|
const directive = family.create(declaration.name, declaration.value, this.remtoes);
|
|
50
52
|
groups[family.name] ??= [];
|
|
51
53
|
groups[family.name].push(directive);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Directive.js","sourceRoot":"","sources":["../source/Directive.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Directive.js","sourceRoot":"","sources":["../source/Directive.ts"],"names":[],"mappings":";;;AAKA,MAAa,UAAU;IACJ,IAAI,CAAgB;IAErC,YAAoB,IAAoB;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEM,KAAK,CAAC,SAAS,CAAE,OAAwB,EAAE,UAA2B;QAC3E,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC5B,IAAI,GAAG,CAAC,MAAM,CAAC,SAAS,KAAK,SAAS;gBACpC,SAAQ;YAEV,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;YAE9E,IAAI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AAU,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;CACF;AApDD,8CAoDC;AAEY,QAAA,SAAS,GAAyB,IAAI,GAAG,CAAC;IACrD,CAAC,WAAW,EAAE,gBAAgB,CAAC;IAC/B,CAAC,IAAI,EAAE,SAAS,CAAC;IACjB,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,MAAM,EAAE,WAAW,CAAC;IACrB,CAAC,QAAQ,EAAE,aAAa,CAAC;CAC1B,CAAC,CAAA"}
|
package/transpiled/Factory.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { syntax } from './RTD';
|
|
|
2
2
|
import type { Connector, Locator, extensions } from '@toa.io/core';
|
|
3
3
|
export declare class Factory implements extensions.Factory {
|
|
4
4
|
private readonly boot;
|
|
5
|
-
private readonly families;
|
|
6
5
|
constructor(boot: Bootloader);
|
|
7
6
|
tenant(locator: Locator, node: syntax.Node): Connector;
|
|
8
7
|
service(): Connector | null;
|
package/transpiled/Factory.js
CHANGED
|
@@ -30,16 +30,15 @@ const Remotes_1 = require("./Remotes");
|
|
|
30
30
|
const RTD_1 = require("./RTD");
|
|
31
31
|
const HTTP_1 = require("./HTTP");
|
|
32
32
|
const Endpoint_1 = require("./Endpoint");
|
|
33
|
-
const
|
|
33
|
+
const directives_1 = require("./directives");
|
|
34
34
|
const Directive_1 = require("./Directive");
|
|
35
35
|
const Composition_1 = require("./Composition");
|
|
36
36
|
const root = __importStar(require("./root"));
|
|
37
|
+
const Interception_1 = require("./Interception");
|
|
37
38
|
class Factory {
|
|
38
39
|
boot;
|
|
39
|
-
families;
|
|
40
40
|
constructor(boot) {
|
|
41
41
|
this.boot = boot;
|
|
42
|
-
this.families = directives.families;
|
|
43
42
|
}
|
|
44
43
|
tenant(locator, node) {
|
|
45
44
|
const broadcast = this.boot.bindings.broadcast(CHANNEL, locator.id);
|
|
@@ -52,13 +51,15 @@ class Factory {
|
|
|
52
51
|
const remotes = new Remotes_1.Remotes(this.boot);
|
|
53
52
|
const node = root.resolve();
|
|
54
53
|
const methods = new Endpoint_1.EndpointsFactory(remotes);
|
|
55
|
-
const directives = new Directive_1.DirectivesFactory(
|
|
54
|
+
const directives = new Directive_1.DirectivesFactory(directives_1.families, remotes);
|
|
55
|
+
const interception = new Interception_1.Interception(directives_1.interceptors);
|
|
56
56
|
const tree = new RTD_1.Tree(node, methods, directives);
|
|
57
57
|
const composition = new Composition_1.Composition(this.boot);
|
|
58
|
-
const gateway = new Gateway_1.Gateway(broadcast, server, tree);
|
|
58
|
+
const gateway = new Gateway_1.Gateway(broadcast, server, tree, interception);
|
|
59
59
|
gateway.depends(remotes);
|
|
60
60
|
gateway.depends(composition);
|
|
61
|
-
|
|
61
|
+
server.depends(gateway);
|
|
62
|
+
return server;
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
exports.Factory = Factory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Factory.js","sourceRoot":"","sources":["../source/Factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAiC;AACjC,uCAAmC;AACnC,uCAAmC;AACnC,+BAAoC;AACpC,iCAA+B;AAC/B,yCAA4D;AAC5D,
|
|
1
|
+
{"version":3,"file":"Factory.js","sourceRoot":"","sources":["../source/Factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAiC;AACjC,uCAAmC;AACnC,uCAAmC;AACnC,+BAAoC;AACpC,iCAA+B;AAC/B,yCAA4D;AAC5D,6CAAqD;AACrD,2CAAgE;AAChE,+CAA2C;AAC3C,6CAA8B;AAC9B,iDAA6C;AAG7C,MAAa,OAAO;IACD,IAAI,CAAY;IAEjC,YAAoB,IAAgB;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEM,MAAM,CAAE,OAAgB,EAAE,IAAiB;QAChD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,C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OAAO,GAAG,YAAY,CAAA"}
|
package/transpiled/Gateway.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { type bindings, Connector } from '@toa.io/core';
|
|
2
2
|
import * as http from './HTTP';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
3
|
+
import type { Interceptor } from './Interception';
|
|
4
|
+
import type { Tree } from './RTD';
|
|
5
|
+
import type { Label } from './discovery';
|
|
6
|
+
import type { Endpoint } from './Endpoint';
|
|
7
|
+
import type { Directives } from './Directive';
|
|
7
8
|
export declare class Gateway extends Connector {
|
|
8
9
|
private readonly broadcast;
|
|
9
10
|
private readonly tree;
|
|
10
|
-
|
|
11
|
+
private readonly interceptor;
|
|
12
|
+
private readonly server;
|
|
13
|
+
constructor(broadcast: Broadcast, server: http.Server, tree: Tree<Endpoint, Directives>, interception: Interceptor);
|
|
11
14
|
protected open(): Promise<void>;
|
|
12
15
|
protected dispose(): void;
|
|
13
16
|
private process;
|
package/transpiled/Gateway.js
CHANGED
|
@@ -30,12 +30,17 @@ const exceptions_1 = require("./exceptions");
|
|
|
30
30
|
class Gateway extends core_1.Connector {
|
|
31
31
|
broadcast;
|
|
32
32
|
tree;
|
|
33
|
-
|
|
33
|
+
interceptor;
|
|
34
|
+
server;
|
|
35
|
+
// eslint-disable-next-line max-params, max-len
|
|
36
|
+
constructor(broadcast, server, tree, interception) {
|
|
34
37
|
super();
|
|
35
38
|
this.broadcast = broadcast;
|
|
36
39
|
this.tree = tree;
|
|
40
|
+
this.interceptor = interception;
|
|
41
|
+
this.server = server;
|
|
37
42
|
this.depends(broadcast);
|
|
38
|
-
this.depends(server)
|
|
43
|
+
// this.depends(server)
|
|
39
44
|
server.attach(this.process.bind(this));
|
|
40
45
|
}
|
|
41
46
|
async open() {
|
|
@@ -46,6 +51,9 @@ class Gateway extends core_1.Connector {
|
|
|
46
51
|
console.info('Gateway is closed.');
|
|
47
52
|
}
|
|
48
53
|
async process(request) {
|
|
54
|
+
const interception = await this.interceptor.intercept(request);
|
|
55
|
+
if (interception !== null)
|
|
56
|
+
return interception;
|
|
49
57
|
const match = this.tree.match(request.path);
|
|
50
58
|
if (match === null)
|
|
51
59
|
throw new http.NotFound();
|
|
@@ -66,6 +74,8 @@ class Gateway extends core_1.Connector {
|
|
|
66
74
|
if (method.endpoint === null)
|
|
67
75
|
throw new http.MethodNotAllowed();
|
|
68
76
|
const body = await request.parse();
|
|
77
|
+
if ('embed' in request && typeof body === 'object' && body !== null)
|
|
78
|
+
Object.assign(body, request.embed);
|
|
69
79
|
const reply = await method.endpoint
|
|
70
80
|
.call(body, request.query, parameters)
|
|
71
81
|
.catch(exceptions_1.rethrow);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Gateway.js","sourceRoot":"","sources":["../source/Gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuD;
|
|
1
|
+
{"version":3,"file":"Gateway.js","sourceRoot":"","sources":["../source/Gateway.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuD;AACvD,6CAA8B;AAC9B,6CAAsC;AAStC,MAAa,OAAQ,SAAQ,gBAAS;IACnB,SAAS,CAAW;IACpB,IAAI,CAA4B;IAChC,WAAW,CAAa;IACxB,MAAM,CAAW;IAElC,+CAA+C;IAC/C,YAAoB,SAAoB,EAAE,MAAmB,EAAE,IAAgC,EAAE,YAAyB;QACxH,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,WAAW,GAAG,YAAY,CAAA;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACvB,uBAAuB;QAEvB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,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,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;YAEpC,OAAO,CAAC,IAAI,CAAC,qBAAqB;gBAChC,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,oBAAoB,CAAC,CAAA;QACjE,CAAC;QAAC,OAAO,SAAS,EAAE,CAAC;YACnB,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAC1B,CAAC;IACH,CAAC;CACF;AAlGD,0BAkGC"}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Connector } from '@toa.io/core';
|
|
2
2
|
import { type IncomingMessage, type OutgoingMessage } from './messages';
|
|
3
3
|
export declare class Server extends Connector {
|
|
4
|
-
private readonly debug;
|
|
5
4
|
private readonly app;
|
|
5
|
+
private readonly debug;
|
|
6
|
+
private readonly requestedPort;
|
|
6
7
|
private server?;
|
|
7
8
|
private constructor();
|
|
9
|
+
get port(): number;
|
|
8
10
|
static create(options?: Partial<Properties>): Server;
|
|
9
11
|
attach(process: Processing): void;
|
|
10
12
|
protected open(): Promise<void>;
|
|
11
13
|
protected close(): Promise<void>;
|
|
12
|
-
protected dispose(): void;
|
|
13
14
|
private extend;
|
|
14
15
|
private success;
|
|
15
16
|
private fail;
|
|
@@ -17,6 +18,7 @@ export declare class Server extends Connector {
|
|
|
17
18
|
interface Properties {
|
|
18
19
|
methods: Set<string>;
|
|
19
20
|
debug: boolean;
|
|
21
|
+
port: number;
|
|
20
22
|
}
|
|
21
23
|
export type Processing = (input: IncomingMessage) => Promise<OutgoingMessage>;
|
|
22
24
|
export {};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cors = exports.express = exports.next = exports.res = exports.createRequest = void 0;
|
|
4
|
-
const buffer_1 = require("buffer");
|
|
5
4
|
const stream_1 = require("stream");
|
|
6
5
|
const server = {
|
|
7
6
|
close: jest.fn()
|
|
@@ -13,7 +12,7 @@ const app = {
|
|
|
13
12
|
listen: jest.fn(() => server)
|
|
14
13
|
};
|
|
15
14
|
function createRequest(req = {}, content = '') {
|
|
16
|
-
const buffer =
|
|
15
|
+
const buffer = Buffer.isBuffer(content) ? content : Buffer.from(content);
|
|
17
16
|
const stream = stream_1.Readable.from(buffer);
|
|
18
17
|
Object.assign(stream, { headers: {} }, req);
|
|
19
18
|
return stream;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.fixtures.js","sourceRoot":"","sources":["../../source/HTTP/Server.fixtures.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"Server.fixtures.js","sourceRoot":"","sources":["../../source/HTTP/Server.fixtures.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAMjC,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,IAAI,CAAC,EAAE,EAAE;CACoB,CAAA;AAEtC,MAAM,GAAG,GAAG;IACV,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE;IACjB,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;IAClB,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;IACd,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;CACG,CAAA;AAElC,SAAgB,aAAa,CAAE,MAAwB,EAAE,EAAE,UAA2B,EAAE;IAEtF,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACxE,MAAM,MAAM,GAAG,iBAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAEpC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAA;IAE3C,OAAO,MAAuD,CAAA;AAChE,CAAC;AARD,sCAQC;AAEY,QAAA,GAAG,GAAG;IACjB,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,WAAG,CAAC;IAC1B,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,WAAG,CAAC;IAC9B,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,WAAG,CAAC;IACvB,IAAI,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,WAAG,CAAC;IACxB,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,WAAG,CAAC;CACkB,CAAA;AAE9B,QAAA,IAAI,GAAG,IAAI,CAAC,EAAE,EAA6B,CAAA;AAE3C,QAAA,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAA;AAE5B,QAAA,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAc,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA"}
|
|
@@ -7,7 +7,6 @@ exports.Server = void 0;
|
|
|
7
7
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
8
|
const node_os_1 = __importDefault(require("node:os"));
|
|
9
9
|
const express_1 = __importDefault(require("express"));
|
|
10
|
-
const cors_1 = __importDefault(require("cors"));
|
|
11
10
|
const core_1 = require("@toa.io/core");
|
|
12
11
|
const generic_1 = require("@toa.io/generic");
|
|
13
12
|
const negotiator_1 = __importDefault(require("negotiator"));
|
|
@@ -15,13 +14,23 @@ const messages_1 = require("./messages");
|
|
|
15
14
|
const exceptions_1 = require("./exceptions");
|
|
16
15
|
const formats_1 = require("./formats");
|
|
17
16
|
class Server extends core_1.Connector {
|
|
18
|
-
debug;
|
|
19
17
|
app;
|
|
18
|
+
debug;
|
|
19
|
+
requestedPort;
|
|
20
20
|
server;
|
|
21
|
-
constructor(app, debug) {
|
|
21
|
+
constructor(app, debug, requestedPort) {
|
|
22
22
|
super();
|
|
23
23
|
this.app = app;
|
|
24
24
|
this.debug = debug;
|
|
25
|
+
this.requestedPort = requestedPort;
|
|
26
|
+
}
|
|
27
|
+
get port() {
|
|
28
|
+
if (this.server === undefined)
|
|
29
|
+
return this.requestedPort;
|
|
30
|
+
const address = this.server.address();
|
|
31
|
+
if (address === null || typeof address === 'string')
|
|
32
|
+
throw new Error('Server is not listening on a port.');
|
|
33
|
+
return address.port;
|
|
25
34
|
}
|
|
26
35
|
static create(options) {
|
|
27
36
|
const properties = options === undefined
|
|
@@ -29,21 +38,21 @@ class Server extends core_1.Connector {
|
|
|
29
38
|
: { ...DEFAULTS, ...options };
|
|
30
39
|
const app = (0, express_1.default)();
|
|
31
40
|
app.disable('x-powered-by');
|
|
32
|
-
app.use((
|
|
41
|
+
// app.use(cors(CORS))
|
|
33
42
|
app.use(supportedMethods(properties.methods));
|
|
34
|
-
return new Server(app, properties.debug);
|
|
43
|
+
return new Server(app, properties.debug, properties.port);
|
|
35
44
|
}
|
|
36
45
|
attach(process) {
|
|
37
46
|
this.app.use((request, response) => {
|
|
38
|
-
this.extend(request)
|
|
39
|
-
|
|
40
|
-
.then(this.success(
|
|
41
|
-
.catch(this.fail(
|
|
47
|
+
const message = this.extend(request);
|
|
48
|
+
process(message)
|
|
49
|
+
.then(this.success(message, response))
|
|
50
|
+
.catch(this.fail(message, response));
|
|
42
51
|
});
|
|
43
52
|
}
|
|
44
53
|
async open() {
|
|
45
54
|
const listening = (0, generic_1.promex)();
|
|
46
|
-
this.server = this.app.listen(
|
|
55
|
+
this.server = this.app.listen(this.requestedPort, listening.callback);
|
|
47
56
|
await listening;
|
|
48
57
|
console.info('HTTP Server is listening.');
|
|
49
58
|
}
|
|
@@ -51,18 +60,25 @@ class Server extends core_1.Connector {
|
|
|
51
60
|
const stopped = (0, generic_1.promex)();
|
|
52
61
|
this.server?.close(stopped.callback);
|
|
53
62
|
await stopped;
|
|
54
|
-
|
|
55
|
-
dispose() {
|
|
63
|
+
this.server = undefined;
|
|
56
64
|
console.info('HTTP Server has been stopped.');
|
|
57
65
|
}
|
|
58
|
-
|
|
66
|
+
extend(request) {
|
|
59
67
|
const message = request;
|
|
60
68
|
message.encoder = negotiate(request);
|
|
61
|
-
message.
|
|
69
|
+
message.pipelines = { body: [], response: [] };
|
|
70
|
+
message.parse = async () => {
|
|
71
|
+
const value = await (0, messages_1.read)(request);
|
|
72
|
+
if (message.pipelines.body.length === 0)
|
|
73
|
+
return value;
|
|
74
|
+
return message.pipelines.body.reduce((value, transform) => transform(value), value);
|
|
75
|
+
};
|
|
62
76
|
return message;
|
|
63
77
|
}
|
|
64
78
|
success(request, response) {
|
|
65
79
|
return (message) => {
|
|
80
|
+
for (const transform of request.pipelines.response)
|
|
81
|
+
transform(message);
|
|
66
82
|
let status = message.status;
|
|
67
83
|
if (status === undefined)
|
|
68
84
|
if (message.body === null)
|
|
@@ -125,13 +141,8 @@ async function adam(request) {
|
|
|
125
141
|
return await completed;
|
|
126
142
|
}
|
|
127
143
|
const DEFAULTS = {
|
|
128
|
-
methods: new Set(['GET', '
|
|
129
|
-
debug: false
|
|
130
|
-
|
|
131
|
-
const CORS = {
|
|
132
|
-
credentials: true,
|
|
133
|
-
maxAge: 86400,
|
|
134
|
-
allowedHeaders: ['accept', 'authorization', 'content-type'],
|
|
135
|
-
origin: (origin, callback) => callback(null, origin)
|
|
144
|
+
methods: new Set(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']),
|
|
145
|
+
debug: false,
|
|
146
|
+
port: 8000
|
|
136
147
|
};
|
|
137
148
|
//# sourceMappingURL=Server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Server.js","sourceRoot":"","sources":["../../source/HTTP/Server.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwB;AACxB,sDAAwB;AACxB,sDAA6B;AAC7B,
|
|
1
|
+
{"version":3,"file":"Server.js","sourceRoot":"","sources":["../../source/HTTP/Server.ts"],"names":[],"mappings":";;;;;;A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,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAO,CAAC,SAAS,CAAC,CAAA;AAC5D,CAAC;AAED,8CAA8C;AAC9C,KAAK,UAAU,IAAI,CAAE,OAAgB;IACnC,MAAM,SAAS,GAAG,IAAA,gBAAM,GAAE,CAAA;IAC1B,MAAM,OAAO,GAAG,iBAAE,CAAC,iBAAiB,CAAC,iBAAE,CAAC,OAAO,CAAC,CAAA;IAEhD,OAAO;SACJ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,QAAQ,CAAC;SAC7B,IAAI,CAAC,OAAO,CAAC,CAAA;IAEhB,OAAO,MAAM,SAAS,CAAA;AACxB,CAAC;AAED,MAAM,QAAQ,GAAe;IAC3B,OAAO,EAAE,IAAI,GAAG,CAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC9E,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,IAAI;CACX,CAAA"}
|
|
@@ -3,4 +3,6 @@ import { Buffer } from 'node:buffer';
|
|
|
3
3
|
export declare const type = "text/plain";
|
|
4
4
|
export declare const multipart = "multipart/text";
|
|
5
5
|
export declare function decode(buffer: Buffer): any;
|
|
6
|
-
export declare function encode(value:
|
|
6
|
+
export declare function encode(value: {
|
|
7
|
+
toString: () => string;
|
|
8
|
+
}): Buffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../source/HTTP/formats/text.ts"],"names":[],"mappings":";;;AAAA,6CAAoC;AAEvB,QAAA,IAAI,GAAG,YAAY,CAAA;AACnB,QAAA,SAAS,GAAG,gBAAgB,CAAA;AAEzC,SAAgB,MAAM,CAAE,MAAc;IACpC,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAA;AAC1B,CAAC;AAFD,wBAEC;AAED,SAAgB,MAAM,CAAE,
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../../../source/HTTP/formats/text.ts"],"names":[],"mappings":";;;AAAA,6CAAoC;AAEvB,QAAA,IAAI,GAAG,YAAY,CAAA;AACnB,QAAA,SAAS,GAAG,gBAAgB,CAAA;AAEzC,SAAgB,MAAM,CAAE,MAAc;IACpC,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAA;AAC1B,CAAC;AAFD,wBAEC;AAED,SAAgB,MAAM,CAAE,KAAiC;IACvD,OAAO,oBAAM,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAA;AACtC,CAAC;AAFD,wBAEC"}
|
|
@@ -34,7 +34,7 @@ function decode(buffer) {
|
|
|
34
34
|
}
|
|
35
35
|
exports.decode = decode;
|
|
36
36
|
function encode(value) {
|
|
37
|
-
const text = yaml.dump(value);
|
|
37
|
+
const text = yaml.dump(value, { lineWidth: -1, noRefs: true });
|
|
38
38
|
return node_buffer_1.Buffer.from(text);
|
|
39
39
|
}
|
|
40
40
|
exports.encode = encode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../../source/HTTP/formats/yaml.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAoC;AACpC,8CAA+B;AAElB,QAAA,IAAI,GAAG,kBAAkB,CAAA;AACzB,QAAA,SAAS,GAAG,gBAAgB,CAAA;AAEzC,SAAgB,MAAM,CAAE,MAAc;IACpC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IAE9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC;AAJD,wBAIC;AAED,SAAgB,MAAM,CAAE,KAAU;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../../source/HTTP/formats/yaml.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAoC;AACpC,8CAA+B;AAElB,QAAA,IAAI,GAAG,kBAAkB,CAAA;AACzB,QAAA,SAAS,GAAG,gBAAgB,CAAA;AAEzC,SAAgB,MAAM,CAAE,MAAc;IACpC,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAA;IAE9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACxB,CAAC;AAJD,wBAIC;AAED,SAAgB,MAAM,CAAE,KAAU;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;IAE9D,OAAO,oBAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC;AAJD,wBAIC"}
|