@venok/http 1.1.0 → 2.0.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/dist/constants.js +33 -0
- package/dist/decorators/controller.decorator.js +45 -0
- package/dist/decorators/header.decorator.js +28 -0
- package/dist/decorators/http-code.decorator.js +22 -0
- package/dist/decorators/http-params.decorator.js +63 -0
- package/dist/decorators/method.decorator.js +57 -0
- package/dist/decorators/redirect.decorator.js +28 -0
- package/dist/decorators/version.decorator.js +31 -0
- package/dist/enums/method.enum.js +32 -0
- package/dist/enums/paramtypes.enum.js +33 -0
- package/dist/enums/status.enum.js +71 -0
- package/dist/enums/version-type.enum.js +27 -0
- package/dist/exceptions/bad-gateway.exception.js +29 -0
- package/dist/exceptions/bad-request.exception.js +29 -0
- package/dist/exceptions/conflict.exception.js +29 -0
- package/dist/exceptions/expectation-failed.exception.js +29 -0
- package/dist/exceptions/failed-dependency.exception.js +29 -0
- package/dist/exceptions/forbidden.exception.js +29 -0
- package/dist/exceptions/gateway-timeout.exception.js +29 -0
- package/dist/exceptions/gone.exception.js +29 -0
- package/dist/exceptions/http-version-not-supported.exception.js +29 -0
- package/dist/exceptions/http.exception.js +94 -0
- package/dist/exceptions/im-a-teapot.exception.js +29 -0
- package/dist/exceptions/internal-server-error.exception.js +29 -0
- package/dist/exceptions/length-required.exception.js +29 -0
- package/dist/exceptions/method-not-allowed.exception.js +29 -0
- package/dist/exceptions/misdirected.exception.js +29 -0
- package/dist/exceptions/not-acceptable.exception.js +29 -0
- package/dist/exceptions/not-found.exception.js +29 -0
- package/dist/exceptions/not-implemented.exception.js +29 -0
- package/dist/exceptions/payload-too-large.exception.js +29 -0
- package/dist/exceptions/payment-required.exception.js +29 -0
- package/dist/exceptions/precondition-failed.exception.js +29 -0
- package/dist/exceptions/precondition-required.exception.js +29 -0
- package/dist/exceptions/proxy-authentication-required.exception.js +29 -0
- package/dist/exceptions/request-timeout.exception.js +29 -0
- package/dist/exceptions/requested-range-not-satisfiable.exception.js +29 -0
- package/dist/exceptions/service-unavailable.exception.js +29 -0
- package/dist/exceptions/too-many-requests.exception.js +29 -0
- package/dist/exceptions/unauthorized.exception.js +29 -0
- package/dist/exceptions/unprocessable-entity.exception.js +29 -0
- package/dist/exceptions/unsupported-media-type.exception.js +29 -0
- package/dist/exceptions/uri-too-long.exception.js +29 -0
- package/dist/filters/context.js +28 -0
- package/dist/filters/filter.js +56 -0
- package/dist/helpers/discovery.helper.js +69 -0
- package/dist/helpers/messages.helper.js +41 -0
- package/dist/helpers/middleware.helper.js +69 -0
- package/dist/helpers/path.helper.js +53 -0
- package/dist/helpers/route.helper.js +54 -0
- package/dist/http/adapter.js +294 -0
- package/dist/http/config.js +67 -0
- package/dist/http/configurable-module.js +26 -0
- package/dist/http/context.js +117 -0
- package/dist/http/explorer.js +133 -0
- package/dist/http/module.js +35 -0
- package/dist/http/starter-module.js +85 -0
- package/dist/index.d.ts +2117 -0
- package/dist/index.js +82 -0
- package/dist/interfaces/adapter.interface.js +0 -0
- package/dist/interfaces/exception.interface.js +0 -0
- package/dist/interfaces/index.js +7 -0
- package/dist/interfaces/middleware/config-proxy.interface.js +0 -0
- package/dist/interfaces/middleware/consumer.interface.js +0 -0
- package/dist/interfaces/middleware/index.js +3 -0
- package/dist/interfaces/options.interface.js +0 -0
- package/dist/interfaces/prefix.interface.js +0 -0
- package/dist/interfaces/router/definition.interface.js +0 -0
- package/dist/interfaces/router/exclude-route.interface.js +0 -0
- package/dist/interfaces/router/index.js +7 -0
- package/dist/interfaces/router/info.interface.js +0 -0
- package/dist/interfaces/router/path-metadata.interface.js +0 -0
- package/dist/interfaces/router/tree.interface.js +0 -0
- package/dist/interfaces/router/version.interface.js +21 -0
- package/dist/middleware/builder.js +96 -0
- package/dist/middleware/module.js +22 -0
- package/dist/middleware/routes-mapper.js +107 -0
- package/dist/middleware/service.js +48 -0
- package/dist/middleware/tree.js +91 -0
- package/dist/router/finder.js +64 -0
- package/dist/router/module.js +89 -0
- package/dist/router/path-factory.js +110 -0
- package/dist/symbols.js +33 -0
- package/package.json +41 -46
- package/adapter/adapter.d.ts +0 -57
- package/adapter/adapter.js +0 -58
- package/adapter/host.d.ts +0 -27
- package/adapter/host.js +0 -33
- package/application/application.d.ts +0 -18
- package/application/application.js +0 -51
- package/application/config.d.ts +0 -16
- package/application/config.js +0 -47
- package/application/http.module-defenition.d.ts +0 -8
- package/application/http.module-defenition.js +0 -6
- package/application/http.module.d.ts +0 -3
- package/application/http.module.js +0 -21
- package/application/http.service.d.ts +0 -11
- package/application/http.service.js +0 -43
- package/application/starter.d.ts +0 -41
- package/application/starter.js +0 -140
- package/constants.d.ts +0 -12
- package/constants.js +0 -15
- package/context/context.d.ts +0 -56
- package/context/context.js +0 -102
- package/context/response.controller.d.ts +0 -30
- package/context/response.controller.js +0 -86
- package/decorators/controller.decorator.d.ts +0 -82
- package/decorators/controller.decorator.js +0 -53
- package/decorators/header.decorator.d.ts +0 -12
- package/decorators/header.decorator.js +0 -23
- package/decorators/http-code.decorator.d.ts +0 -9
- package/decorators/http-code.decorator.js +0 -19
- package/decorators/index.d.ts +0 -9
- package/decorators/index.js +0 -25
- package/decorators/redirect.decorator.d.ts +0 -6
- package/decorators/redirect.decorator.js +0 -16
- package/decorators/render.decorator.d.ts +0 -10
- package/decorators/render.decorator.js +0 -20
- package/decorators/request-mapping.decorator.d.ts +0 -78
- package/decorators/request-mapping.decorator.js +0 -98
- package/decorators/route-params.decorator.d.ts +0 -378
- package/decorators/route-params.decorator.js +0 -227
- package/decorators/sse.decorator.d.ts +0 -6
- package/decorators/sse.decorator.js +0 -20
- package/decorators/version.decorator.d.ts +0 -7
- package/decorators/version.decorator.js +0 -20
- package/enums/http-status.enum.d.ts +0 -53
- package/enums/http-status.enum.js +0 -57
- package/enums/index.d.ts +0 -4
- package/enums/index.js +0 -20
- package/enums/request-method.enum.d.ts +0 -11
- package/enums/request-method.enum.js +0 -15
- package/enums/route-paramtypes.enum.d.ts +0 -14
- package/enums/route-paramtypes.enum.js +0 -18
- package/enums/version-type.enum.d.ts +0 -9
- package/enums/version-type.enum.js +0 -13
- package/errors/bad-gateway.exception.d.ts +0 -33
- package/errors/bad-gateway.exception.js +0 -41
- package/errors/bad-request.exception.d.ts +0 -33
- package/errors/bad-request.exception.js +0 -41
- package/errors/conflict.exception.d.ts +0 -33
- package/errors/conflict.exception.js +0 -41
- package/errors/forbidden.exception.d.ts +0 -33
- package/errors/forbidden.exception.js +0 -41
- package/errors/gateway-timeout.exception.d.ts +0 -33
- package/errors/gateway-timeout.exception.js +0 -41
- package/errors/gone.exception.d.ts +0 -33
- package/errors/gone.exception.js +0 -41
- package/errors/http-version-not-supported.exception.d.ts +0 -33
- package/errors/http-version-not-supported.exception.js +0 -41
- package/errors/http.exception.d.ts +0 -79
- package/errors/http.exception.js +0 -123
- package/errors/im-a-teapot.exception.d.ts +0 -36
- package/errors/im-a-teapot.exception.js +0 -44
- package/errors/index.d.ts +0 -11
- package/errors/index.js +0 -27
- package/errors/internal-server-error.exception.d.ts +0 -33
- package/errors/internal-server-error.exception.js +0 -41
- package/errors/invalid-middleware-configuration.exception.d.ts +0 -4
- package/errors/invalid-middleware-configuration.exception.js +0 -11
- package/errors/invalid-middleware.exception.d.ts +0 -4
- package/errors/invalid-middleware.exception.js +0 -11
- package/errors/not-found.exception.d.ts +0 -33
- package/errors/not-found.exception.js +0 -41
- package/errors/unknown-request-mapping.exception.d.ts +0 -5
- package/errors/unknown-request-mapping.exception.js +0 -11
- package/exceptions/messages.d.ts +0 -4
- package/exceptions/messages.js +0 -13
- package/explorers/path.explorer.d.ts +0 -8
- package/explorers/path.explorer.js +0 -38
- package/explorers/router.explorer.d.ts +0 -51
- package/explorers/router.explorer.js +0 -195
- package/factory/context-id.factory.d.ts +0 -41
- package/factory/context-id.factory.js +0 -52
- package/factory/index.d.ts +0 -4
- package/factory/index.js +0 -20
- package/factory/method.factory.d.ts +0 -5
- package/factory/method.factory.js +0 -30
- package/factory/params.factory.d.ts +0 -5
- package/factory/params.factory.js +0 -39
- package/factory/path.factory.d.ts +0 -13
- package/factory/path.factory.js +0 -95
- package/filters/context.d.ts +0 -9
- package/filters/context.js +0 -15
- package/filters/filter.d.ts +0 -22
- package/filters/filter.js +0 -78
- package/helpers/adapter.helper.d.ts +0 -27
- package/helpers/adapter.helper.js +0 -37
- package/helpers/exclude-route.helper.d.ts +0 -4
- package/helpers/exclude-route.helper.js +0 -18
- package/helpers/flatten-routes.helper.d.ts +0 -5
- package/helpers/flatten-routes.helper.js +0 -27
- package/helpers/index.d.ts +0 -6
- package/helpers/index.js +0 -22
- package/helpers/messages.helper.d.ts +0 -6
- package/helpers/messages.helper.js +0 -25
- package/helpers/path.helper.d.ts +0 -3
- package/helpers/path.helper.js +0 -13
- package/helpers/sse.helper.d.ts +0 -45
- package/helpers/sse.helper.js +0 -83
- package/index.d.ts +0 -1
- package/index.js +0 -3
- package/interfaces/http/cors.interface.d.ts +0 -58
- package/interfaces/http/cors.interface.js +0 -2
- package/interfaces/http/exception.interface.d.ts +0 -6
- package/interfaces/http/exception.interface.js +0 -2
- package/interfaces/http/exclude-route.interface.d.ts +0 -15
- package/interfaces/http/exclude-route.interface.js +0 -2
- package/interfaces/http/index.d.ts +0 -10
- package/interfaces/http/index.js +0 -26
- package/interfaces/http/message-event.interface.d.ts +0 -6
- package/interfaces/http/message-event.interface.js +0 -2
- package/interfaces/http/module.inteface.d.ts +0 -5
- package/interfaces/http/module.inteface.js +0 -2
- package/interfaces/http/options.interface.d.ts +0 -127
- package/interfaces/http/options.interface.js +0 -2
- package/interfaces/http/path-metadata.interface.d.ts +0 -31
- package/interfaces/http/path-metadata.interface.js +0 -2
- package/interfaces/http/prefix-options.interface.d.ts +0 -7
- package/interfaces/http/prefix-options.interface.js +0 -2
- package/interfaces/http/raw-request.d.ts +0 -4
- package/interfaces/http/raw-request.js +0 -2
- package/interfaces/http/routes.interface.d.ts +0 -7
- package/interfaces/http/routes.interface.js +0 -2
- package/interfaces/http/server.interface.d.ts +0 -54
- package/interfaces/http/server.interface.js +0 -2
- package/interfaces/index.d.ts +0 -3
- package/interfaces/index.js +0 -19
- package/interfaces/middleware/config-proxy.interface.d.ts +0 -23
- package/interfaces/middleware/config-proxy.interface.js +0 -2
- package/interfaces/middleware/configuration.interface.d.ts +0 -12
- package/interfaces/middleware/configuration.interface.js +0 -2
- package/interfaces/middleware/consumer.interface.d.ts +0 -16
- package/interfaces/middleware/consumer.interface.js +0 -2
- package/interfaces/middleware/index.d.ts +0 -4
- package/interfaces/middleware/index.js +0 -20
- package/interfaces/middleware/middleware.interface.d.ts +0 -7
- package/interfaces/middleware/middleware.interface.js +0 -2
- package/interfaces/router/callback-paramtypes.interface.d.ts +0 -1
- package/interfaces/router/callback-paramtypes.interface.js +0 -2
- package/interfaces/router/definition.interface.d.ts +0 -10
- package/interfaces/router/definition.interface.js +0 -2
- package/interfaces/router/index.d.ts +0 -3
- package/interfaces/router/index.js +0 -19
- package/interfaces/router/version-options.interface.d.ts +0 -92
- package/interfaces/router/version-options.interface.js +0 -9
- package/middleware/builder.d.ts +0 -15
- package/middleware/builder.js +0 -78
- package/middleware/container.d.ts +0 -13
- package/middleware/container.js +0 -50
- package/middleware/extractor.d.ts +0 -15
- package/middleware/extractor.js +0 -50
- package/middleware/index.d.ts +0 -1
- package/middleware/index.js +0 -17
- package/middleware/module.d.ts +0 -33
- package/middleware/module.js +0 -180
- package/middleware/resolver.d.ts +0 -10
- package/middleware/resolver.js +0 -27
- package/middleware/routes-mapper.d.ts +0 -19
- package/middleware/routes-mapper.js +0 -111
- package/middleware/utils.d.ts +0 -8
- package/middleware/utils.js +0 -86
- package/router/module.d.ts +0 -18
- package/router/module.js +0 -88
- package/router/resolver.d.ts +0 -31
- package/router/resolver.js +0 -128
- package/storage/http-instance.storage.d.ts +0 -9
- package/storage/http-instance.storage.js +0 -19
- package/stream/index.d.ts +0 -1
- package/stream/index.js +0 -17
- package/stream/interfaces/index.d.ts +0 -2
- package/stream/interfaces/index.js +0 -18
- package/stream/interfaces/streamable-handler-response.interface.d.ts +0 -12
- package/stream/interfaces/streamable-handler-response.interface.js +0 -2
- package/stream/interfaces/streamable-options.interface.d.ts +0 -10
- package/stream/interfaces/streamable-options.interface.js +0 -2
- package/stream/streamable-file.d.ts +0 -22
- package/stream/streamable-file.js +0 -55
- package/test/context/response.controller.spec.d.ts +0 -1
- package/test/context/response.controller.spec.js +0 -328
- package/test/decorators/controller.decorator.spec.d.ts +0 -1
- package/test/decorators/controller.decorator.spec.js +0 -113
- package/test/decorators/header.decorator.spec.d.ts +0 -1
- package/test/decorators/header.decorator.spec.js +0 -33
- package/test/decorators/http-code.decorator.spec.d.ts +0 -1
- package/test/decorators/http-code.decorator.spec.js +0 -30
- package/test/decorators/redirect.decorator.spec.d.ts +0 -1
- package/test/decorators/redirect.decorator.spec.js +0 -36
- package/test/decorators/render.decorator.spec.d.ts +0 -1
- package/test/decorators/render.decorator.spec.js +0 -30
- package/test/decorators/request-mapping.decorator.spec.d.ts +0 -1
- package/test/decorators/request-mapping.decorator.spec.js +0 -85
- package/test/decorators/route-params.decorator.spec.d.ts +0 -1
- package/test/decorators/route-params.decorator.spec.js +0 -493
- package/test/decorators/sse.decorator.spec.d.ts +0 -1
- package/test/decorators/sse.decorator.spec.js +0 -35
- package/test/decorators/version.decorator.spec.d.ts +0 -1
- package/test/decorators/version.decorator.spec.js +0 -43
- package/test/exceptions/handler.spec.d.ts +0 -1
- package/test/exceptions/handler.spec.js +0 -145
- package/test/exceptions/proxy.spec.d.ts +0 -1
- package/test/exceptions/proxy.spec.js +0 -74
- package/test/explorers/path.explorer.spec.d.ts +0 -1
- package/test/explorers/path.explorer.spec.js +0 -190
- package/test/explorers/router.explorer.spec.d.ts +0 -1
- package/test/explorers/router.explorer.spec.js +0 -206
- package/test/factory/method.factory.spec.d.ts +0 -1
- package/test/factory/method.factory.spec.js +0 -33
- package/test/factory/params.factory.spec.d.ts +0 -1
- package/test/factory/params.factory.spec.js +0 -104
- package/test/factory/path.factory.spec.d.ts +0 -1
- package/test/factory/path.factory.spec.js +0 -260
- package/test/filters/context.spec.d.ts +0 -1
- package/test/filters/context.spec.js +0 -96
- package/test/filters/filter.spec.d.ts +0 -1
- package/test/filters/filter.spec.js +0 -96
- package/test/helpers/flatten-routes.helper.spec.d.ts +0 -1
- package/test/helpers/flatten-routes.helper.spec.js +0 -131
- package/test/helpers/sse.helper.spec.d.ts +0 -1
- package/test/helpers/sse.helper.spec.js +0 -132
- package/test/middleware/builder.spec.d.ts +0 -1
- package/test/middleware/builder.spec.js +0 -235
- package/test/middleware/container.spec.d.ts +0 -1
- package/test/middleware/container.spec.js +0 -81
- package/test/middleware/module.spec.d.ts +0 -1
- package/test/middleware/module.spec.js +0 -206
- package/test/middleware/route-info-path-extractor.spec.d.ts +0 -1
- package/test/middleware/route-info-path-extractor.spec.js +0 -123
- package/test/middleware/routes-mapper.spec.d.ts +0 -1
- package/test/middleware/routes-mapper.spec.js +0 -162
- package/test/middleware/utils.spec.d.ts +0 -1
- package/test/middleware/utils.spec.js +0 -132
- package/test/router/module.spec.d.ts +0 -1
- package/test/router/module.spec.js +0 -40
- package/test/router/resolver.spec.d.ts +0 -1
- package/test/router/resolver.spec.js +0 -326
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
import { ApplicationContextOptions } from "@venok/core/interfaces/application/context-options.interface";
|
|
2
|
-
import { CorsOptions, CorsOptionsDelegate } from "@venok/http/interfaces/http/cors.interface";
|
|
3
|
-
/**
|
|
4
|
-
* Interface describing Https Options that can be set.
|
|
5
|
-
*
|
|
6
|
-
* @see https://nodejs.org/api/tls.html
|
|
7
|
-
*
|
|
8
|
-
* @publicApi
|
|
9
|
-
*/
|
|
10
|
-
export interface HttpsOptions {
|
|
11
|
-
/**
|
|
12
|
-
* PFX or PKCS12 encoded private key and certificate chain. pfx is an alternative
|
|
13
|
-
* to providing key and cert individually. PFX is usually encrypted, if it is,
|
|
14
|
-
* passphrase will be used to decrypt it. Multiple PFX can be provided either
|
|
15
|
-
* as an array of unencrypted PFX buffers, or an array of objects in the form
|
|
16
|
-
* {buf: <string|buffer>[, passphrase: <string>]}. The object form can only
|
|
17
|
-
* occur in an array. object.passphrase is optional. Encrypted PFX will be decrypted
|
|
18
|
-
* with object.passphrase if provided, or options.passphrase if it is not.
|
|
19
|
-
*/
|
|
20
|
-
pfx?: any;
|
|
21
|
-
/**
|
|
22
|
-
* Private keys in PEM format. PEM allows the option of private keys being encrypted.
|
|
23
|
-
* Encrypted keys will be decrypted with options.passphrase. Multiple keys using
|
|
24
|
-
* different algorithms can be provided either as an array of unencrypted key
|
|
25
|
-
* strings or buffers, or an array of objects in the form {pem: <string|buffer>[, passphrase: <string>]}.
|
|
26
|
-
* The object form can only occur in an array. object.passphrase is optional.
|
|
27
|
-
* Encrypted keys will be decrypted with object.passphrase if provided, or options.passphrase
|
|
28
|
-
* if it is not
|
|
29
|
-
*/
|
|
30
|
-
key?: any;
|
|
31
|
-
/**
|
|
32
|
-
* Shared passphrase used for a single private key and/or a PFX.
|
|
33
|
-
*/
|
|
34
|
-
passphrase?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Cert chains in PEM format. One cert chain should be provided per private key.
|
|
37
|
-
* Each cert chain should consist of the PEM formatted certificate for a provided
|
|
38
|
-
* private key, followed by the PEM formatted intermediate certificates (if any),
|
|
39
|
-
* in order, and not including the root CA (the root CA must be pre-known to the
|
|
40
|
-
* peer, see ca). When providing multiple cert chains, they do not have to be
|
|
41
|
-
* in the same order as their private keys in key. If the intermediate certificates
|
|
42
|
-
* are not provided, the peer will not be able to validate the certificate, and
|
|
43
|
-
* the handshake will fail.
|
|
44
|
-
*/
|
|
45
|
-
cert?: any;
|
|
46
|
-
/**
|
|
47
|
-
* Optionally override the trusted CA certificates. Default is to trust the well-known
|
|
48
|
-
* CAs curated by Mozilla. Mozilla's CAs are completely replaced when CAs are
|
|
49
|
-
* explicitly specified using this option. The value can be a string or Buffer,
|
|
50
|
-
* or an Array of strings and/or Buffers. Any string or Buffer can contain multiple
|
|
51
|
-
* PEM CAs concatenated together. The peer's certificate must be chainable to
|
|
52
|
-
* a CA trusted by the server for the connection to be authenticated. When using
|
|
53
|
-
* certificates that are not chainable to a well-known CA, the certificate's CA
|
|
54
|
-
* must be explicitly specified as a trusted or the connection will fail to authenticate.
|
|
55
|
-
* If the peer uses a certificate that doesn't match or chain to one of the default
|
|
56
|
-
* CAs, use the ca option to provide a CA certificate that the peer's certificate
|
|
57
|
-
* can match or chain to. For self-signed certificates, the certificate is its
|
|
58
|
-
* own CA, and must be provided. For PEM encoded certificates, supported types
|
|
59
|
-
* are "TRUSTED CERTIFICATE", "X509 CERTIFICATE", and "CERTIFICATE". See also tls.rootCertificates.
|
|
60
|
-
*/
|
|
61
|
-
ca?: any;
|
|
62
|
-
/**
|
|
63
|
-
* PEM formatted CRLs (Certificate Revocation Lists).
|
|
64
|
-
*/
|
|
65
|
-
crl?: any;
|
|
66
|
-
/**
|
|
67
|
-
* Cipher suite specification, replacing the default. For more information, see
|
|
68
|
-
* modifying the default cipher suite. Permitted ciphers can be obtained via tls.getCiphers().
|
|
69
|
-
* Cipher names must be uppercased in order for OpenSSL to accept them.
|
|
70
|
-
*/
|
|
71
|
-
ciphers?: string;
|
|
72
|
-
/**
|
|
73
|
-
* Attempt to use the server's cipher suite preferences instead of the client's.
|
|
74
|
-
* When true, causes SSL_OP_CIPHER_SERVER_PREFERENCE to be set in secureOptions,
|
|
75
|
-
* see OpenSSL Options for more information.
|
|
76
|
-
*/
|
|
77
|
-
honorCipherOrder?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* If true the server will request a certificate from clients that connect and
|
|
80
|
-
* attempt to verify that certificate. Default: false.
|
|
81
|
-
*/
|
|
82
|
-
requestCert?: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* If not false the server will reject any connection which is not authorized
|
|
85
|
-
* with the list of supplied CAs. This option only has an effect if requestCert is true. Default: true
|
|
86
|
-
*/
|
|
87
|
-
rejectUnauthorized?: boolean;
|
|
88
|
-
/**
|
|
89
|
-
* An array or Buffer of possible NPN protocols. (Protocols should be ordered
|
|
90
|
-
* by their priority).
|
|
91
|
-
*/
|
|
92
|
-
NPNProtocols?: any;
|
|
93
|
-
/**
|
|
94
|
-
* A function that will be called if the client supports SNI TLS extension. Two
|
|
95
|
-
* arguments will be passed when called: servername and cb. SNICallback should
|
|
96
|
-
* invoke cb(null, ctx), where ctx is a SecureContext instance. (tls.createSecureContext(...)
|
|
97
|
-
* can be used to get a proper SecureContext.) If SNICallback wasn't provided
|
|
98
|
-
* the default callback with high-level API will be used.
|
|
99
|
-
*/
|
|
100
|
-
SNICallback?: (servername: string, cb: (err: Error, ctx: any) => any) => any;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* @publicApi
|
|
104
|
-
*/
|
|
105
|
-
export interface VenokApplicationOptions extends ApplicationContextOptions {
|
|
106
|
-
/**
|
|
107
|
-
* CORS options from [CORS package](https://github.com/expressjs/cors#configuration-options)
|
|
108
|
-
*/
|
|
109
|
-
cors?: boolean | CorsOptions | CorsOptionsDelegate<any>;
|
|
110
|
-
/**
|
|
111
|
-
* Whether to use underlying platform body parser.
|
|
112
|
-
*/
|
|
113
|
-
bodyParser?: boolean;
|
|
114
|
-
/**
|
|
115
|
-
* Set of configurable HTTPS options
|
|
116
|
-
*/
|
|
117
|
-
httpsOptions?: HttpsOptions;
|
|
118
|
-
/**
|
|
119
|
-
* Whether to register the raw request body on the request. Use `req.rawBody`.
|
|
120
|
-
*/
|
|
121
|
-
rawBody?: boolean;
|
|
122
|
-
/**
|
|
123
|
-
* Force close open HTTP connections. Useful if restarting your application hangs due to
|
|
124
|
-
* keep-alive connections in the HTTP adapter.
|
|
125
|
-
*/
|
|
126
|
-
forceCloseConnections?: boolean;
|
|
127
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { VersioningOptions, VersionValue } from "../router/version-options.interface";
|
|
2
|
-
export interface RoutePathMetadata {
|
|
3
|
-
/**
|
|
4
|
-
* Controller-level path (e.g., @Controller('resource') = "resource").
|
|
5
|
-
*/
|
|
6
|
-
ctrlPath?: string;
|
|
7
|
-
/**
|
|
8
|
-
* Method-level path (e.g., @Get('resource') = "resource").
|
|
9
|
-
*/
|
|
10
|
-
methodPath?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Global route prefix specified with the "NestApplication#setGlobalPrefix" method.
|
|
13
|
-
*/
|
|
14
|
-
globalPrefix?: string;
|
|
15
|
-
/**
|
|
16
|
-
* Module-level path registered through the "RouterModule".
|
|
17
|
-
*/
|
|
18
|
-
modulePath?: string;
|
|
19
|
-
/**
|
|
20
|
-
* Controller-level version (e.g., @Controller({ version: '1.0' }) = "1.0").
|
|
21
|
-
*/
|
|
22
|
-
controllerVersion?: VersionValue;
|
|
23
|
-
/**
|
|
24
|
-
* Method-level version (e.g., @Version('1.0') = "1.0").
|
|
25
|
-
*/
|
|
26
|
-
methodVersion?: VersionValue;
|
|
27
|
-
/**
|
|
28
|
-
* API versioning options object.
|
|
29
|
-
*/
|
|
30
|
-
versioningOptions?: VersioningOptions;
|
|
31
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { VersioningOptions, VersionValue } from "../router/version-options.interface";
|
|
2
|
-
import { CorsOptions, CorsOptionsDelegate } from "@venok/http/interfaces/http/cors.interface";
|
|
3
|
-
import { RequestMethod } from "@venok/http/enums";
|
|
4
|
-
import { VenokApplicationOptions } from "@venok/http/interfaces/http/options.interface";
|
|
5
|
-
export type ErrorHandler<TRequest = any, TResponse = any> = (error: any, req: TRequest, res: TResponse, next?: Function) => any;
|
|
6
|
-
export type RequestHandler<TRequest = any, TResponse = any> = (req: TRequest, res: TResponse, next?: Function) => any;
|
|
7
|
-
export interface HttpServer<TRequest = any, TResponse = any, ServerInstance = any> {
|
|
8
|
-
use(handler: RequestHandler<TRequest, TResponse> | ErrorHandler<TRequest, TResponse>): any;
|
|
9
|
-
use(path: string, handler: RequestHandler<TRequest, TResponse> | ErrorHandler<TRequest, TResponse>): any;
|
|
10
|
-
useBodyParser?(...args: any[]): any;
|
|
11
|
-
get(handler: RequestHandler<TRequest, TResponse>): any;
|
|
12
|
-
get(path: string, handler: RequestHandler<TRequest, TResponse>): any;
|
|
13
|
-
post(handler: RequestHandler<TRequest, TResponse>): any;
|
|
14
|
-
post(path: string, handler: RequestHandler<TRequest, TResponse>): any;
|
|
15
|
-
head(handler: RequestHandler<TRequest, TResponse>): any;
|
|
16
|
-
head(path: string, handler: RequestHandler<TRequest, TResponse>): any;
|
|
17
|
-
delete(handler: RequestHandler<TRequest, TResponse>): any;
|
|
18
|
-
delete(path: string, handler: RequestHandler<TRequest, TResponse>): any;
|
|
19
|
-
put(handler: RequestHandler<TRequest, TResponse>): any;
|
|
20
|
-
put(path: string, handler: RequestHandler<TRequest, TResponse>): any;
|
|
21
|
-
patch(handler: RequestHandler<TRequest, TResponse>): any;
|
|
22
|
-
patch(path: string, handler: RequestHandler<TRequest, TResponse>): any;
|
|
23
|
-
all(path: string, handler: RequestHandler<TRequest, TResponse>): any;
|
|
24
|
-
all(handler: RequestHandler<TRequest, TResponse>): any;
|
|
25
|
-
options(handler: RequestHandler<TRequest, TResponse>): any;
|
|
26
|
-
options(path: string, handler: RequestHandler<TRequest, TResponse>): any;
|
|
27
|
-
listen(port: number | string, callback?: () => void): any;
|
|
28
|
-
listen(port: number | string, hostname: string, callback?: () => void): any;
|
|
29
|
-
reply(response: any, body: any, statusCode?: number): any;
|
|
30
|
-
status(response: any, statusCode: number): any;
|
|
31
|
-
end(response: any, message?: string): any;
|
|
32
|
-
render(response: any, view: string, options: any): any;
|
|
33
|
-
redirect(response: any, statusCode: number, url: string): any;
|
|
34
|
-
isHeadersSent(response: any): boolean;
|
|
35
|
-
setHeader(response: any, name: string, value: string): any;
|
|
36
|
-
setErrorHandler?(handler: Function, prefix?: string): any;
|
|
37
|
-
setNotFoundHandler?(handler: Function, prefix?: string): any;
|
|
38
|
-
useStaticAssets?(...args: any[]): this;
|
|
39
|
-
setBaseViewsDir?(path: string | string[]): this;
|
|
40
|
-
setViewEngine?(engineOrOptions: any): this;
|
|
41
|
-
createMiddlewareFactory(method: RequestMethod): ((path: string, callback: Function) => any) | Promise<(path: string, callback: Function) => any>;
|
|
42
|
-
getRequestHostname?(request: TRequest): string;
|
|
43
|
-
getRequestMethod?(request: TRequest): string;
|
|
44
|
-
getRequestUrl?(request: TRequest): string;
|
|
45
|
-
getInstance(): ServerInstance;
|
|
46
|
-
registerParserMiddleware(...args: any[]): any;
|
|
47
|
-
enableCors(options: CorsOptions | CorsOptionsDelegate<TRequest>): any;
|
|
48
|
-
getHttpServer(): any;
|
|
49
|
-
initHttpServer(options: VenokApplicationOptions): void;
|
|
50
|
-
close(): any;
|
|
51
|
-
getType(): string;
|
|
52
|
-
init?(): Promise<void>;
|
|
53
|
-
applyVersionFilter(handler: Function, version: VersionValue, versioningOptions: VersioningOptions): (req: TRequest, res: TResponse, next: () => void) => Function;
|
|
54
|
-
}
|
package/interfaces/index.d.ts
DELETED
package/interfaces/index.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./http"), exports);
|
|
18
|
-
__exportStar(require("./middleware"), exports);
|
|
19
|
-
__exportStar(require("./router"), exports);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { RouteInfo } from "./configuration.interface";
|
|
2
|
-
import { Type } from "@venok/core";
|
|
3
|
-
import { MiddlewareConsumer } from "./consumer.interface";
|
|
4
|
-
/**
|
|
5
|
-
* @publicApi
|
|
6
|
-
*/
|
|
7
|
-
export interface MiddlewareConfigProxy {
|
|
8
|
-
/**
|
|
9
|
-
* Excludes routes from the currently processed middleware.
|
|
10
|
-
*
|
|
11
|
-
* @param {(string | RouteInfo)[]} routes
|
|
12
|
-
* @returns {MiddlewareConfigProxy}
|
|
13
|
-
*/
|
|
14
|
-
exclude(...routes: (string | RouteInfo)[]): MiddlewareConfigProxy;
|
|
15
|
-
/**
|
|
16
|
-
* Attaches passed either routes or controllers to the currently configured middleware.
|
|
17
|
-
* If you pass a class, Venok would attach middleware to every path defined within this controller.
|
|
18
|
-
*
|
|
19
|
-
* @param {(string | Type | RouteInfo)[]} routes
|
|
20
|
-
* @returns {MiddlewareConsumer}
|
|
21
|
-
*/
|
|
22
|
-
forRoutes(...routes: (string | Type | RouteInfo)[]): MiddlewareConsumer;
|
|
23
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { RequestMethod } from "../../enums";
|
|
2
|
-
import { VersionValue } from "../router/version-options.interface";
|
|
3
|
-
import { Type } from "@venok/core";
|
|
4
|
-
export interface RouteInfo {
|
|
5
|
-
path: string;
|
|
6
|
-
method: RequestMethod;
|
|
7
|
-
version?: VersionValue;
|
|
8
|
-
}
|
|
9
|
-
export interface MiddlewareConfiguration<T = any> {
|
|
10
|
-
middleware: T;
|
|
11
|
-
forRoutes: (Type | string | RouteInfo)[];
|
|
12
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Type } from "@venok/core";
|
|
2
|
-
import { MiddlewareConfigProxy } from "./config-proxy.interface";
|
|
3
|
-
/**
|
|
4
|
-
* Interface defining method for applying user defined middleware to routes.
|
|
5
|
-
*
|
|
6
|
-
* @publicApi
|
|
7
|
-
*/
|
|
8
|
-
export interface MiddlewareConsumer {
|
|
9
|
-
/**
|
|
10
|
-
* @param {...(Type | Function)} middleware middleware class/function or array of classes/functions
|
|
11
|
-
* to be attached to the passed routes.
|
|
12
|
-
*
|
|
13
|
-
* @returns {MiddlewareConfigProxy}
|
|
14
|
-
*/
|
|
15
|
-
apply(...middleware: (Type | Function)[]): MiddlewareConfigProxy;
|
|
16
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./config-proxy.interface"), exports);
|
|
18
|
-
__exportStar(require("./configuration.interface"), exports);
|
|
19
|
-
__exportStar(require("./consumer.interface"), exports);
|
|
20
|
-
__exportStar(require("./middleware.interface"), exports);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type RouterProxyCallback = <TRequest, TResponse>(req?: TRequest, res?: TResponse, next?: () => void) => void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { VersionValue } from "./version-options.interface";
|
|
2
|
-
import { RequestMethod } from "../../enums";
|
|
3
|
-
import { RouterProxyCallback } from "./callback-paramtypes.interface";
|
|
4
|
-
export interface RouteDefinition {
|
|
5
|
-
path: string[];
|
|
6
|
-
requestMethod: RequestMethod;
|
|
7
|
-
targetCallback: RouterProxyCallback;
|
|
8
|
-
methodName: string;
|
|
9
|
-
version?: VersionValue;
|
|
10
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./callback-paramtypes.interface"), exports);
|
|
18
|
-
__exportStar(require("./definition.interface"), exports);
|
|
19
|
-
__exportStar(require("./version-options.interface"), exports);
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { VersioningType } from "../../enums";
|
|
2
|
-
/**
|
|
3
|
-
* Indicates that this will work for any version passed in the request, or no version.
|
|
4
|
-
*
|
|
5
|
-
* @publicApi
|
|
6
|
-
*/
|
|
7
|
-
export declare const VERSION_NEUTRAL: unique symbol;
|
|
8
|
-
/**
|
|
9
|
-
* @publicApi
|
|
10
|
-
*/
|
|
11
|
-
export type VersionValue = string | typeof VERSION_NEUTRAL | Array<string | typeof VERSION_NEUTRAL>;
|
|
12
|
-
/**
|
|
13
|
-
* @publicApi
|
|
14
|
-
*/
|
|
15
|
-
export interface VersionOptions {
|
|
16
|
-
/**
|
|
17
|
-
* Specifies an optional API Version. When configured, methods
|
|
18
|
-
* within the controller will only be routed if the request version
|
|
19
|
-
* matches the specified value.
|
|
20
|
-
*
|
|
21
|
-
* Supported only by HTTP-based application (does not apply to non-HTTP microservices).
|
|
22
|
-
*
|
|
23
|
-
* @see [Versioning](https://docs.nestjs.com/techniques/versioning)
|
|
24
|
-
*/
|
|
25
|
-
version?: VersionValue;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* @publicApi
|
|
29
|
-
*/
|
|
30
|
-
export interface HeaderVersioningOptions {
|
|
31
|
-
type: VersioningType.HEADER;
|
|
32
|
-
/**
|
|
33
|
-
* The name of the Request Header that contains the version.
|
|
34
|
-
*/
|
|
35
|
-
header: string;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* @publicApi
|
|
39
|
-
*/
|
|
40
|
-
export interface UriVersioningOptions {
|
|
41
|
-
type: VersioningType.URI;
|
|
42
|
-
/**
|
|
43
|
-
* Optional prefix that will prepend the version within the URI.
|
|
44
|
-
*
|
|
45
|
-
* Defaults to `v`.
|
|
46
|
-
*
|
|
47
|
-
* Ex. Assuming a version of `1`, for `/api/v1/route`, `v` is the prefix.
|
|
48
|
-
*/
|
|
49
|
-
prefix?: string | false;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* @publicApi
|
|
53
|
-
*/
|
|
54
|
-
export interface MediaTypeVersioningOptions {
|
|
55
|
-
type: VersioningType.MEDIA_TYPE;
|
|
56
|
-
/**
|
|
57
|
-
* The key within the Media Type Header to determine the version from.
|
|
58
|
-
*
|
|
59
|
-
* Ex. For `application/json;v=1`, the key is `v=`.
|
|
60
|
-
*/
|
|
61
|
-
key: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* @publicApi
|
|
65
|
-
*/
|
|
66
|
-
export interface CustomVersioningOptions {
|
|
67
|
-
type: VersioningType.CUSTOM;
|
|
68
|
-
/**
|
|
69
|
-
* A function that accepts a request object (specific to the underlying platform, ie Express or Fastify)
|
|
70
|
-
* and returns a single version value or an ordered array of versions, in order from HIGHEST to LOWEST.
|
|
71
|
-
*
|
|
72
|
-
* Ex. Returned version array = ['3.1', '3.0', '2.5', '2', '1.9']
|
|
73
|
-
*
|
|
74
|
-
* Use type assertion or narrowing to identify the specific request type.
|
|
75
|
-
*/
|
|
76
|
-
extractor: (request: unknown) => string | string[];
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* @publicApi
|
|
80
|
-
*/
|
|
81
|
-
interface VersioningCommonOptions {
|
|
82
|
-
/**
|
|
83
|
-
* The default version to be used as a fallback when you did not provide some
|
|
84
|
-
* version to `@Controller()` nor `@Version()`.
|
|
85
|
-
*/
|
|
86
|
-
defaultVersion?: VersionOptions["version"];
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* @publicApi
|
|
90
|
-
*/
|
|
91
|
-
export type VersioningOptions = VersioningCommonOptions & (HeaderVersioningOptions | UriVersioningOptions | MediaTypeVersioningOptions | CustomVersioningOptions);
|
|
92
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VERSION_NEUTRAL = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Indicates that this will work for any version passed in the request, or no version.
|
|
6
|
-
*
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
exports.VERSION_NEUTRAL = Symbol("VERSION_NEUTRAL");
|
package/middleware/builder.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { RoutesMapper } from "./routes-mapper";
|
|
2
|
-
import { MiddlewareConfigProxy, MiddlewareConfiguration, MiddlewareConsumer, HttpServer } from "../interfaces";
|
|
3
|
-
import { RouteInfoPathExtractor } from "./extractor";
|
|
4
|
-
import { Type } from "@venok/core";
|
|
5
|
-
export declare class MiddlewareBuilder implements MiddlewareConsumer {
|
|
6
|
-
private readonly routesMapper;
|
|
7
|
-
private readonly httpAdapter;
|
|
8
|
-
private readonly routeInfoPathExtractor;
|
|
9
|
-
private readonly middlewareCollection;
|
|
10
|
-
constructor(routesMapper: RoutesMapper, httpAdapter: HttpServer, routeInfoPathExtractor: RouteInfoPathExtractor);
|
|
11
|
-
apply(...middleware: Array<Type | Function | any>): MiddlewareConfigProxy;
|
|
12
|
-
build(): MiddlewareConfiguration[];
|
|
13
|
-
getHttpAdapter(): HttpServer;
|
|
14
|
-
private static readonly ConfigProxy;
|
|
15
|
-
}
|
package/middleware/builder.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MiddlewareBuilder = void 0;
|
|
4
|
-
const flatten_helper_1 = require("../../core/helpers/flatten.helper");
|
|
5
|
-
const utils_1 = require("./utils");
|
|
6
|
-
const helpers_1 = require("../helpers");
|
|
7
|
-
class MiddlewareBuilder {
|
|
8
|
-
constructor(routesMapper, httpAdapter, routeInfoPathExtractor) {
|
|
9
|
-
this.routesMapper = routesMapper;
|
|
10
|
-
this.httpAdapter = httpAdapter;
|
|
11
|
-
this.routeInfoPathExtractor = routeInfoPathExtractor;
|
|
12
|
-
this.middlewareCollection = new Set();
|
|
13
|
-
}
|
|
14
|
-
apply(...middleware) {
|
|
15
|
-
return new MiddlewareBuilder.ConfigProxy(this, (0, flatten_helper_1.flatten)(middleware), this.routeInfoPathExtractor);
|
|
16
|
-
}
|
|
17
|
-
build() {
|
|
18
|
-
return [...this.middlewareCollection];
|
|
19
|
-
}
|
|
20
|
-
getHttpAdapter() {
|
|
21
|
-
return this.httpAdapter;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.MiddlewareBuilder = MiddlewareBuilder;
|
|
25
|
-
MiddlewareBuilder.ConfigProxy = class {
|
|
26
|
-
constructor(builder, middleware, routeInfoPathExtractor) {
|
|
27
|
-
this.builder = builder;
|
|
28
|
-
this.middleware = middleware;
|
|
29
|
-
this.routeInfoPathExtractor = routeInfoPathExtractor;
|
|
30
|
-
this.excludedRoutes = [];
|
|
31
|
-
}
|
|
32
|
-
getExcludedRoutes() {
|
|
33
|
-
return this.excludedRoutes;
|
|
34
|
-
}
|
|
35
|
-
exclude(...routes) {
|
|
36
|
-
this.excludedRoutes = this.getRoutesFlatList(routes).map((route) => ({
|
|
37
|
-
...route,
|
|
38
|
-
path: this.routeInfoPathExtractor.extractPathFrom(route),
|
|
39
|
-
}));
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
forRoutes(...routes) {
|
|
43
|
-
const { middlewareCollection } = this.builder;
|
|
44
|
-
const flattedRoutes = this.getRoutesFlatList(routes);
|
|
45
|
-
const forRoutes = this.removeOverlappedRoutes(flattedRoutes);
|
|
46
|
-
const configuration = {
|
|
47
|
-
middleware: (0, utils_1.filterMiddleware)(this.middleware, this.excludedRoutes, this.builder.getHttpAdapter()),
|
|
48
|
-
forRoutes,
|
|
49
|
-
};
|
|
50
|
-
middlewareCollection.add(configuration);
|
|
51
|
-
return this.builder;
|
|
52
|
-
}
|
|
53
|
-
getRoutesFlatList(routes) {
|
|
54
|
-
const { routesMapper } = this.builder;
|
|
55
|
-
return (0, flatten_helper_1.flatten)(routes.map((route) => routesMapper.mapRouteToRouteInfo(route)));
|
|
56
|
-
}
|
|
57
|
-
removeOverlappedRoutes(routes) {
|
|
58
|
-
const regexMatchParams = /(:[^\/]*)/g;
|
|
59
|
-
const wildcard = "([^/]*)";
|
|
60
|
-
const routesWithRegex = routes
|
|
61
|
-
.filter((route) => route.path.includes(":"))
|
|
62
|
-
.map((route) => ({
|
|
63
|
-
method: route.method,
|
|
64
|
-
path: route.path,
|
|
65
|
-
regex: new RegExp("^(" + route.path.replace(regexMatchParams, wildcard) + ")$", "g"),
|
|
66
|
-
}));
|
|
67
|
-
return routes.filter((route) => {
|
|
68
|
-
const isOverlapped = (item) => {
|
|
69
|
-
if (route.method !== item.method)
|
|
70
|
-
return false;
|
|
71
|
-
const normalizedRoutePath = (0, helpers_1.stripEndSlash)(route.path);
|
|
72
|
-
return normalizedRoutePath !== item.path && item.regex.test(normalizedRoutePath);
|
|
73
|
-
};
|
|
74
|
-
const routeMatch = routesWithRegex.find(isOverlapped);
|
|
75
|
-
return routeMatch === undefined;
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
};
|