@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/lib6/http-handler.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-handler.js","sourceRoot":"","sources":["../src/http-handler.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;AAEhE,+CAA0C;AAI1C,0CAA0C;AAG1C,0DAAqE;AAQrE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,4BAA4B,CAAC,CAAC;AAE7D;IAQE,YAAsB,YAAqB;QAArB,iBAAY,GAAZ,YAAY,CAAS;QAPjC,YAAO,GAAyB,IAAI,4BAAY,EAAU,CAAC;QAQnE,IAAI,CAAC,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACnE,CAAC;IAED,kBAAkB,CAAC,IAAY,EAAE,IAAiB;QAChD,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEe,cAAc,CAC5B,OAAsB,EACtB,QAAwB;;YAExB,MAAM,aAAa,GAAkB,+BAAe,CAAC,OAAO,CAAC,CAAC;YAC9D,MAAM,cAAc,GAAG,IAAI,CAAC,qBAAqB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAErE,IAAI,CAAC,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,IAAI,CAAC,yBAAyB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;gBACjD,OAAO,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;gBAElE,MAAM,CAAC,KAAK,CAAC;YACf,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAES,iBAAiB,CAAC,OAAgB;QAC1C,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC;YAC1C,MAAM,CAAC,CACL,cAAsB,EACtB,MAAc,EACd,IAAmB;gBAEnB,MAAM,UAAU,GAAiC,MAAM,OAAO,CAAC,GAAG,CAChE,cAAc,CACf,CAAC;gBACF,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;gBACjD,MAAM,CAAC,MAAM,CAAC;YAChB,CAAC,CAAA,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA/ED,kCA+EC"}
|
package/lib6/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/lib6/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/lib6/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/lib6/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;
|
|
@@ -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/lib6/keys.d.ts
DELETED
package/lib6/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/lib6/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/lib6/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/lib6/parser.js
DELETED
|
@@ -1,106 +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
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
7
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
8
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
9
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
10
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
11
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const _1 = require("./");
|
|
16
|
-
const promisify_1 = require("./promisify");
|
|
17
|
-
const jsonBody = require('body/json');
|
|
18
|
-
// tslint:enable:no-any
|
|
19
|
-
const parseJsonBody = promisify_1.promisify(jsonBody);
|
|
20
|
-
/**
|
|
21
|
-
* Get the content-type header value from the request
|
|
22
|
-
* @param req Http request
|
|
23
|
-
*/
|
|
24
|
-
function getContentType(req) {
|
|
25
|
-
const val = req.headers['content-type'];
|
|
26
|
-
if (typeof val === 'string') {
|
|
27
|
-
return val;
|
|
28
|
-
}
|
|
29
|
-
else if (Array.isArray(val)) {
|
|
30
|
-
// Assume only one value is present
|
|
31
|
-
return val[0];
|
|
32
|
-
}
|
|
33
|
-
return undefined;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Parses the request to derive arguments to be passed in for the Application
|
|
37
|
-
* controller method
|
|
38
|
-
*
|
|
39
|
-
* @param request Incoming HTTP request
|
|
40
|
-
* @param operationSpec Swagger spec defined in the controller
|
|
41
|
-
* @param pathParams Path parameters in incoming HTTP request
|
|
42
|
-
*/
|
|
43
|
-
function parseOperationArgs(request, operationSpec, pathParams) {
|
|
44
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
const args = [];
|
|
46
|
-
const body = yield loadRequestBodyIfNeeded(operationSpec, request);
|
|
47
|
-
return buildOperationArguments(operationSpec, request, pathParams, body);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
exports.parseOperationArgs = parseOperationArgs;
|
|
51
|
-
function loadRequestBodyIfNeeded(operationSpec, request) {
|
|
52
|
-
if (!hasArgumentsFromBody(operationSpec))
|
|
53
|
-
return Promise.resolve();
|
|
54
|
-
const contentType = getContentType(request);
|
|
55
|
-
if (contentType && !/json/.test(contentType)) {
|
|
56
|
-
const err = new _1.HttpErrors.UnsupportedMediaType(`Content-type ${contentType} is not supported.`);
|
|
57
|
-
return Promise.reject(err);
|
|
58
|
-
}
|
|
59
|
-
return parseJsonBody(request).catch((err) => {
|
|
60
|
-
err.statusCode = 400;
|
|
61
|
-
return Promise.reject(err);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function hasArgumentsFromBody(operationSpec) {
|
|
65
|
-
if (!operationSpec.parameters || !operationSpec.parameters.length)
|
|
66
|
-
return false;
|
|
67
|
-
for (const paramSpec of operationSpec.parameters) {
|
|
68
|
-
if ('$ref' in paramSpec)
|
|
69
|
-
continue;
|
|
70
|
-
const source = paramSpec.in;
|
|
71
|
-
if (source === 'formData' || source === 'body')
|
|
72
|
-
return true;
|
|
73
|
-
}
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
function buildOperationArguments(operationSpec, request, pathParams, body) {
|
|
77
|
-
const args = [];
|
|
78
|
-
for (const paramSpec of operationSpec.parameters || []) {
|
|
79
|
-
if ('$ref' in paramSpec) {
|
|
80
|
-
// TODO(bajtos) implement $ref parameters
|
|
81
|
-
throw new Error('$ref parameters are not supported yet.');
|
|
82
|
-
}
|
|
83
|
-
const spec = paramSpec;
|
|
84
|
-
switch (spec.in) {
|
|
85
|
-
case 'query':
|
|
86
|
-
args.push(request.query[spec.name]);
|
|
87
|
-
break;
|
|
88
|
-
case 'path':
|
|
89
|
-
args.push(pathParams[spec.name]);
|
|
90
|
-
break;
|
|
91
|
-
case 'header':
|
|
92
|
-
args.push(request.headers[spec.name.toLowerCase()]);
|
|
93
|
-
break;
|
|
94
|
-
case 'formData':
|
|
95
|
-
args.push(body ? body[spec.name] : undefined);
|
|
96
|
-
break;
|
|
97
|
-
case 'body':
|
|
98
|
-
args.push(body);
|
|
99
|
-
break;
|
|
100
|
-
default:
|
|
101
|
-
throw new _1.HttpErrors.NotImplemented('Parameters with "in: ' + spec.in + '" are not supported yet.');
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return args;
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=parser.js.map
|
package/lib6/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,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACxC,EAAE,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC;IACb,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9B,mCAAmC;QACnC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IACD,MAAM,CAAC,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;;GAOG;AACH,4BACE,OAAsB,EACtB,aAA8B,EAC9B,UAA+B;;QAE/B,MAAM,IAAI,GAAkB,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,MAAM,uBAAuB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACnE,MAAM,CAAC,uBAAuB,CAAC,aAAa,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,CAAC,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|
|
|
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/lib6/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/lib6/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"}
|
|
@@ -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/lib6/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
|
-
}
|
|
@@ -1,97 +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 url = require("url");
|
|
9
|
-
const debug = require('debug')('loopback:core:routing-table');
|
|
10
|
-
// TODO(bajtos) Refactor this code to use Trie-based lookup,
|
|
11
|
-
// e.g. via wayfarer/trie or find-my-way
|
|
12
|
-
const pathToRegexp = require("path-to-regexp");
|
|
13
|
-
function parseRequestUrl(request) {
|
|
14
|
-
// TODO(bajtos) The following parsing can be skipped when the router
|
|
15
|
-
// is mounted on an express app
|
|
16
|
-
const parsedRequest = request;
|
|
17
|
-
const parsedUrl = url.parse(parsedRequest.url, true);
|
|
18
|
-
parsedRequest.path = parsedUrl.pathname || '/';
|
|
19
|
-
parsedRequest.query = parsedUrl.query;
|
|
20
|
-
return parsedRequest;
|
|
21
|
-
}
|
|
22
|
-
exports.parseRequestUrl = parseRequestUrl;
|
|
23
|
-
class RoutingTable {
|
|
24
|
-
constructor() {
|
|
25
|
-
this._routes = [];
|
|
26
|
-
}
|
|
27
|
-
registerController(controller, spec) {
|
|
28
|
-
assert(typeof spec === 'object' && !!spec, 'API specification must be a non-null object');
|
|
29
|
-
if (!spec.paths || !Object.keys(spec.paths).length) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
debug('Registering Controller with API', spec);
|
|
33
|
-
for (const path in spec.paths) {
|
|
34
|
-
for (const verb in spec.paths[path]) {
|
|
35
|
-
const opSpec = spec.paths[path][verb];
|
|
36
|
-
// TODO(bajtos) handle the case where opSpec.parameters contains $ref
|
|
37
|
-
debug(' %s %s -> %s(%s)', verb, path, opSpec['x-operation-name'], (opSpec.parameters || [])
|
|
38
|
-
.map(p => p.name)
|
|
39
|
-
.join(', '));
|
|
40
|
-
this._routes.push(new RouteEntry(path, verb, opSpec, controller));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
find(request) {
|
|
45
|
-
for (const entry of this._routes) {
|
|
46
|
-
const match = entry.match(request);
|
|
47
|
-
if (match)
|
|
48
|
-
return match;
|
|
49
|
-
}
|
|
50
|
-
return undefined;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.RoutingTable = RoutingTable;
|
|
54
|
-
class RouteEntry {
|
|
55
|
-
constructor(path, verb, _spec, _controller) {
|
|
56
|
-
this._spec = _spec;
|
|
57
|
-
this._controller = _controller;
|
|
58
|
-
this._verb = verb.toLowerCase();
|
|
59
|
-
// In Swagger, path parameters are wrapped in `{}`.
|
|
60
|
-
// In Express.js, path parameters are prefixed with `:`
|
|
61
|
-
path = path.replace(/{([^}]*)}(\/|$)/g, ':$1$2');
|
|
62
|
-
this._pathRegexp = pathToRegexp(path, [], { strict: false, end: true });
|
|
63
|
-
}
|
|
64
|
-
match(request) {
|
|
65
|
-
debug('trying endpoint', this);
|
|
66
|
-
if (this._verb !== request.method.toLowerCase()) {
|
|
67
|
-
debug(' -> verb mismatch');
|
|
68
|
-
return undefined;
|
|
69
|
-
}
|
|
70
|
-
const match = this._pathRegexp.exec(request.path);
|
|
71
|
-
if (!match) {
|
|
72
|
-
debug(' -> path mismatch');
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
const pathParams = this._buildPathParams(match);
|
|
76
|
-
debug(' -> found with params: %j', pathParams);
|
|
77
|
-
return this._createResolvedRoute(pathParams);
|
|
78
|
-
}
|
|
79
|
-
_createResolvedRoute(pathParams) {
|
|
80
|
-
return {
|
|
81
|
-
controller: this._controller,
|
|
82
|
-
methodName: this._spec['x-operation-name'],
|
|
83
|
-
spec: this._spec,
|
|
84
|
-
pathParams: pathParams,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
_buildPathParams(pathMatch) {
|
|
88
|
-
const pathParams = Object.create(null);
|
|
89
|
-
for (const ix in this._pathRegexp.keys) {
|
|
90
|
-
const key = this._pathRegexp.keys[ix];
|
|
91
|
-
const matchIndex = +ix + 1;
|
|
92
|
-
pathParams[key.name] = pathMatch[matchIndex];
|
|
93
|
-
}
|
|
94
|
-
return pathParams;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=routing-table.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"routing-table.js","sourceRoot":"","sources":["../../src/router/routing-table.ts"],"names":[],"mappings":";AAAA,iDAAiD;A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AAM,CAAC,UAAU,CAAC;IACpB,CAAC;CACF"}
|
package/lib6/sequence.d.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="http-errors" />
|
|
3
|
-
import { ServerRequest, ServerResponse } from 'http';
|
|
4
|
-
import { FindRoute, InvokeMethod, LogError, OperationRetval, ParsedRequest } from './internal-types';
|
|
5
|
-
import { HttpError } from 'http-errors';
|
|
6
|
-
/**
|
|
7
|
-
* The default implementation of Sequence.
|
|
8
|
-
*
|
|
9
|
-
* This class implements default Sequence for the LoopBack framework.
|
|
10
|
-
* Default sequence is used if user hasn't defined their own Sequence
|
|
11
|
-
* for their application.
|
|
12
|
-
*
|
|
13
|
-
* Sequence constructor() and run() methods are invoked from [[http-handler]]
|
|
14
|
-
* when the API request comes in. User defines APIs in their Application
|
|
15
|
-
* Controller class.
|
|
16
|
-
*
|
|
17
|
-
* User can bind their own Sequence to app as shown below
|
|
18
|
-
* ```ts
|
|
19
|
-
* app.bind('sequence').toClass(MySequence);
|
|
20
|
-
* ```
|
|
21
|
-
*/
|
|
22
|
-
export declare class Sequence {
|
|
23
|
-
protected findRoute: FindRoute;
|
|
24
|
-
protected invoke: InvokeMethod;
|
|
25
|
-
protected logError: LogError;
|
|
26
|
-
/**
|
|
27
|
-
* Constructor: Injects findRoute, invokeMethod & logError
|
|
28
|
-
* methods as promises.
|
|
29
|
-
*
|
|
30
|
-
* @param findRoute Finds the appropriate controller method,
|
|
31
|
-
* spec and args for invocation
|
|
32
|
-
* @param invoke Invokes the method
|
|
33
|
-
* @param logError Logs error
|
|
34
|
-
*/
|
|
35
|
-
constructor(findRoute: FindRoute, invoke: InvokeMethod, logError: LogError);
|
|
36
|
-
/**
|
|
37
|
-
* Runs the default sequence. Given a request and response, running the
|
|
38
|
-
* sequence will produce a response or an error.
|
|
39
|
-
*
|
|
40
|
-
* Default sequence executes these steps
|
|
41
|
-
* - Finds the appropriate controller method, swagger spec
|
|
42
|
-
* and args for invocation
|
|
43
|
-
* - Parses HTTP request to get API argument list
|
|
44
|
-
* - Invokes the API which is defined in the Application Controller
|
|
45
|
-
* - Writes the result from API into the HTTP response
|
|
46
|
-
* - Error is caught and logged using 'logError' if any of the above steps
|
|
47
|
-
* in the sequence fails with an error.
|
|
48
|
-
* @param req Parsed incoming HTTP request
|
|
49
|
-
* @param res HTTP server response with result from Application controller
|
|
50
|
-
* method invocation
|
|
51
|
-
*/
|
|
52
|
-
run(req: ParsedRequest, res: ServerResponse): Promise<void>;
|
|
53
|
-
sendResponse(response: ServerResponse, result: OperationRetval): void;
|
|
54
|
-
sendError(res: ServerResponse, req: ServerRequest, err: HttpError): void;
|
|
55
|
-
}
|
package/lib6/sequence.js
DELETED
|
@@ -1,109 +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
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
7
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
9
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
10
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
11
|
-
};
|
|
12
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
13
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
14
|
-
};
|
|
15
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
16
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
17
|
-
};
|
|
18
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
const debug = require('debug')('loopback:core:sequence');
|
|
28
|
-
const context_1 = require("@loopback/context");
|
|
29
|
-
const parser_1 = require("./parser");
|
|
30
|
-
const writer_1 = require("./writer");
|
|
31
|
-
/**
|
|
32
|
-
* The default implementation of Sequence.
|
|
33
|
-
*
|
|
34
|
-
* This class implements default Sequence for the LoopBack framework.
|
|
35
|
-
* Default sequence is used if user hasn't defined their own Sequence
|
|
36
|
-
* for their application.
|
|
37
|
-
*
|
|
38
|
-
* Sequence constructor() and run() methods are invoked from [[http-handler]]
|
|
39
|
-
* when the API request comes in. User defines APIs in their Application
|
|
40
|
-
* Controller class.
|
|
41
|
-
*
|
|
42
|
-
* User can bind their own Sequence to app as shown below
|
|
43
|
-
* ```ts
|
|
44
|
-
* app.bind('sequence').toClass(MySequence);
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
let Sequence = class Sequence {
|
|
48
|
-
/**
|
|
49
|
-
* Constructor: Injects findRoute, invokeMethod & logError
|
|
50
|
-
* methods as promises.
|
|
51
|
-
*
|
|
52
|
-
* @param findRoute Finds the appropriate controller method,
|
|
53
|
-
* spec and args for invocation
|
|
54
|
-
* @param invoke Invokes the method
|
|
55
|
-
* @param logError Logs error
|
|
56
|
-
*/
|
|
57
|
-
constructor(findRoute, invoke, logError) {
|
|
58
|
-
this.findRoute = findRoute;
|
|
59
|
-
this.invoke = invoke;
|
|
60
|
-
this.logError = logError;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Runs the default sequence. Given a request and response, running the
|
|
64
|
-
* sequence will produce a response or an error.
|
|
65
|
-
*
|
|
66
|
-
* Default sequence executes these steps
|
|
67
|
-
* - Finds the appropriate controller method, swagger spec
|
|
68
|
-
* and args for invocation
|
|
69
|
-
* - Parses HTTP request to get API argument list
|
|
70
|
-
* - Invokes the API which is defined in the Application Controller
|
|
71
|
-
* - Writes the result from API into the HTTP response
|
|
72
|
-
* - Error is caught and logged using 'logError' if any of the above steps
|
|
73
|
-
* in the sequence fails with an error.
|
|
74
|
-
* @param req Parsed incoming HTTP request
|
|
75
|
-
* @param res HTTP server response with result from Application controller
|
|
76
|
-
* method invocation
|
|
77
|
-
*/
|
|
78
|
-
run(req, res) {
|
|
79
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
try {
|
|
81
|
-
const { controller, methodName, spec, pathParams } = this.findRoute(req);
|
|
82
|
-
const args = yield parser_1.parseOperationArgs(req, spec, pathParams);
|
|
83
|
-
const result = yield this.invoke(controller, methodName, args);
|
|
84
|
-
debug('%s.%s() result -', controller, methodName, result);
|
|
85
|
-
this.sendResponse(res, result);
|
|
86
|
-
}
|
|
87
|
-
catch (err) {
|
|
88
|
-
this.sendError(res, req, err);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
sendResponse(response, result) {
|
|
93
|
-
writer_1.writeResultToResponse(response, result);
|
|
94
|
-
}
|
|
95
|
-
sendError(res, req, err) {
|
|
96
|
-
const statusCode = err.statusCode || err.status || 500;
|
|
97
|
-
res.statusCode = statusCode;
|
|
98
|
-
res.end();
|
|
99
|
-
this.logError(err, statusCode, req);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
Sequence = __decorate([
|
|
103
|
-
__param(0, context_1.inject('findRoute')),
|
|
104
|
-
__param(1, context_1.inject('invokeMethod')),
|
|
105
|
-
__param(2, context_1.inject('logError')),
|
|
106
|
-
__metadata("design:paramtypes", [Function, Function, Function])
|
|
107
|
-
], Sequence);
|
|
108
|
-
exports.Sequence = Sequence;
|
|
109
|
-
//# sourceMappingURL=sequence.js.map
|
package/lib6/sequence.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sequence.js","sourceRoot":"","sources":["../src/sequence.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,8BAA8B;AAC9B,+CAA+C;AAC/C,gEAAgE;;;;;;;;;;;;;;;;;;;;;;AAEhE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,wBAAwB,CAAC,CAAC;AAEzD,+CAAyC;AAQzC,qCAA4C;AAC5C,qCAA+C;AAE/C;;;;;;;;;;;;;;;GAeG;AACH,IAAa,QAAQ,GAArB;IACG;;;;;;;;MAQE;IACH,YACiC,SAAoB,EACjB,MAAoB,EACxB,QAAkB;QAFjB,cAAS,GAAT,SAAS,CAAW;QACjB,WAAM,GAAN,MAAM,CAAc;QACxB,aAAQ,GAAR,QAAQ,CAAU;IAC/C,CAAC;IAGJ;;;;;;;;;;;;;;;OAeG;IACG,GAAG,CAAC,GAAkB,EAAE,GAAmB;;YAC/C,IAAI,CAAC;gBACH,MAAM,EAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;gBACvE,MAAM,IAAI,GAAG,MAAM,2BAAkB,CAAC,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;gBAC7D,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;gBAC/D,KAAK,CAAC,kBAAkB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;gBAC1D,IAAI,CAAC,YAAY,CAAC,GAA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