@dcl/http-server 1.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.
Files changed (59) hide show
  1. package/README.md +3 -0
  2. package/dist/benchmark.d.ts +1 -0
  3. package/dist/benchmark.js +94 -0
  4. package/dist/benchmark.js.map +1 -0
  5. package/dist/cors.d.ts +35 -0
  6. package/dist/cors.js +138 -0
  7. package/dist/cors.js.map +1 -0
  8. package/dist/helpers.d.ts +1 -0
  9. package/dist/helpers.js +3 -0
  10. package/dist/helpers.js.map +1 -0
  11. package/dist/index.d.ts +8 -0
  12. package/dist/index.js +25 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/injectors.d.ts +5 -0
  15. package/dist/injectors.js +22 -0
  16. package/dist/injectors.js.map +1 -0
  17. package/dist/layer.d.ts +58 -0
  18. package/dist/layer.js +102 -0
  19. package/dist/layer.js.map +1 -0
  20. package/dist/logic.d.ts +12 -0
  21. package/dist/logic.js +288 -0
  22. package/dist/logic.js.map +1 -0
  23. package/dist/methods.d.ts +6 -0
  24. package/dist/methods.js +16 -0
  25. package/dist/methods.js.map +1 -0
  26. package/dist/metrics.d.ts +36 -0
  27. package/dist/metrics.js +107 -0
  28. package/dist/metrics.js.map +1 -0
  29. package/dist/middleware.d.ts +9 -0
  30. package/dist/middleware.js +35 -0
  31. package/dist/middleware.js.map +1 -0
  32. package/dist/router.d.ts +190 -0
  33. package/dist/router.js +516 -0
  34. package/dist/router.js.map +1 -0
  35. package/dist/server-handler.d.ts +1 -0
  36. package/dist/server-handler.js +34 -0
  37. package/dist/server-handler.js.map +1 -0
  38. package/dist/server.d.ts +17 -0
  39. package/dist/server.js +176 -0
  40. package/dist/server.js.map +1 -0
  41. package/dist/status-checks.d.ts +33 -0
  42. package/dist/status-checks.js +154 -0
  43. package/dist/status-checks.js.map +1 -0
  44. package/dist/terminator.d.ts +18 -0
  45. package/dist/terminator.js +128 -0
  46. package/dist/terminator.js.map +1 -0
  47. package/dist/test-component.d.ts +22 -0
  48. package/dist/test-component.js +89 -0
  49. package/dist/test-component.js.map +1 -0
  50. package/dist/test-server.d.ts +21 -0
  51. package/dist/test-server.js +81 -0
  52. package/dist/test-server.js.map +1 -0
  53. package/dist/types.d.ts +32 -0
  54. package/dist/types.js +3 -0
  55. package/dist/types.js.map +1 -0
  56. package/dist/ws.d.ts +8 -0
  57. package/dist/ws.js +32 -0
  58. package/dist/ws.js.map +1 -0
  59. package/package.json +49 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @dcl/http-server
2
+
3
+ forked from https://github.com/well-known-components/http-server
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ // this server shuts down after 10100 requests.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const interfaces_1 = require("@well-known-components/interfaces");
5
+ const env_config_provider_1 = require("@well-known-components/env-config-provider");
6
+ const index_1 = require("./index");
7
+ const logger_1 = require("@well-known-components/logger");
8
+ const fs_1 = require("fs");
9
+ // Lifecycle.run manages the lifecycle of the application and components
10
+ // it is particularly useful for servers with many components with state
11
+ // like database connectors, servers, or batch jobs.
12
+ // It also handles POSIX signals like SIGTERM to gracefully stop the
13
+ // components
14
+ interfaces_1.Lifecycle.run({ initComponents, main });
15
+ // main entry point of the application, it's role is to wire components
16
+ // together (controllers, handlers) and ultimately start the components
17
+ // by calling startComponents
18
+ async function main({ components, startComponents, stop }) {
19
+ const globalContext = { components };
20
+ // wire the server
21
+ components.server.setContext(globalContext);
22
+ components.server.use(async function logger(ctx, next) {
23
+ // Log the response time of all the requests handled by this server
24
+ return await next();
25
+ });
26
+ let counter = 0;
27
+ const staticBuffer = Buffer.from(new Array(10000).fill(0).map(() => Math.floor(Math.random() * 256)));
28
+ const staticArrayBuffer = new Uint8Array(staticBuffer);
29
+ const packageJsonString = (0, fs_1.readFileSync)('package.json').toString();
30
+ const packageJson = JSON.parse(packageJsonString);
31
+ const TOTAL_REQUESTS = 10100;
32
+ const TOTAL_STAGES = 5;
33
+ components.server.use(async function handler(ctx) {
34
+ counter++;
35
+ if (counter >= TOTAL_REQUESTS) {
36
+ setTimeout(() => stop().catch(console.log), 0);
37
+ }
38
+ const headers = {};
39
+ const stage = Math.floor((counter / TOTAL_REQUESTS) * TOTAL_STAGES);
40
+ switch (stage) {
41
+ case 1:
42
+ return {
43
+ headers,
44
+ status: 200,
45
+ body: staticBuffer
46
+ };
47
+ case 2:
48
+ return {
49
+ headers,
50
+ status: 200,
51
+ body: staticArrayBuffer
52
+ };
53
+ case 3:
54
+ return {
55
+ headers,
56
+ status: 200,
57
+ body: packageJsonString
58
+ };
59
+ case 4:
60
+ return {
61
+ headers,
62
+ status: 200,
63
+ body: packageJson
64
+ };
65
+ }
66
+ // Respond hello world
67
+ return {
68
+ headers,
69
+ status: 200,
70
+ body: {
71
+ json: true,
72
+ text: 'Hello world'
73
+ }
74
+ };
75
+ });
76
+ // start server and other components
77
+ await startComponents();
78
+ }
79
+ // initComponents role is to create BUT NOT START the components,
80
+ // this function is only called once by the Lifecycle manager
81
+ async function initComponents() {
82
+ const logs = await (0, logger_1.createLogComponent)({});
83
+ const config = (0, env_config_provider_1.createConfigComponent)({
84
+ HTTP_SERVER_PORT: '5000',
85
+ HTTP_SERVER_HOST: '0.0.0.0'
86
+ });
87
+ const server = await (0, index_1.createServerComponent)({ logs, config }, {});
88
+ return /*components*/ {
89
+ logs,
90
+ config,
91
+ server
92
+ };
93
+ }
94
+ //# sourceMappingURL=benchmark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.js","sourceRoot":"","sources":["../src/benchmark.ts"],"names":[],"mappings":";AAAA,+CAA+C;;AAE/C,kEAAuH;AACvH,oFAAkF;AAClF,mCAA+C;AAC/C,0DAAkE;AAClE,2BAAiC;AAejC,wEAAwE;AACxE,wEAAwE;AACxE,oDAAoD;AACpD,oEAAoE;AACpE,aAAa;AACb,sBAAS,CAAC,GAAG,CAAa,EAAE,cAAc,EAAE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QACN,MAAM;KACP,CAAA;AACH,CAAC"}
package/dist/cors.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { Response } from 'node-fetch';
2
+ import { IHttpServerComponent } from '@well-known-components/interfaces';
3
+ export declare const corsHeaders: {
4
+ 'Access-Control-Allow-Origin': string;
5
+ 'Access-Control-Allow-Methods': string;
6
+ 'Access-Control-Max-Age': string;
7
+ 'Access-Control-Expose-Headers': string;
8
+ 'Access-Control-Allow-Headers': string;
9
+ };
10
+ export declare function handleOptions(): Response;
11
+ type CustomOrigin = (requestOrigin: string | undefined) => boolean;
12
+ export interface CorsOptions {
13
+ /**
14
+ * @default '*''
15
+ */
16
+ origin?: boolean | string | (string | RegExp)[] | CustomOrigin;
17
+ /**
18
+ * @default 'GET,HEAD,PUT,PATCH,POST,DELETE'
19
+ */
20
+ methods?: string[];
21
+ allowedHeaders?: string[];
22
+ exposedHeaders?: string[];
23
+ credentials?: boolean;
24
+ maxAge?: number;
25
+ /**
26
+ * @default false
27
+ */
28
+ preflightContinue?: boolean;
29
+ /**
30
+ * @default 204
31
+ */
32
+ optionsSuccessStatus?: number;
33
+ }
34
+ export declare function createCorsMiddleware<Context>(options: CorsOptions): IHttpServerComponent.IRequestHandler<Context>;
35
+ export {};
package/dist/cors.js ADDED
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ // Temporary fix to enable local develoment until this CORS module is merged into http-server
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.corsHeaders = void 0;
5
+ exports.handleOptions = handleOptions;
6
+ exports.createCorsMiddleware = createCorsMiddleware;
7
+ const node_fetch_1 = require("node-fetch");
8
+ exports.corsHeaders = {
9
+ 'Access-Control-Allow-Origin': '*',
10
+ 'Access-Control-Allow-Methods': 'GET, HEAD, OPTIONS',
11
+ 'Access-Control-Max-Age': '86400',
12
+ 'Access-Control-Expose-Headers': 'ETag',
13
+ 'Access-Control-Allow-Headers': 'Accept, Accept-Encoding, Access-Control-Allow-Credentials, Access-Control-Allow-Headers, Access-Control-Allow-Methods, Access-Control-Allow-Origin, ' +
14
+ 'Access-Control-Max-Age, Age, Allow,Authentication-Info, Authorization, CONNECT, Cache-Control, Connection, Content-Base, Content-Length, Content-Location, ' +
15
+ 'Content-MD5, Content-Type, Content-Version, Cookie, DELETE, Destination, Expires, ETag, From, GET, HEAD, Host, Keep-Alive, Location, MIME-Version, OPTION, OPTIONS, ' +
16
+ 'Optional, Origin, POST, PUT, Protocol, Proxy-Authenticate, Proxy-Authentication-Info, Proxy-Authorization, Proxy-Features, Public, Referer, Refresh, Resolver-Location, ' +
17
+ 'Sec-Websocket-Extensions, Sec-Websocket-Key, Sec-Websocket-Origin, Sec-Websocket-Protocol, Sec-Websocket-Version, Security-Scheme, Server, Set-Cookie, et-Cookie2, SetProfile, ' +
18
+ 'Status, Timeout, Title, URI, User-Agent, Version, WWW-Authenticate, X-Content-Duration, X-Content-Security-Policy, X-Content-Type-Options, X-CustomHeader, X-DNSPrefetch-Control, ' +
19
+ 'X-Forwarded-For, X-Forwarded-Port, X-Forwarded-Proto, X-Frame-Options, X-Modified, X-OTHER, X-PING, X-Requested-With'
20
+ };
21
+ function handleOptions() {
22
+ return new node_fetch_1.Response(undefined, {
23
+ headers: exports.corsHeaders
24
+ });
25
+ }
26
+ function isString(s) {
27
+ return typeof s === 'string' || s instanceof String;
28
+ }
29
+ function isOriginAllowed(origin, allowedOrigin) {
30
+ if (Array.isArray(allowedOrigin)) {
31
+ for (let i = 0; i < allowedOrigin.length; ++i) {
32
+ if (isOriginAllowed(origin, allowedOrigin[i])) {
33
+ return true;
34
+ }
35
+ }
36
+ return false;
37
+ }
38
+ else if (isString(allowedOrigin)) {
39
+ return origin === allowedOrigin;
40
+ }
41
+ else if (allowedOrigin instanceof RegExp) {
42
+ return allowedOrigin.test(origin);
43
+ }
44
+ else if (allowedOrigin instanceof Function) {
45
+ return allowedOrigin(origin);
46
+ }
47
+ else {
48
+ return !!allowedOrigin;
49
+ }
50
+ }
51
+ function configureOrigin(options, req, headers) {
52
+ const requestOrigin = req.headers.get('origin');
53
+ let isAllowed = false;
54
+ if (!options.origin || options.origin === '*') {
55
+ // allow any origin
56
+ headers.set('Access-Control-Allow-Origin', '*');
57
+ }
58
+ else if (isString(options.origin)) {
59
+ // fixed origin
60
+ headers.set('Access-Control-Allow-Origin', options.origin);
61
+ headers.set('Vary', 'Origin');
62
+ }
63
+ else if (requestOrigin && options.origin) {
64
+ isAllowed = isOriginAllowed(requestOrigin, options.origin);
65
+ // reflect origin
66
+ headers.set('Access-Control-Allow-Origin', isAllowed ? requestOrigin : 'false');
67
+ headers.set('Vary', 'Origin');
68
+ }
69
+ }
70
+ function configureMethods(options, req, headers) {
71
+ if (options.methods && options.methods.length) {
72
+ headers.set('Access-Control-Allow-Methods', options.methods.join(','));
73
+ }
74
+ }
75
+ function configureCredentials(options, req, headers) {
76
+ if (options.credentials === true) {
77
+ headers.set('Access-Control-Allow-Credentials', 'true');
78
+ }
79
+ }
80
+ function configureAllowedHeaders(options, req, headers) {
81
+ let allowedHeaders = options.allowedHeaders || null;
82
+ if (!allowedHeaders) {
83
+ allowedHeaders = req.headers.get('access-control-request-headers'); // .headers wasn't specified, so reflect the request headers
84
+ headers.set('Vary', 'Access-Control-Request-Headers');
85
+ }
86
+ if (allowedHeaders && !isString(allowedHeaders)) {
87
+ allowedHeaders = allowedHeaders.join(','); // .headers is an array, so turn it into a string
88
+ }
89
+ if (allowedHeaders && allowedHeaders.length) {
90
+ headers.set('Access-Control-Allow-Headers', allowedHeaders);
91
+ }
92
+ }
93
+ function configureExposedHeaders(options, req, headers) {
94
+ const exposedHeaders = options.exposedHeaders;
95
+ if (exposedHeaders && exposedHeaders.length) {
96
+ headers.set('Access-Control-Expose-Headers', exposedHeaders.join(','));
97
+ }
98
+ }
99
+ function configureMaxAge(options, req, headers) {
100
+ if (options.maxAge !== undefined) {
101
+ headers.set('Access-Control-Max-Age', options.maxAge.toString());
102
+ }
103
+ }
104
+ function createCorsMiddleware(options) {
105
+ return async function handleCors(event, next) {
106
+ const request = event.request;
107
+ const method = request.method && request.method.toUpperCase && request.method.toUpperCase();
108
+ if (method === 'OPTIONS') {
109
+ if (options.preflightContinue) {
110
+ return await next();
111
+ }
112
+ else {
113
+ const headers = new node_fetch_1.Headers();
114
+ // preflight
115
+ configureOrigin(options, request, headers);
116
+ configureCredentials(options, request, headers);
117
+ configureMethods(options, request, headers);
118
+ configureAllowedHeaders(options, request, headers);
119
+ configureMaxAge(options, request, headers);
120
+ configureExposedHeaders(options, request, headers);
121
+ headers.set('Content-Length', '0');
122
+ return { status: options.optionsSuccessStatus || 204, headers };
123
+ }
124
+ }
125
+ else {
126
+ const r = await next();
127
+ const headers = new node_fetch_1.Headers(r.headers);
128
+ if (event.request.headers.has('origin')) {
129
+ // actual response
130
+ configureOrigin(options, request, headers);
131
+ configureCredentials(options, request, headers);
132
+ configureExposedHeaders(options, request, headers);
133
+ }
134
+ return { ...r, headers };
135
+ }
136
+ };
137
+ }
138
+ //# sourceMappingURL=cors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cors.js","sourceRoot":"","sources":["../src/cors.ts"],"names":[],"mappings":";AAAA,6FAA6F;;;AAoB7F,sCAIC;AAgHD,oDAsCC;AA5KD,2CAAuD;AAG1C,QAAA,WAAW,GAAG;IACzB,6BAA6B,EAAE,GAAG;IAClC,8BAA8B,EAAE,oBAAoB;IACpD,wBAAwB,EAAE,OAAO;IACjC,+BAA+B,EAAE,MAAM;IACvC,8BAA8B,EAC5B,sJAAsJ;QACtJ,6JAA6J;QAC7J,sKAAsK;QACtK,0KAA0K;QAC1K,iLAAiL;QACjL,oLAAoL;QACpL,sHAAsH;CACzH,CAAA;AAED,SAAgB,aAAa;IAC3B,OAAO,IAAI,qBAAQ,CAAC,SAAS,EAAE;QAC7B,OAAO,EAAE,mBAAW;KACrB,CAAC,CAAA;AACJ,CAAC;AA2BD,SAAS,QAAQ,CAAC,CAAM;IACtB,OAAO,OAAO,CAAC,KAAK,QAAQ,I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"__esModule", { value: true });
3
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ export * from './server';
2
+ export * from './injectors';
3
+ export * from './test-component';
4
+ export * from './types';
5
+ export * from './status-checks';
6
+ export * from './helpers';
7
+ export * from './router';
8
+ export * from './metrics';
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
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("./server"), exports);
18
+ __exportStar(require("./injectors"), exports);
19
+ __exportStar(require("./test-component"), exports);
20
+ __exportStar(require("./types"), exports);
21
+ __exportStar(require("./status-checks"), exports);
22
+ __exportStar(require("./helpers"), exports);
23
+ __exportStar(require("./router"), exports);
24
+ __exportStar(require("./metrics"), exports);
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAwB;AACxB,8CAA2B;AAC3B,mDAAgC;AAChC,0CAAuB;AACvB,kDAA+B;AAC/B,4CAAyB;AACzB,2CAAwB;AACxB,4CAAyB"}
@@ -0,0 +1,5 @@
1
+ import type { IHttpServerComponent } from '@well-known-components/interfaces';
2
+ /**
3
+ * @public
4
+ */
5
+ export declare function getUnderlyingServer<T>(server: IHttpServerComponent<any>): Promise<T>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUnderlyingServer = getUnderlyingServer;
4
+ exports._setUnderlyingServer = _setUnderlyingServer;
5
+ const underlyingServerKey = Symbol('real-server');
6
+ /**
7
+ * @public
8
+ */
9
+ async function getUnderlyingServer(server) {
10
+ const getListener = server[underlyingServerKey];
11
+ if (!getListener)
12
+ throw new Error('The provided server does not have an underlying http or https server implementation');
13
+ return getListener();
14
+ }
15
+ /**
16
+ * @internal
17
+ */
18
+ function _setUnderlyingServer(server, getter) {
19
+ ;
20
+ server[underlyingServerKey] = getter;
21
+ }
22
+ //# sourceMappingURL=injectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"injectors.js","sourceRoot":"","sources":["../src/injectors.ts"],"names":[],"mappings":";;AAOA,kDAKC;AAKD,oDAEC;AAjBD,MAAM,mBAAmB,GAAG,MAAM,CAAC,aAAa,CAAC,CAAA;AAEjD;;GAEG;AACI,KAAK,UAAU,mBAAmB,CAAI,MAAiC;IAC5E,MAAM,WAAW,GAAsB,MAAc,CAAC,mBAAmB,CAAC,CAAA;IAC1E,IAAI,CAAC,WAAW;QACd,MAAM,IAAI,KAAK,CAAC,qFAAqF,CAAC,CAAA;IACxG,OAAO,WAAW,EAAE,CAAA;AACtB,CAAC;AAED;;GAEG;AACH,SAAgB,oBAAoB,CAAI,MAAiC,EAAE,MAAwB;IACjG,CAAC;IAAC,MAAc,CAAC,mBAAmB,CAAC,GAAG,MAAM,CAAA;AAChD,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { IHttpServerComponent as http } from '@well-known-components/interfaces';
2
+ import { Key } from 'path-to-regexp';
3
+ import { Middleware } from './middleware';
4
+ import { RoutedContext } from './router';
5
+ export type LayerOptions = Partial<{
6
+ name: string;
7
+ sensitive: boolean;
8
+ strict: boolean;
9
+ ignoreCaptures: boolean;
10
+ end: boolean;
11
+ prefix: string;
12
+ }>;
13
+ /**
14
+ * Initialize a new routing Layer with given `method`, `path`, and `middleware`.
15
+ *
16
+ * @param path - Path string or regular expression.
17
+ * @param methods - Array of HTTP verbs.
18
+ * @param middleware - Layer callback/middleware or series of.
19
+ * @param opts - Layer options
20
+ *
21
+ * @public
22
+ */
23
+ export declare class Layer<Context, Path extends string> {
24
+ opts: LayerOptions;
25
+ name: string | null;
26
+ methods: http.HTTPMethod[];
27
+ paramNames: Key[];
28
+ stack: Middleware<RoutedContext<http.DefaultContext<Context>, Path>>[];
29
+ path: string;
30
+ regexp: RegExp;
31
+ constructor(path: Path, methods: ReadonlyArray<http.HTTPMethod>, middleware: Middleware<RoutedContext<http.DefaultContext<Context>, Path>> | Middleware<RoutedContext<http.DefaultContext<Context>, Path>>[], opts?: LayerOptions);
32
+ /**
33
+ * Returns whether request `path` matches route.
34
+ *
35
+ * @param path -
36
+ */
37
+ match(path: string): boolean;
38
+ /**
39
+ * Returns map of URL parameters for given `path` and `paramNames`.
40
+ *
41
+ * @param path -
42
+ * @param captures -
43
+ * @param existingParams -
44
+ */
45
+ params(captures: Array<string>, existingParams: Record<string, string>): object;
46
+ /**
47
+ * Returns array of regexp url path captures.
48
+ *
49
+ * @param path -
50
+ */
51
+ captures(path: string): Array<string>;
52
+ /**
53
+ * Prefix route path.
54
+ *
55
+ * @param prefix -
56
+ */
57
+ setPrefix(prefix: string): this;
58
+ }
package/dist/layer.js ADDED
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Layer = void 0;
4
+ const path_to_regexp_1 = require("path-to-regexp");
5
+ /**
6
+ * Initialize a new routing Layer with given `method`, `path`, and `middleware`.
7
+ *
8
+ * @param path - Path string or regular expression.
9
+ * @param methods - Array of HTTP verbs.
10
+ * @param middleware - Layer callback/middleware or series of.
11
+ * @param opts - Layer options
12
+ *
13
+ * @public
14
+ */
15
+ class Layer {
16
+ constructor(path, methods, middleware, opts) {
17
+ this.opts = opts || {};
18
+ this.name = this.opts.name || null;
19
+ this.methods = [];
20
+ this.paramNames = [];
21
+ this.stack = Array.isArray(middleware) ? middleware : [middleware];
22
+ for (let i = 0; i < methods.length; i++) {
23
+ const l = this.methods.push(methods[i].toUpperCase());
24
+ if (this.methods[l - 1] === 'GET')
25
+ this.methods.unshift('HEAD');
26
+ }
27
+ // ensure middleware is a function
28
+ for (let i = 0; i < this.stack.length; i++) {
29
+ const fn = this.stack[i];
30
+ const type = typeof fn;
31
+ if (type !== 'function')
32
+ throw new Error(`${methods.toString()} \`${this.opts.name || path}\`: \`middleware\` must be a function, not \`${type}\``);
33
+ }
34
+ this.path = path;
35
+ this.regexp = (0, path_to_regexp_1.pathToRegexp)(path, this.paramNames, this.opts);
36
+ }
37
+ /**
38
+ * Returns whether request `path` matches route.
39
+ *
40
+ * @param path -
41
+ */
42
+ match(path) {
43
+ return this.regexp.test(path);
44
+ }
45
+ /**
46
+ * Returns map of URL parameters for given `path` and `paramNames`.
47
+ *
48
+ * @param path -
49
+ * @param captures -
50
+ * @param existingParams -
51
+ */
52
+ params(captures, existingParams) {
53
+ const params = existingParams || {};
54
+ for (let len = captures.length, i = 0; i < len; i++) {
55
+ if (this.paramNames[i]) {
56
+ const c = captures[i];
57
+ params[this.paramNames[i].name] = c ? safeDecodeURIComponent(c) : c;
58
+ }
59
+ }
60
+ return params;
61
+ }
62
+ /**
63
+ * Returns array of regexp url path captures.
64
+ *
65
+ * @param path -
66
+ */
67
+ captures(path) {
68
+ const r = path.match(this.regexp);
69
+ if (!r)
70
+ return [];
71
+ return this.opts.ignoreCaptures ? [] : r.slice(1);
72
+ }
73
+ /**
74
+ * Prefix route path.
75
+ *
76
+ * @param prefix -
77
+ */
78
+ setPrefix(prefix) {
79
+ if (this.path) {
80
+ this.path = this.path !== '/' || this.opts.strict === true ? `${prefix}${this.path}` : prefix;
81
+ this.paramNames = [];
82
+ this.regexp = (0, path_to_regexp_1.pathToRegexp)(this.path, this.paramNames, this.opts);
83
+ }
84
+ return this;
85
+ }
86
+ }
87
+ exports.Layer = Layer;
88
+ /**
89
+ * Safe decodeURIComponent, won't throw any error.
90
+ * If `decodeURIComponent` error happen, just return the original value.
91
+ *
92
+ * @param text -
93
+ */
94
+ function safeDecodeURIComponent(text) {
95
+ try {
96
+ return decodeURIComponent(text);
97
+ }
98
+ catch (e) {
99
+ return text;
100
+ }
101
+ }
102
+ //# sourceMappingURL=layer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layer.js","sourceRoot":"","sources":["../src/layer.ts"],"names":[],"mappings":";;;AACA,mDAAkD;AAalD;;;;;;;;;GASG;AACH,MAAa,KAAK;IAShB,YACE,IAAU,EACV,OAAuC,EACvC,UAEmE,EACnE,IAAmB;QAEnB,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAA;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAA;QAClC,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;QACpB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAA;QAElE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,WAAW,EAAqB,CAAC,CAAA;YACxE,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,KAAK;gBAAE,IAAI,CAAC,OAAO,CAAC,OAAO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AAC,CAAC,CAAC,CAAA;YACrE,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IAED;;;;OAIG;IAEH,QAAQ,CAAC,IAAY;QACnB,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACjC,IAAI,CAAC,CAAC;YAAE,OAAO,EAAE,CAAA;QACjB,OAAO,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACnD,CAAC;IAED;;;;OAIG;IAEH,SAAS,CAAC,MAAc;QACtB,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAAA;YAC7F,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;YACpB,IAAI,CAAC,MAAM,GAAG,IAAA,6BAAY,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;QACnE,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AApGD,sBAoGC;AAED;;;;;GAKG;AAEH,SAAS,sBAAsB,CAAC,IAAY;IAC1C,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAA;IACjC,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
@@ -0,0 +1,12 @@
1
+ import * as http from 'http';
2
+ import type { IHttpServerComponent } from '@well-known-components/interfaces';
3
+ import { Middleware } from './middleware';
4
+ export declare const getRequestFromNodeMessage: <T extends http.IncomingMessage & {
5
+ originalUrl?: string;
6
+ }>(request: T, host: string) => IHttpServerComponent.IRequest;
7
+ export declare const coerceErrorsMiddleware: Middleware<any>;
8
+ /**
9
+ * Default middleware
10
+ * @public
11
+ */
12
+ export declare function defaultHandler(): Promise<IHttpServerComponent.IResponse>;