@loopback/core 4.0.0-alpha.9 → 4.0.2
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/LICENSE +25 -0
- package/README.md +77 -2
- package/dist/application.d.ts +341 -0
- package/dist/application.js +554 -0
- package/dist/application.js.map +1 -0
- package/dist/component.d.ts +80 -0
- package/dist/component.js +59 -0
- package/dist/component.js.map +1 -0
- package/dist/extension-point.d.ts +121 -0
- package/dist/extension-point.js +227 -0
- package/dist/extension-point.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/keys.d.ts +97 -0
- package/dist/keys.js +109 -0
- package/dist/keys.js.map +1 -0
- package/dist/lifecycle-registry.d.ts +91 -0
- package/dist/lifecycle-registry.js +191 -0
- package/dist/lifecycle-registry.js.map +1 -0
- package/dist/lifecycle.d.ts +47 -0
- package/dist/lifecycle.js +56 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/mixin-target.d.ts +60 -0
- package/{lib6/internal-types.js → dist/mixin-target.js} +2 -3
- package/dist/mixin-target.js.map +1 -0
- package/dist/server.d.ts +16 -0
- package/{lib6/component.js → dist/server.js} +2 -2
- package/dist/server.js.map +1 -0
- package/dist/service.d.ts +63 -0
- package/dist/service.js +151 -0
- package/dist/service.js.map +1 -0
- package/package.json +39 -37
- package/src/application.ts +719 -0
- package/src/component.ts +155 -0
- package/src/extension-point.ts +312 -0
- package/src/index.ts +29 -0
- package/src/keys.ts +144 -0
- package/src/lifecycle-registry.ts +268 -0
- package/src/lifecycle.ts +90 -0
- package/src/mixin-target.ts +69 -0
- package/src/server.ts +22 -0
- package/src/service.ts +211 -0
- package/index.d.ts +0 -6
- package/index.js +0 -9
- package/lib/application.d.ts +0 -54
- package/lib/application.js +0 -81
- package/lib/application.js.map +0 -1
- package/lib/component.d.ts +0 -2
- package/lib/component.js +0 -7
- package/lib/component.js.map +0 -1
- package/lib/http-handler.d.ts +0 -16
- package/lib/http-handler.js +0 -62
- package/lib/http-handler.js.map +0 -1
- package/lib/index.d.ts +0 -17
- package/lib/index.js +0 -37
- package/lib/index.js.map +0 -1
- package/lib/internal-types.d.ts +0 -29
- package/lib/internal-types.js +0 -8
- package/lib/internal-types.js.map +0 -1
- package/lib/keys.d.ts +0 -7
- package/lib/keys.js +0 -16
- package/lib/keys.js.map +0 -1
- package/lib/parser.d.ts +0 -11
- package/lib/parser.js +0 -96
- package/lib/parser.js.map +0 -1
- package/lib/promisify.d.ts +0 -3
- package/lib/promisify.js +0 -34
- package/lib/promisify.js.map +0 -1
- package/lib/router/metadata.d.ts +0 -12
- package/lib/router/metadata.js +0 -30
- package/lib/router/metadata.js.map +0 -1
- package/lib/router/routing-table.d.ts +0 -16
- package/lib/router/routing-table.js +0 -97
- package/lib/router/routing-table.js.map +0 -1
- package/lib/sequence.d.ts +0 -55
- package/lib/sequence.js +0 -99
- package/lib/sequence.js.map +0 -1
- package/lib/server.d.ts +0 -23
- package/lib/server.js +0 -64
- package/lib/server.js.map +0 -1
- package/lib/writer.d.ts +0 -11
- package/lib/writer.js +0 -34
- package/lib/writer.js.map +0 -1
- package/lib6/application.d.ts +0 -54
- package/lib6/application.js +0 -81
- package/lib6/application.js.map +0 -1
- package/lib6/component.d.ts +0 -2
- package/lib6/component.js.map +0 -1
- package/lib6/http-handler.d.ts +0 -16
- package/lib6/http-handler.js +0 -72
- package/lib6/http-handler.js.map +0 -1
- package/lib6/index.d.ts +0 -17
- package/lib6/index.js +0 -37
- package/lib6/index.js.map +0 -1
- package/lib6/internal-types.d.ts +0 -29
- package/lib6/internal-types.js.map +0 -1
- package/lib6/keys.d.ts +0 -7
- package/lib6/keys.js +0 -16
- package/lib6/keys.js.map +0 -1
- package/lib6/parser.d.ts +0 -11
- package/lib6/parser.js +0 -106
- package/lib6/parser.js.map +0 -1
- package/lib6/promisify.d.ts +0 -3
- package/lib6/promisify.js +0 -34
- package/lib6/promisify.js.map +0 -1
- package/lib6/router/metadata.d.ts +0 -12
- package/lib6/router/metadata.js +0 -30
- package/lib6/router/metadata.js.map +0 -1
- package/lib6/router/routing-table.d.ts +0 -16
- package/lib6/router/routing-table.js +0 -97
- package/lib6/router/routing-table.js.map +0 -1
- package/lib6/sequence.d.ts +0 -55
- package/lib6/sequence.js +0 -109
- package/lib6/sequence.js.map +0 -1
- package/lib6/server.d.ts +0 -23
- package/lib6/server.js +0 -74
- package/lib6/server.js.map +0 -1
- package/lib6/writer.d.ts +0 -11
- package/lib6/writer.js +0 -34
- package/lib6/writer.js.map +0 -1
package/lib/application.d.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Binding, Context, Constructor } from '@loopback/context';
|
|
3
|
-
import { Component } from '.';
|
|
4
|
-
import { ServerRequest, ServerResponse } from 'http';
|
|
5
|
-
import { HttpHandler } from './http-handler';
|
|
6
|
-
import { Sequence } from './sequence';
|
|
7
|
-
export declare class Application extends Context {
|
|
8
|
-
options: ApplicationOptions;
|
|
9
|
-
/**
|
|
10
|
-
* Handle incoming HTTP(S) request by invoking the corresponding
|
|
11
|
-
* Controller method via the configured Sequence.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
*
|
|
15
|
-
* ```ts
|
|
16
|
-
* const app = new Application();
|
|
17
|
-
* // setup controllers, etc.
|
|
18
|
-
*
|
|
19
|
-
* const server = http.createServer(app.handleHttp);
|
|
20
|
-
* server.listen(3000);
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @param req The request.
|
|
24
|
-
* @param res The response.
|
|
25
|
-
*/
|
|
26
|
-
handleHttp: (req: ServerRequest, res: ServerResponse) => Promise<void>;
|
|
27
|
-
protected _httpHandler: HttpHandler;
|
|
28
|
-
constructor(options?: ApplicationOptions);
|
|
29
|
-
protected _bindSequence(): void;
|
|
30
|
-
protected _handleHttpRequest(request: ServerRequest, response: ServerResponse): Promise<void>;
|
|
31
|
-
protected _setupHandlerIfNeeded(): void;
|
|
32
|
-
/**
|
|
33
|
-
* Register a controller class with this application.
|
|
34
|
-
*
|
|
35
|
-
* @param controllerCtor {Function} The controller class
|
|
36
|
-
* (constructor function).
|
|
37
|
-
* @return {Binding} The newly created binding, you can use the reference to
|
|
38
|
-
* further modify the binding, e.g. lock the value to prevent further
|
|
39
|
-
* modifications.
|
|
40
|
-
*
|
|
41
|
-
* ```ts
|
|
42
|
-
* @spec(apiSpec)
|
|
43
|
-
* class MyController {
|
|
44
|
-
* }
|
|
45
|
-
* app.controller(MyController).lock();
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
controller<T>(controllerCtor: Constructor<T>): Binding;
|
|
49
|
-
protected _logError(err: Error, statusCode: number, req: ServerRequest): void;
|
|
50
|
-
}
|
|
51
|
-
export interface ApplicationOptions {
|
|
52
|
-
components?: Array<Constructor<Component>>;
|
|
53
|
-
sequence?: Constructor<Sequence>;
|
|
54
|
-
}
|
package/lib/application.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/core
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const context_1 = require("@loopback/context");
|
|
8
|
-
const metadata_1 = require("./router/metadata");
|
|
9
|
-
const http_handler_1 = require("./http-handler");
|
|
10
|
-
const sequence_1 = require("./sequence");
|
|
11
|
-
const debug = require('debug')('loopback:core:application');
|
|
12
|
-
class Application extends context_1.Context {
|
|
13
|
-
constructor(options) {
|
|
14
|
-
super();
|
|
15
|
-
this.options = options;
|
|
16
|
-
if (options && options.components) {
|
|
17
|
-
for (const component of options.components) {
|
|
18
|
-
// TODO(superkhau): Need to figure a way around this hack,
|
|
19
|
-
// `componentClassName.constructor.name` + `componentClassName.name`
|
|
20
|
-
// doesn't work
|
|
21
|
-
const componentClassName = component.toString().split(' ')[1];
|
|
22
|
-
this.bind(`component.${componentClassName}`).toClass(component);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
this._bindSequence();
|
|
26
|
-
this.handleHttp = (req, res) => this._handleHttpRequest(req, res);
|
|
27
|
-
this.bind('logError').to(this._logError.bind(this));
|
|
28
|
-
}
|
|
29
|
-
_bindSequence() {
|
|
30
|
-
// TODO(bajtos, ritch, superkhau) figure out how to integrate this single
|
|
31
|
-
// sequence with custom sequences contributed by components
|
|
32
|
-
const sequence = this.options && this.options.sequence
|
|
33
|
-
? this.options.sequence
|
|
34
|
-
: sequence_1.Sequence;
|
|
35
|
-
this.bind('sequence').toClass(sequence);
|
|
36
|
-
}
|
|
37
|
-
_handleHttpRequest(request, response) {
|
|
38
|
-
this._setupHandlerIfNeeded();
|
|
39
|
-
return this._httpHandler.handleRequest(request, response);
|
|
40
|
-
}
|
|
41
|
-
_setupHandlerIfNeeded() {
|
|
42
|
-
// TODO(bajtos) support hot-reloading of controllers
|
|
43
|
-
// after the app started. The idea is to rebuild the HttpHandler
|
|
44
|
-
// instance whenever a controller was added/deleted.
|
|
45
|
-
if (this._httpHandler)
|
|
46
|
-
return;
|
|
47
|
-
this._httpHandler = new http_handler_1.HttpHandler(this);
|
|
48
|
-
for (const b of this.find('controllers.*')) {
|
|
49
|
-
const ctor = b.valueConstructor;
|
|
50
|
-
if (!ctor) {
|
|
51
|
-
throw new Error(`The controller ${b.key} was not bound via .toClass()`);
|
|
52
|
-
}
|
|
53
|
-
const apiSpec = metadata_1.getApiSpec(ctor);
|
|
54
|
-
this._httpHandler.registerController(b.key, apiSpec);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Register a controller class with this application.
|
|
59
|
-
*
|
|
60
|
-
* @param controllerCtor {Function} The controller class
|
|
61
|
-
* (constructor function).
|
|
62
|
-
* @return {Binding} The newly created binding, you can use the reference to
|
|
63
|
-
* further modify the binding, e.g. lock the value to prevent further
|
|
64
|
-
* modifications.
|
|
65
|
-
*
|
|
66
|
-
* ```ts
|
|
67
|
-
* @spec(apiSpec)
|
|
68
|
-
* class MyController {
|
|
69
|
-
* }
|
|
70
|
-
* app.controller(MyController).lock();
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
controller(controllerCtor) {
|
|
74
|
-
return this.bind('controllers.' + controllerCtor.name).toClass(controllerCtor);
|
|
75
|
-
}
|
|
76
|
-
_logError(err, statusCode, req) {
|
|
77
|
-
console.error('Unhandled error in %s %s: %s %s', req.method, req.url, statusCode, err.stack || err);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.Application = Application;
|
|
81
|
-
//# sourceMappingURL=application.js.map
|
package/lib/application.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"application.js","sourceRoot":"","sources":["../src/application.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;AAEhE,+CAAgE;AAGhE,gDAA6C;AAC7C,iDAA2C;AAC3C,yCAAoC;AAEpC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,2BAA2B,CAAC,CAAC;AAE5D,iBAAyB,SAAQ,iBAAO;IAsBtC,YAAmB,OAA4B;QAC7C,KAAK,EAAE,CAAC;QADS,YAAO,GAAP,OAAO,CAAqB;QAG7C,EAAE,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;YAClC,GAAG,CAAC,CAAC,MAAM,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;gBAC3C,0DAA0D;gBAC1D,qEAAqE;gBACrE,gBAAgB;gBAChB,MAAM,kBAAkB,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC9D,IAAI,CAAC,IAAI,C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AM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,GAAG,+BAA+B,CAAC,CAAC;YAC1E,CAAC;YACD,MAAM,OAAO,GAAG,qBAAU,CAAC,IAAI,CAAC,CAAC;YACjC,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,UAAU,CAAI,cAA8B;QACjD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC,OAAO,CAC5D,cAAc,CACf,CAAC;IACJ,CAAC;IAES,SAAS,CACjB,GAAU,EACV,UAAkB,EAClB,GAAkB;QAElB,OAAO,CAAC,KAAK,CACX,iCAAiC,EACjC,GAAG,CAAC,MAAM,EACV,GAAG,CAAC,GAAG,EACP,UAAU,EACV,GAAG,CAAC,KAAK,IAAI,GAAG,CACjB,CAAC;IACJ,CAAC;CACF;AAhHD,kCAgHC"}
|
package/lib/component.d.ts
DELETED
package/lib/component.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/core
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
//# sourceMappingURL=component.js.map
|
package/lib/component.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../src/component.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE"}
|
package/lib/http-handler.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Context } from '@loopback/context';
|
|
3
|
-
import { OpenApiSpec } from '@loopback/openapi-spec';
|
|
4
|
-
import { ServerRequest, ServerResponse } from 'http';
|
|
5
|
-
import { RoutingTable } from './router/routing-table';
|
|
6
|
-
export declare class HttpHandler {
|
|
7
|
-
protected _rootContext: Context;
|
|
8
|
-
protected _routes: RoutingTable<string>;
|
|
9
|
-
handleRequest: (request: ServerRequest, response: ServerResponse) => Promise<void>;
|
|
10
|
-
constructor(_rootContext: Context);
|
|
11
|
-
registerController(name: string, spec: OpenApiSpec): void;
|
|
12
|
-
protected _handleRequest(request: ServerRequest, response: ServerResponse): Promise<void>;
|
|
13
|
-
protected _createRequestContext(req: ServerRequest, res: ServerResponse): Context;
|
|
14
|
-
protected _bindFindRoute(context: Context): void;
|
|
15
|
-
protected _bindInvokeMethod(context: Context): void;
|
|
16
|
-
}
|
package/lib/http-handler.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/core
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const context_1 = require("@loopback/context");
|
|
8
|
-
const HttpErrors = require("http-errors");
|
|
9
|
-
const routing_table_1 = require("./router/routing-table");
|
|
10
|
-
const debug = require('debug')('loopback:core:http-handler');
|
|
11
|
-
class HttpHandler {
|
|
12
|
-
constructor(_rootContext) {
|
|
13
|
-
this._rootContext = _rootContext;
|
|
14
|
-
this._routes = new routing_table_1.RoutingTable();
|
|
15
|
-
this.handleRequest = (req, res) => this._handleRequest(req, res);
|
|
16
|
-
}
|
|
17
|
-
registerController(name, spec) {
|
|
18
|
-
this._routes.registerController(name, spec);
|
|
19
|
-
}
|
|
20
|
-
async _handleRequest(request, response) {
|
|
21
|
-
const parsedRequest = routing_table_1.parseRequestUrl(request);
|
|
22
|
-
const requestContext = this._createRequestContext(request, response);
|
|
23
|
-
this._bindFindRoute(requestContext);
|
|
24
|
-
this._bindInvokeMethod(requestContext);
|
|
25
|
-
const sequence = await requestContext.get('sequence');
|
|
26
|
-
return sequence.run(parsedRequest, response);
|
|
27
|
-
}
|
|
28
|
-
_createRequestContext(req, res) {
|
|
29
|
-
const requestContext = new context_1.Context(this._rootContext);
|
|
30
|
-
requestContext.bind('http.request').to(req);
|
|
31
|
-
requestContext.bind('http.response').to(res);
|
|
32
|
-
return requestContext;
|
|
33
|
-
}
|
|
34
|
-
_bindFindRoute(context) {
|
|
35
|
-
context.bind('findRoute').toDynamicValue(() => {
|
|
36
|
-
return (request) => {
|
|
37
|
-
const req = context.getSync('http.request');
|
|
38
|
-
const found = this._routes.find(req);
|
|
39
|
-
if (!found)
|
|
40
|
-
throw new HttpErrors.NotFound(`Endpoint "${req.method} ${req.path}" not found.`);
|
|
41
|
-
// bind routing information to context
|
|
42
|
-
const ctor = context.getBinding(found.controller).valueConstructor;
|
|
43
|
-
if (!ctor)
|
|
44
|
-
throw new Error(`The controller ${found.controller} was not bound via .toClass()`);
|
|
45
|
-
context.bind('controller.current.ctor').to(ctor);
|
|
46
|
-
context.bind('controller.current.operation').to(found.methodName);
|
|
47
|
-
return found;
|
|
48
|
-
};
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
_bindInvokeMethod(context) {
|
|
52
|
-
context.bind('invokeMethod').toDynamicValue(() => {
|
|
53
|
-
return async (controllerName, method, args) => {
|
|
54
|
-
const controller = await context.get(controllerName);
|
|
55
|
-
const result = await controller[method](...args);
|
|
56
|
-
return result;
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
exports.HttpHandler = HttpHandler;
|
|
62
|
-
//# sourceMappingURL=http-handler.js.map
|
package/lib/http-handler.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-handler.js","sourceRoot":"","sources":["../src/http-handler.ts"],"names":[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AAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBACjD,MAAM,CAAC,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA/ED,kCA+EC"}
|
package/lib/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export { Application } from './application';
|
|
2
|
-
export { Component } from './component';
|
|
3
|
-
export { api } from './router/metadata';
|
|
4
|
-
export { Sequence } from './sequence';
|
|
5
|
-
export { Server, ServerConfig, ServerState } from './server';
|
|
6
|
-
export { inject } from '@loopback/context';
|
|
7
|
-
export * from '@loopback/openapi-spec';
|
|
8
|
-
export { ServerRequest, ServerResponse } from 'http';
|
|
9
|
-
import * as HttpErrors from 'http-errors';
|
|
10
|
-
export { HttpErrors };
|
|
11
|
-
export { ParsedRequest, OperationRetval, FindRoute, InvokeMethod, LogError, OperationArgs } from './internal-types';
|
|
12
|
-
export { parseOperationArgs } from './parser';
|
|
13
|
-
export { parseRequestUrl } from './router/routing-table';
|
|
14
|
-
export { RoutingTable, ResolvedRoute } from './router/routing-table';
|
|
15
|
-
export { HttpHandler } from './http-handler';
|
|
16
|
-
export { writeResultToResponse } from './writer';
|
|
17
|
-
export * from './keys';
|
package/lib/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/core
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
function __export(m) {
|
|
7
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
// package dependencies
|
|
11
|
-
var application_1 = require("./application");
|
|
12
|
-
exports.Application = application_1.Application;
|
|
13
|
-
var metadata_1 = require("./router/metadata");
|
|
14
|
-
exports.api = metadata_1.api;
|
|
15
|
-
var sequence_1 = require("./sequence");
|
|
16
|
-
exports.Sequence = sequence_1.Sequence;
|
|
17
|
-
var server_1 = require("./server");
|
|
18
|
-
exports.Server = server_1.Server;
|
|
19
|
-
exports.ServerState = server_1.ServerState;
|
|
20
|
-
// loopback dependencies
|
|
21
|
-
var context_1 = require("@loopback/context");
|
|
22
|
-
exports.inject = context_1.inject;
|
|
23
|
-
// import all errors from external http-errors package
|
|
24
|
-
const HttpErrors = require("http-errors");
|
|
25
|
-
exports.HttpErrors = HttpErrors;
|
|
26
|
-
var parser_1 = require("./parser");
|
|
27
|
-
exports.parseOperationArgs = parser_1.parseOperationArgs;
|
|
28
|
-
var routing_table_1 = require("./router/routing-table");
|
|
29
|
-
exports.parseRequestUrl = routing_table_1.parseRequestUrl;
|
|
30
|
-
var routing_table_2 = require("./router/routing-table");
|
|
31
|
-
exports.RoutingTable = routing_table_2.RoutingTable;
|
|
32
|
-
var http_handler_1 = require("./http-handler");
|
|
33
|
-
exports.HttpHandler = http_handler_1.HttpHandler;
|
|
34
|
-
var writer_1 = require("./writer");
|
|
35
|
-
exports.writeResultToResponse = writer_1.writeResultToResponse;
|
|
36
|
-
__export(require("./keys"));
|
|
37
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;AAEhE,uBAAuB;AACvB,6CAA0C;AAAlC,oCAAA,WAAW,CAAA;AAEnB,8CAAsC;AAA9B,yBAAA,GAAG,CAAA;AACX,uCAAoC;AAA5B,8BAAA,QAAQ,CAAA;AAChB,mCAA2D;AAAnD,0BAAA,MAAM,CAAA;AAAgB,+BAAA,WAAW,CAAA;AAEzC,wBAAwB;AACxB,6CAAyC;AAAjC,2BAAA,MAAM,CAAA;AAMd,sDAAsD;AACtD,0CAA0C;AAGlC,gCAAU;AAWlB,mCAA4C;AAApC,sCAAA,kBAAkB,CAAA;AAC1B,wDAAuD;AAA/C,0CAAA,eAAe,CAAA;AACvB,wDAAmE;AAA3D,uCAAA,YAAY,CAAA;AACpB,+CAA2C;AAAnC,qCAAA,WAAW,CAAA;AACnB,mCAA+C;AAAvC,yCAAA,qBAAqB,CAAA;AAC7B,4BAAuB"}
|
package/lib/internal-types.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ServerRequest } from 'http';
|
|
3
|
-
import { ResolvedRoute } from './router/routing-table';
|
|
4
|
-
export interface ParsedRequest extends ServerRequest {
|
|
5
|
-
path: string;
|
|
6
|
-
query: {
|
|
7
|
-
[key: string]: string;
|
|
8
|
-
};
|
|
9
|
-
url: string;
|
|
10
|
-
pathname: string;
|
|
11
|
-
method: string;
|
|
12
|
-
}
|
|
13
|
-
export declare type FindRoute = (request: ParsedRequest) => ResolvedRoute<string>;
|
|
14
|
-
/**
|
|
15
|
-
* Invokes a method defined in the Application Controller
|
|
16
|
-
*
|
|
17
|
-
* @param controller Name of end-user's application controller
|
|
18
|
-
* class which defines the methods.
|
|
19
|
-
* @param method Method name in application controller class
|
|
20
|
-
* @param args Operation arguments for the method
|
|
21
|
-
* @returns OperationRetval Result from method invocation
|
|
22
|
-
*/
|
|
23
|
-
export declare type InvokeMethod = (controller: string, method: string, args: OperationArgs) => Promise<OperationRetval>;
|
|
24
|
-
export declare type LogError = (err: Error, statusCode: number, request: ServerRequest) => void;
|
|
25
|
-
export declare type PathParameterValues = {
|
|
26
|
-
[key: string]: any;
|
|
27
|
-
};
|
|
28
|
-
export declare type OperationArgs = any[];
|
|
29
|
-
export declare type OperationRetval = any;
|
package/lib/internal-types.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/core
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
// tslint:enable:no-any
|
|
8
|
-
//# sourceMappingURL=internal-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal-types.js","sourceRoot":"","sources":["../src/internal-types.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;AAyChE,uBAAuB"}
|
package/lib/keys.d.ts
DELETED
package/lib/keys.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/core
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
var BindingKeys;
|
|
8
|
-
(function (BindingKeys) {
|
|
9
|
-
var Context;
|
|
10
|
-
(function (Context) {
|
|
11
|
-
Context.CONTROLLER_CLASS = 'controller.class';
|
|
12
|
-
Context.CONTROLLER_METHOD_NAME = 'controller.method.name';
|
|
13
|
-
Context.CONTROLLER_METHOD_META = 'controller.method.meta';
|
|
14
|
-
})(Context = BindingKeys.Context || (BindingKeys.Context = {}));
|
|
15
|
-
})(BindingKeys = exports.BindingKeys || (exports.BindingKeys = {}));
|
|
16
|
-
//# sourceMappingURL=keys.js.map
|
package/lib/keys.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;AAEhE,IAAiB,WAAW,CAM3B;AAND,WAAiB,WAAW;IAC1B,IAAiB,OAAO,CAIvB;IAJD,WAAiB,OAAO;QACT,wBAAgB,GAAW,kBAAkB,CAAC;QAC9C,8BAAsB,GAAW,wBAAwB,CAAC;QAC1D,8BAAsB,GAAW,wBAAwB,CAAC;IACzE,CAAC,EAJgB,OAAO,GAAP,mBAAO,KAAP,mBAAO,QAIvB;AACH,CAAC,EANgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAM3B"}
|
package/lib/parser.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { OperationObject } from '@loopback/openapi-spec';
|
|
2
|
-
import { OperationArgs, ParsedRequest, PathParameterValues } from './internal-types';
|
|
3
|
-
/**
|
|
4
|
-
* Parses the request to derive arguments to be passed in for the Application
|
|
5
|
-
* controller method
|
|
6
|
-
*
|
|
7
|
-
* @param request Incoming HTTP request
|
|
8
|
-
* @param operationSpec Swagger spec defined in the controller
|
|
9
|
-
* @param pathParams Path parameters in incoming HTTP request
|
|
10
|
-
*/
|
|
11
|
-
export declare function parseOperationArgs(request: ParsedRequest, operationSpec: OperationObject, pathParams: PathParameterValues): Promise<OperationArgs>;
|
package/lib/parser.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/core
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const _1 = require("./");
|
|
8
|
-
const promisify_1 = require("./promisify");
|
|
9
|
-
const jsonBody = require('body/json');
|
|
10
|
-
// tslint:enable:no-any
|
|
11
|
-
const parseJsonBody = promisify_1.promisify(jsonBody);
|
|
12
|
-
/**
|
|
13
|
-
* Get the content-type header value from the request
|
|
14
|
-
* @param req Http request
|
|
15
|
-
*/
|
|
16
|
-
function getContentType(req) {
|
|
17
|
-
const val = req.headers['content-type'];
|
|
18
|
-
if (typeof val === 'string') {
|
|
19
|
-
return val;
|
|
20
|
-
}
|
|
21
|
-
else if (Array.isArray(val)) {
|
|
22
|
-
// Assume only one value is present
|
|
23
|
-
return val[0];
|
|
24
|
-
}
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Parses the request to derive arguments to be passed in for the Application
|
|
29
|
-
* controller method
|
|
30
|
-
*
|
|
31
|
-
* @param request Incoming HTTP request
|
|
32
|
-
* @param operationSpec Swagger spec defined in the controller
|
|
33
|
-
* @param pathParams Path parameters in incoming HTTP request
|
|
34
|
-
*/
|
|
35
|
-
async function parseOperationArgs(request, operationSpec, pathParams) {
|
|
36
|
-
const args = [];
|
|
37
|
-
const body = await loadRequestBodyIfNeeded(operationSpec, request);
|
|
38
|
-
return buildOperationArguments(operationSpec, request, pathParams, body);
|
|
39
|
-
}
|
|
40
|
-
exports.parseOperationArgs = parseOperationArgs;
|
|
41
|
-
function loadRequestBodyIfNeeded(operationSpec, request) {
|
|
42
|
-
if (!hasArgumentsFromBody(operationSpec))
|
|
43
|
-
return Promise.resolve();
|
|
44
|
-
const contentType = getContentType(request);
|
|
45
|
-
if (contentType && !/json/.test(contentType)) {
|
|
46
|
-
const err = new _1.HttpErrors.UnsupportedMediaType(`Content-type ${contentType} is not supported.`);
|
|
47
|
-
return Promise.reject(err);
|
|
48
|
-
}
|
|
49
|
-
return parseJsonBody(request).catch((err) => {
|
|
50
|
-
err.statusCode = 400;
|
|
51
|
-
return Promise.reject(err);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function hasArgumentsFromBody(operationSpec) {
|
|
55
|
-
if (!operationSpec.parameters || !operationSpec.parameters.length)
|
|
56
|
-
return false;
|
|
57
|
-
for (const paramSpec of operationSpec.parameters) {
|
|
58
|
-
if ('$ref' in paramSpec)
|
|
59
|
-
continue;
|
|
60
|
-
const source = paramSpec.in;
|
|
61
|
-
if (source === 'formData' || source === 'body')
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
function buildOperationArguments(operationSpec, request, pathParams, body) {
|
|
67
|
-
const args = [];
|
|
68
|
-
for (const paramSpec of operationSpec.parameters || []) {
|
|
69
|
-
if ('$ref' in paramSpec) {
|
|
70
|
-
// TODO(bajtos) implement $ref parameters
|
|
71
|
-
throw new Error('$ref parameters are not supported yet.');
|
|
72
|
-
}
|
|
73
|
-
const spec = paramSpec;
|
|
74
|
-
switch (spec.in) {
|
|
75
|
-
case 'query':
|
|
76
|
-
args.push(request.query[spec.name]);
|
|
77
|
-
break;
|
|
78
|
-
case 'path':
|
|
79
|
-
args.push(pathParams[spec.name]);
|
|
80
|
-
break;
|
|
81
|
-
case 'header':
|
|
82
|
-
args.push(request.headers[spec.name.toLowerCase()]);
|
|
83
|
-
break;
|
|
84
|
-
case 'formData':
|
|
85
|
-
args.push(body ? body[spec.name] : undefined);
|
|
86
|
-
break;
|
|
87
|
-
case 'body':
|
|
88
|
-
args.push(body);
|
|
89
|
-
break;
|
|
90
|
-
default:
|
|
91
|
-
throw new _1.HttpErrors.NotImplemented('Parameters with "in: ' + spec.in + '" are not supported yet.');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return args;
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=parser.js.map
|
package/lib/parser.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parser.js","sourceRoot":"","sources":["../src/parser.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;AAGhE,yBAA8B;AAE9B,2CAAsC;AAatC,MAAM,QAAQ,GAAe,OAAO,CAAC,WAAW,CAAC,CAAC;AAIlD,uBAAuB;AAEvB,MAAM,aAAa,GAA+C,qBAAS,CACzE,QAAQ,CACT,CAAC;AAEF;;;GAGG;AACH,wBAAwB,GAAkB;IACxC,MAAM,GAAG,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AC,CAAC,CAAC;gBACjC,KAAK,CAAC;YACR,KAAK,QAAQ;gBACX,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;gBACpD,KAAK,CAAC;YACR,KAAK,UAAU;gBACb,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;gBAC9C,KAAK,CAAC;YACR,KAAK,MAAM;gBACT,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAChB,KAAK,CAAC;YACR;gBACE,MAAM,IAAI,aAAU,CAAC,cAAc,CACjC,uBAAuB,GAAG,IAAI,CAAC,EAAE,GAAG,0BAA0B,CAC/D,CAAC;QACN,CAAC;IACH,CAAC;IACD,MAAM,CAAC,IAAI,CAAC;AACd,CAAC"}
|
package/lib/promisify.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export declare function promisify<T>(func: (callback: (err: any, result: T) => void) => void): () => Promise<T>;
|
|
2
|
-
export declare function promisify<T, A1>(func: (arg1: A1, callback: (err: any, result: T) => void) => void): (arg1: A1) => Promise<T>;
|
|
3
|
-
export declare function promisify<T, A1, A2>(func: (arg1: A1, arg2: A2, callback: (err: any, result: T) => void) => void): (arg1: A1, arg2: A2) => Promise<T>;
|
package/lib/promisify.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/core
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
// TODO(bajtos) Move this file to a standalone module, or find an existing
|
|
8
|
-
// npm module that we could use instead. Just make sure the existing
|
|
9
|
-
// module is using native utils.promisify() when available.
|
|
10
|
-
// tslint:disable:no-any
|
|
11
|
-
const util = require("util");
|
|
12
|
-
const nativePromisify = util.promisify;
|
|
13
|
-
function promisify(func) {
|
|
14
|
-
if (nativePromisify)
|
|
15
|
-
return nativePromisify(func);
|
|
16
|
-
// The simplest implementation of Promisify
|
|
17
|
-
return (...args) => {
|
|
18
|
-
return new Promise((resolve, reject) => {
|
|
19
|
-
try {
|
|
20
|
-
func(...args, (err, result) => {
|
|
21
|
-
if (err)
|
|
22
|
-
reject(err);
|
|
23
|
-
else
|
|
24
|
-
resolve(result);
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
reject(err);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
exports.promisify = promisify;
|
|
34
|
-
//# sourceMappingURL=promisify.js.map
|
package/lib/promisify.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"promisify.js","sourceRoot":"","sources":["../src/promisify.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;AAEhE,0EAA0E;AAC1E,oEAAoE;AACpE,2DAA2D;AAE3D,wBAAwB;AAExB,6BAA6B;AAE7B,MAAM,eAAe,GAAI,IAAY,CAAC,SAAS,CAAC;AAYhD,mBACE,IAA8B;IAE9B,EAAE,CAAC,CAAC,eAAe,CAAC;QAAC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAElD,2CAA2C;IAC3C,MAAM,CAAC,CAAC,GAAG,IAAI;QACb,MAAM,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM;YACjC,IAAI,CAAC;gBACH,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC,GAAS,EAAE,MAAY;oBACpC,EAAE,CAAC,CAAC,GAAG,CAAC;wBAAC,MAAM,CAAC,GAAG,CAAC,CAAC;oBACrB,IAAI;wBAAC,OAAO,CAAC,MAAM,CAAC,CAAC;gBACvB,CAAC,CAAC,CAAC;YACL,CAAC;YAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBACb,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAlBD,8BAkBC"}
|
package/lib/router/metadata.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { OpenApiSpec } from '@loopback/openapi-spec';
|
|
2
|
-
/**
|
|
3
|
-
* Decorate the given Controller constructor with metadata describing
|
|
4
|
-
* the HTTP/REST API the Controller implements/provides.
|
|
5
|
-
*
|
|
6
|
-
* @param {OpenApiSpec} spec OpenAPI specification describing the endpoints
|
|
7
|
-
* handled by this controller
|
|
8
|
-
*
|
|
9
|
-
* @decorator
|
|
10
|
-
*/
|
|
11
|
-
export declare function api(spec: OpenApiSpec): (constructor: Function) => void;
|
|
12
|
-
export declare function getApiSpec(constructor: Function): OpenApiSpec;
|
package/lib/router/metadata.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright IBM Corp. 2017. All Rights Reserved.
|
|
3
|
-
// Node module: @loopback/core
|
|
4
|
-
// This file is licensed under the MIT License.
|
|
5
|
-
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const assert = require("assert");
|
|
8
|
-
const context_1 = require("@loopback/context");
|
|
9
|
-
/**
|
|
10
|
-
* Decorate the given Controller constructor with metadata describing
|
|
11
|
-
* the HTTP/REST API the Controller implements/provides.
|
|
12
|
-
*
|
|
13
|
-
* @param {OpenApiSpec} spec OpenAPI specification describing the endpoints
|
|
14
|
-
* handled by this controller
|
|
15
|
-
*
|
|
16
|
-
* @decorator
|
|
17
|
-
*/
|
|
18
|
-
function api(spec) {
|
|
19
|
-
return function (constructor) {
|
|
20
|
-
assert(typeof constructor === 'function', 'The @api decorator can be applied to constructors only.');
|
|
21
|
-
context_1.Reflector.defineMetadata('loopback:api-spec', spec, constructor);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.api = api;
|
|
25
|
-
// TODO(bajtos) Add unit-tests
|
|
26
|
-
function getApiSpec(constructor) {
|
|
27
|
-
return context_1.Reflector.getMetadata('loopback:api-spec', constructor);
|
|
28
|
-
}
|
|
29
|
-
exports.getApiSpec = getApiSpec;
|
|
30
|
-
//# sourceMappingURL=metadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../../src/router/metadata.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;AAEhE,iCAAiC;AACjC,+CAA4C;AAI5C;;;;;;;;GAQG;AACH,aAAoB,IAAiB;IACnC,MAAM,CAAC,UAAS,WAAqB;QACnC,MAAM,CACJ,OAAO,WAAW,KAAK,UAAU,EACjC,yDAAyD,CAC1D,CAAC;QACF,mBAAS,CAAC,cAAc,CAAC,mBAAmB,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;IACnE,CAAC,CAAC;AACJ,CAAC;AARD,kBAQC;AAED,8BAA8B;AAC9B,oBAA2B,WAAqB;IAC9C,MAAM,CAAC,mBAAS,CAAC,WAAW,CAAC,mBAAmB,EAAE,WAAW,CAAC,CAAC;AACjE,CAAC;AAFD,gCAEC"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { OpenApiSpec, OperationObject } from '@loopback/openapi-spec';
|
|
3
|
-
import { ServerRequest } from 'http';
|
|
4
|
-
import { ParsedRequest, PathParameterValues } from '../internal-types';
|
|
5
|
-
export declare function parseRequestUrl(request: ServerRequest): ParsedRequest;
|
|
6
|
-
export declare class RoutingTable<ControllerType> {
|
|
7
|
-
private readonly _routes;
|
|
8
|
-
registerController(controller: ControllerType, spec: OpenApiSpec): void;
|
|
9
|
-
find(request: ParsedRequest): ResolvedRoute<ControllerType> | undefined;
|
|
10
|
-
}
|
|
11
|
-
export interface ResolvedRoute<ControllerType> {
|
|
12
|
-
readonly controller: ControllerType;
|
|
13
|
-
readonly methodName: string;
|
|
14
|
-
readonly spec: OperationObject;
|
|
15
|
-
readonly pathParams: PathParameterValues;
|
|
16
|
-
}
|