@spinajs/http 2.0.46 → 2.0.49
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/README.md +11 -11
- package/lib/config/http.d.ts +1 -0
- package/lib/config/http.d.ts.map +1 -0
- package/lib/config/http.js +5 -7
- package/lib/config/http.js.map +1 -1
- package/lib/controllers.d.ts +4 -3
- package/lib/controllers.d.ts.map +1 -0
- package/lib/controllers.js +37 -65
- package/lib/controllers.js.map +1 -1
- package/lib/decorators.d.ts +3 -2
- package/lib/decorators.d.ts.map +1 -0
- package/lib/decorators.js +68 -100
- package/lib/decorators.js.map +1 -1
- package/lib/exceptions.d.ts +2 -0
- package/lib/exceptions.d.ts.map +1 -0
- package/lib/exceptions.js +1 -0
- package/lib/index.d.ts +9 -8
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +8 -24
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts +3 -2
- package/lib/interfaces.d.ts.map +1 -0
- package/lib/interfaces.js +16 -24
- package/lib/interfaces.js.map +1 -1
- package/lib/middlewares/RequestId.d.ts +2 -1
- package/lib/middlewares/RequestId.d.ts.map +1 -0
- package/lib/middlewares/RequestId.js +7 -10
- package/lib/middlewares/RequestId.js.map +1 -1
- package/lib/middlewares/ResponseTime.d.ts +2 -1
- package/lib/middlewares/ResponseTime.d.ts.map +1 -0
- package/lib/middlewares/ResponseTime.js +5 -8
- package/lib/middlewares/ResponseTime.js.map +1 -1
- package/lib/response-methods/badRequest.d.ts +3 -1
- package/lib/response-methods/badRequest.d.ts.map +1 -0
- package/lib/response-methods/badRequest.js +4 -8
- package/lib/response-methods/badRequest.js.map +1 -1
- package/lib/response-methods/conflict.d.ts +3 -1
- package/lib/response-methods/conflict.d.ts.map +1 -0
- package/lib/response-methods/conflict.js +4 -8
- package/lib/response-methods/conflict.js.map +1 -1
- package/lib/response-methods/cookieResponse.d.ts +3 -1
- package/lib/response-methods/cookieResponse.d.ts.map +1 -0
- package/lib/response-methods/cookieResponse.js +8 -35
- package/lib/response-methods/cookieResponse.js.map +1 -1
- package/lib/response-methods/created.d.ts +3 -1
- package/lib/response-methods/created.d.ts.map +1 -0
- package/lib/response-methods/created.js +4 -8
- package/lib/response-methods/created.js.map +1 -1
- package/lib/response-methods/file.d.ts +2 -1
- package/lib/response-methods/file.d.ts.map +1 -0
- package/lib/response-methods/file.js +15 -46
- package/lib/response-methods/file.js.map +1 -1
- package/lib/response-methods/forbidden.d.ts +3 -1
- package/lib/response-methods/forbidden.d.ts.map +1 -0
- package/lib/response-methods/forbidden.js +4 -8
- package/lib/response-methods/forbidden.js.map +1 -1
- package/lib/response-methods/index.d.ts +14 -13
- package/lib/response-methods/index.d.ts.map +1 -0
- package/lib/response-methods/index.js +13 -29
- package/lib/response-methods/index.js.map +1 -1
- package/lib/response-methods/noContent.d.ts +3 -1
- package/lib/response-methods/noContent.d.ts.map +1 -0
- package/lib/response-methods/noContent.js +4 -8
- package/lib/response-methods/noContent.js.map +1 -1
- package/lib/response-methods/notAllowed.d.ts +3 -1
- package/lib/response-methods/notAllowed.d.ts.map +1 -0
- package/lib/response-methods/notAllowed.js +4 -8
- package/lib/response-methods/notAllowed.js.map +1 -1
- package/lib/response-methods/notFound.d.ts +3 -1
- package/lib/response-methods/notFound.d.ts.map +1 -0
- package/lib/response-methods/notFound.js +4 -8
- package/lib/response-methods/notFound.js.map +1 -1
- package/lib/response-methods/ok.d.ts +3 -1
- package/lib/response-methods/ok.d.ts.map +1 -0
- package/lib/response-methods/ok.js +4 -8
- package/lib/response-methods/ok.js.map +1 -1
- package/lib/response-methods/pug.d.ts +3 -1
- package/lib/response-methods/pug.d.ts.map +1 -0
- package/lib/response-methods/pug.js +4 -8
- package/lib/response-methods/pug.js.map +1 -1
- package/lib/response-methods/redirect.d.ts +2 -1
- package/lib/response-methods/redirect.d.ts.map +1 -0
- package/lib/response-methods/redirect.js +2 -6
- package/lib/response-methods/redirect.js.map +1 -1
- package/lib/response-methods/serverError.d.ts +3 -1
- package/lib/response-methods/serverError.d.ts.map +1 -0
- package/lib/response-methods/serverError.js +4 -8
- package/lib/response-methods/serverError.js.map +1 -1
- package/lib/response-methods/unauthorized.d.ts +3 -1
- package/lib/response-methods/unauthorized.d.ts.map +1 -0
- package/lib/response-methods/unauthorized.js +4 -8
- package/lib/response-methods/unauthorized.js.map +1 -1
- package/lib/responses.d.ts +2 -1
- package/lib/responses.d.ts.map +1 -0
- package/lib/responses.js +25 -55
- package/lib/responses.js.map +1 -1
- package/lib/route-args/ArgAsRequest.d.ts +3 -2
- package/lib/route-args/ArgAsRequest.d.ts.map +1 -0
- package/lib/route-args/ArgAsRequest.js +7 -10
- package/lib/route-args/ArgAsRequest.js.map +1 -1
- package/lib/route-args/ArgAsResponse.d.ts +3 -2
- package/lib/route-args/ArgAsResponse.d.ts.map +1 -0
- package/lib/route-args/ArgAsResponse.js +7 -10
- package/lib/route-args/ArgAsResponse.js.map +1 -1
- package/lib/route-args/ArgHydrator.d.ts +2 -1
- package/lib/route-args/ArgHydrator.d.ts.map +1 -0
- package/lib/route-args/ArgHydrator.js +1 -5
- package/lib/route-args/ArgHydrator.js.map +1 -1
- package/lib/route-args/FromBody.d.ts +3 -2
- package/lib/route-args/FromBody.d.ts.map +1 -0
- package/lib/route-args/FromBody.js +8 -11
- package/lib/route-args/FromBody.js.map +1 -1
- package/lib/route-args/FromCookie.d.ts +3 -2
- package/lib/route-args/FromCookie.d.ts.map +1 -0
- package/lib/route-args/FromCookie.js +12 -39
- package/lib/route-args/FromCookie.js.map +1 -1
- package/lib/route-args/FromDi.d.ts +3 -2
- package/lib/route-args/FromDi.d.ts.map +1 -0
- package/lib/route-args/FromDi.js +7 -10
- package/lib/route-args/FromDi.js.map +1 -1
- package/lib/route-args/FromForm.d.ts +4 -3
- package/lib/route-args/FromForm.d.ts.map +1 -0
- package/lib/route-args/FromForm.js +64 -54
- package/lib/route-args/FromForm.js.map +1 -1
- package/lib/route-args/FromHeaderArg.d.ts +3 -2
- package/lib/route-args/FromHeaderArg.d.ts.map +1 -0
- package/lib/route-args/FromHeaderArg.js +9 -12
- package/lib/route-args/FromHeaderArg.js.map +1 -1
- package/lib/route-args/FromParams.d.ts +3 -2
- package/lib/route-args/FromParams.d.ts.map +1 -0
- package/lib/route-args/FromParams.js +7 -10
- package/lib/route-args/FromParams.js.map +1 -1
- package/lib/route-args/FromQuery.d.ts +3 -2
- package/lib/route-args/FromQuery.d.ts.map +1 -0
- package/lib/route-args/FromQuery.js +7 -10
- package/lib/route-args/FromQuery.js.map +1 -1
- package/lib/route-args/RouteArgs.d.ts +2 -1
- package/lib/route-args/RouteArgs.d.ts.map +1 -0
- package/lib/route-args/RouteArgs.js +20 -27
- package/lib/route-args/RouteArgs.js.map +1 -1
- package/lib/route-args/index.d.ts +12 -11
- package/lib/route-args/index.d.ts.map +1 -0
- package/lib/route-args/index.js +11 -27
- package/lib/route-args/index.js.map +1 -1
- package/lib/schemas/RouteArgsSchemas.d.ts +1 -0
- package/lib/schemas/RouteArgsSchemas.d.ts.map +1 -0
- package/lib/schemas/RouteArgsSchemas.js +1 -4
- package/lib/schemas/RouteArgsSchemas.js.map +1 -1
- package/lib/server.d.ts +4 -3
- package/lib/server.d.ts.map +1 -0
- package/lib/server.js +45 -68
- package/lib/server.js.map +1 -1
- package/lib/transformers/PureTransformer.d.ts +2 -1
- package/lib/transformers/PureTransformer.d.ts.map +1 -0
- package/lib/transformers/PureTransformer.js +6 -9
- package/lib/transformers/PureTransformer.js.map +1 -1
- package/lib/transformers/index.d.ts +2 -1
- package/lib/transformers/index.d.ts.map +1 -0
- package/lib/transformers/index.js +1 -17
- package/lib/transformers/index.js.map +1 -1
- package/package.json +80 -81
- package/lib/static/favicon.ico +0 -0
- package/lib/static/style.css +0 -15
- package/lib/views/responses/badRequest.pug +0 -13
- package/lib/views/responses/conflict.pug +0 -13
- package/lib/views/responses/forbidden.pug +0 -13
- package/lib/views/responses/noContent.pug +0 -13
- package/lib/views/responses/not-allowed.pug +0 -13
- package/lib/views/responses/notFound.pug +0 -13
- package/lib/views/responses/ok.pug +0 -12
- package/lib/views/responses/serverError.pug +0 -13
- package/lib/views/responses/unauthorized.pug +0 -13
package/lib/responses.js
CHANGED
|
@@ -1,44 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.httpResponse = exports.htmlResponse = exports.textResponse = exports.jsonResponse = void 0;
|
|
27
|
-
const interfaces_1 = require("./interfaces");
|
|
28
|
-
const configuration_1 = require("@spinajs/configuration");
|
|
29
|
-
const di_1 = require("@spinajs/di");
|
|
30
|
-
const log_1 = require("@spinajs/log");
|
|
31
|
-
const randomstring = __importStar(require("randomstring"));
|
|
32
|
-
const templates_1 = require("@spinajs/templates");
|
|
1
|
+
import { HTTP_STATUS_CODE, HttpAcceptHeaders, DataTransformer } from './interfaces.js';
|
|
2
|
+
import { Configuration } from '@spinajs/configuration';
|
|
3
|
+
import { DI } from '@spinajs/di';
|
|
4
|
+
import { Log } from '@spinajs/log';
|
|
5
|
+
import * as randomstring from 'randomstring';
|
|
6
|
+
import { Templates } from '@spinajs/templates';
|
|
33
7
|
/**
|
|
34
8
|
* Sends data & sets proper header as json
|
|
35
9
|
*
|
|
36
10
|
* @param model - data to send
|
|
37
11
|
* @param status - status code
|
|
38
12
|
*/
|
|
39
|
-
function jsonResponse(model, status) {
|
|
13
|
+
export function jsonResponse(model, status) {
|
|
40
14
|
return (_req, res) => {
|
|
41
|
-
res.status(status ? status :
|
|
15
|
+
res.status(status ? status : HTTP_STATUS_CODE.OK);
|
|
42
16
|
if (model) {
|
|
43
17
|
res.json(model);
|
|
44
18
|
}
|
|
@@ -47,23 +21,21 @@ function jsonResponse(model, status) {
|
|
|
47
21
|
}
|
|
48
22
|
};
|
|
49
23
|
}
|
|
50
|
-
exports.jsonResponse = jsonResponse;
|
|
51
24
|
/**
|
|
52
25
|
* Sends data & sets proper header as json
|
|
53
26
|
*
|
|
54
27
|
* @param model - data to send
|
|
55
28
|
* @param status - status code
|
|
56
29
|
*/
|
|
57
|
-
function textResponse(model, status) {
|
|
30
|
+
export function textResponse(model, status) {
|
|
58
31
|
return (_req, res) => {
|
|
59
|
-
res.status(status ? status :
|
|
32
|
+
res.status(status ? status : HTTP_STATUS_CODE.OK);
|
|
60
33
|
if (model) {
|
|
61
34
|
res.set('Content-Type', 'text/plain');
|
|
62
35
|
res.send(JSON.stringify(model));
|
|
63
36
|
}
|
|
64
37
|
};
|
|
65
38
|
}
|
|
66
|
-
exports.textResponse = textResponse;
|
|
67
39
|
/**
|
|
68
40
|
* Sends html response & sets proper header. If template is not avaible, handles proper error rendering.
|
|
69
41
|
*
|
|
@@ -71,8 +43,8 @@ exports.textResponse = textResponse;
|
|
|
71
43
|
* @param model - data passed to template
|
|
72
44
|
* @param status - optional status code
|
|
73
45
|
*/
|
|
74
|
-
function htmlResponse(file, model, status) {
|
|
75
|
-
const cfg =
|
|
46
|
+
export function htmlResponse(file, model, status) {
|
|
47
|
+
const cfg = DI.get(Configuration);
|
|
76
48
|
return (req, res) => {
|
|
77
49
|
if (!req.accepts('html')) {
|
|
78
50
|
httpResponse({
|
|
@@ -80,33 +52,32 @@ function htmlResponse(file, model, status) {
|
|
|
80
52
|
message: 'invalid request content type',
|
|
81
53
|
code: 400,
|
|
82
54
|
},
|
|
83
|
-
},
|
|
55
|
+
}, HTTP_STATUS_CODE.BAD_REQUEST, 'responses/serverError.pug')(req, res);
|
|
84
56
|
return;
|
|
85
57
|
}
|
|
86
58
|
res.set('Content-Type', 'text/html');
|
|
87
59
|
_render(file, model, status).catch((err) => {
|
|
88
|
-
const log =
|
|
60
|
+
const log = DI.resolve(Log, ['http']);
|
|
89
61
|
log.warn(`Cannot render html file ${file}, error: ${err.message}:${err.stack}`, err);
|
|
90
62
|
// try to render server error response
|
|
91
|
-
_render('responses/serverError.pug', { error: err },
|
|
92
|
-
const log =
|
|
63
|
+
_render('responses/serverError.pug', { error: err }, HTTP_STATUS_CODE.INTERNAL_ERROR).catch((err2) => {
|
|
64
|
+
const log = DI.resolve(Log, ['http']);
|
|
93
65
|
// final fallback rendering error fails, we render embedded html error page
|
|
94
66
|
const ticketNo = randomstring.generate(7);
|
|
95
67
|
log.warn(`Cannot render pug file error: ${err2.message}, ticket: ${ticketNo}`, err);
|
|
96
|
-
res.status(
|
|
68
|
+
res.status(HTTP_STATUS_CODE.INTERNAL_ERROR);
|
|
97
69
|
res.send(cfg.get('http.FatalTemplate').replace('{ticket}', ticketNo));
|
|
98
70
|
});
|
|
99
71
|
});
|
|
100
72
|
function _render(f, m, c) {
|
|
101
|
-
const templateEngine =
|
|
73
|
+
const templateEngine = DI.get(Templates);
|
|
102
74
|
return templateEngine.render(f, m).then((content) => {
|
|
103
|
-
res.status(c ? c :
|
|
75
|
+
res.status(c ? c : HTTP_STATUS_CODE.OK);
|
|
104
76
|
res.send(content);
|
|
105
77
|
});
|
|
106
78
|
}
|
|
107
79
|
};
|
|
108
80
|
}
|
|
109
|
-
exports.htmlResponse = htmlResponse;
|
|
110
81
|
/**
|
|
111
82
|
* Default response handling. Checks `Accept` header & matches proper response
|
|
112
83
|
* For now its supports html & json responses
|
|
@@ -116,15 +87,15 @@ exports.htmlResponse = htmlResponse;
|
|
|
116
87
|
* @param template - template to render without extension eg. `views/responses/ok`. It will try to match .pug, .xml or whatever to match response
|
|
117
88
|
* to `Accept` header
|
|
118
89
|
*/
|
|
119
|
-
function httpResponse(model, code, template) {
|
|
120
|
-
const cfg =
|
|
90
|
+
export function httpResponse(model, code, template) {
|
|
91
|
+
const cfg = DI.get(Configuration);
|
|
121
92
|
const acceptedHeaders = cfg.get('http.AcceptHeaders');
|
|
122
|
-
const transformers =
|
|
93
|
+
const transformers = DI.resolve(Array.ofType(DataTransformer));
|
|
123
94
|
return (req, res) => {
|
|
124
|
-
if (req.accepts('html') && (acceptedHeaders &
|
|
95
|
+
if (req.accepts('html') && (acceptedHeaders & HttpAcceptHeaders.HTML) === HttpAcceptHeaders.HTML) {
|
|
125
96
|
htmlResponse(`${template}.pug`, model, code)(req, res);
|
|
126
97
|
}
|
|
127
|
-
else if (req.accepts('json') && (acceptedHeaders &
|
|
98
|
+
else if (req.accepts('json') && (acceptedHeaders & HttpAcceptHeaders.JSON) === HttpAcceptHeaders.JSON) {
|
|
128
99
|
if (req.headers['x-data-transform']) {
|
|
129
100
|
const transformer = transformers.find((t) => t.Type === req.headers['x-data-transform']);
|
|
130
101
|
if (transformer) {
|
|
@@ -136,7 +107,7 @@ function httpResponse(model, code, template) {
|
|
|
136
107
|
message: "invalid data transformer, remove header 'x-data-transform' to return raw data or set proper data transformer",
|
|
137
108
|
code: 400,
|
|
138
109
|
},
|
|
139
|
-
},
|
|
110
|
+
}, HTTP_STATUS_CODE.BAD_REQUEST)(req, res);
|
|
140
111
|
}
|
|
141
112
|
}
|
|
142
113
|
else {
|
|
@@ -148,5 +119,4 @@ function httpResponse(model, code, template) {
|
|
|
148
119
|
}
|
|
149
120
|
};
|
|
150
121
|
}
|
|
151
|
-
exports.httpResponse = httpResponse;
|
|
152
122
|
//# sourceMappingURL=responses.js.map
|
package/lib/responses.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../src/responses.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"responses.js","sourceRoot":"","sources":["../src/responses.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAQ,GAAG,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,YAAY,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,MAAyB;IAChE,OAAO,CAAC,IAAqB,EAAE,GAAqB,EAAE,EAAE;QACtD,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAElD,IAAI,KAAK,EAAE;YACT,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACjB;aAAM;YACL,GAAG,CAAC,IAAI,EAAE,CAAC;SACZ;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,KAAU,EAAE,MAAyB;IAChE,OAAO,CAAC,IAAqB,EAAE,GAAqB,EAAE,EAAE;QACtD,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;QAElD,IAAI,KAAK,EAAE;YACT,GAA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ameter, ParameterType, IRouteCall, Request } from '../interfaces';
|
|
1
|
+
import { RouteArgs } from './RouteArgs.js';
|
|
2
|
+
import { IRouteParameter, ParameterType, IRouteCall, Request } from '../interfaces.js';
|
|
3
3
|
export declare class ArgAsRequest extends RouteArgs {
|
|
4
4
|
get SupportedType(): ParameterType;
|
|
5
5
|
extract(callData: IRouteCall, _param: IRouteParameter, req: Request): Promise<{
|
|
@@ -7,3 +7,4 @@ export declare class ArgAsRequest extends RouteArgs {
|
|
|
7
7
|
Args: Request;
|
|
8
8
|
}>;
|
|
9
9
|
}
|
|
10
|
+
//# sourceMappingURL=ArgAsRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArgAsRequest.d.ts","sourceRoot":"","sources":["../../src/route-args/ArgAsRequest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAGvF,qBACa,YAAa,SAAQ,SAAS;IACzC,IAAW,aAAa,IAAI,aAAa,CAExC;IAEY,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO;;;;CAGjF"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
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;
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const di_1 = require("@spinajs/di");
|
|
13
|
-
let ArgAsRequest = class ArgAsRequest extends RouteArgs_1.RouteArgs {
|
|
7
|
+
import { RouteArgs } from './RouteArgs.js';
|
|
8
|
+
import { ParameterType } from '../interfaces.js';
|
|
9
|
+
import { Injectable } from '@spinajs/di';
|
|
10
|
+
let ArgAsRequest = class ArgAsRequest extends RouteArgs {
|
|
14
11
|
get SupportedType() {
|
|
15
|
-
return
|
|
12
|
+
return ParameterType.Req;
|
|
16
13
|
}
|
|
17
14
|
async extract(callData, _param, req) {
|
|
18
15
|
return { CallData: callData, Args: req };
|
|
19
16
|
}
|
|
20
17
|
};
|
|
21
18
|
ArgAsRequest = __decorate([
|
|
22
|
-
|
|
19
|
+
Injectable()
|
|
23
20
|
], ArgAsRequest);
|
|
24
|
-
|
|
21
|
+
export { ArgAsRequest };
|
|
25
22
|
//# sourceMappingURL=ArgAsRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArgAsRequest.js","sourceRoot":"","sources":["../../src/route-args/ArgAsRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ArgAsRequest.js","sourceRoot":"","sources":["../../src/route-args/ArgAsRequest.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAmB,aAAa,EAAuB,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,SAAS;IACzC,IAAW,aAAa;QACtB,OAAO,aAAa,CAAC,GAAG,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,QAAoB,EAAE,MAAuB,EAAE,GAAY;QAC9E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAC3C,CAAC;CACF,CAAA;AARY,YAAY;IADxB,UAAU,EAAE;GACA,YAAY,CAQxB;SARY,YAAY"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RouteArgs } from './RouteArgs';
|
|
2
|
-
import { IRouteParameter, ParameterType, IRouteCall, Request } from '../interfaces';
|
|
1
|
+
import { RouteArgs } from './RouteArgs.js';
|
|
2
|
+
import { IRouteParameter, ParameterType, IRouteCall, Request } from '../interfaces.js';
|
|
3
3
|
import * as express from 'express';
|
|
4
4
|
export declare class ArgAsResponse extends RouteArgs {
|
|
5
5
|
get SupportedType(): ParameterType;
|
|
@@ -8,3 +8,4 @@ export declare class ArgAsResponse extends RouteArgs {
|
|
|
8
8
|
Args: express.Response<any, Record<string, any>>;
|
|
9
9
|
}>;
|
|
10
10
|
}
|
|
11
|
+
//# sourceMappingURL=ArgAsResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArgAsResponse.d.ts","sourceRoot":"","sources":["../../src/route-args/ArgAsResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,qBACa,aAAc,SAAQ,SAAS;IAC1C,IAAW,aAAa,IAAI,aAAa,CAExC;IAEY,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ;;;;CAGzG"}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
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;
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const di_1 = require("@spinajs/di");
|
|
13
|
-
let ArgAsResponse = class ArgAsResponse extends RouteArgs_1.RouteArgs {
|
|
7
|
+
import { RouteArgs } from './RouteArgs.js';
|
|
8
|
+
import { ParameterType } from '../interfaces.js';
|
|
9
|
+
import { Injectable } from '@spinajs/di';
|
|
10
|
+
let ArgAsResponse = class ArgAsResponse extends RouteArgs {
|
|
14
11
|
get SupportedType() {
|
|
15
|
-
return
|
|
12
|
+
return ParameterType.Res;
|
|
16
13
|
}
|
|
17
14
|
async extract(callData, _param, _req, res) {
|
|
18
15
|
return { CallData: callData, Args: res };
|
|
19
16
|
}
|
|
20
17
|
};
|
|
21
18
|
ArgAsResponse = __decorate([
|
|
22
|
-
|
|
19
|
+
Injectable()
|
|
23
20
|
], ArgAsResponse);
|
|
24
|
-
|
|
21
|
+
export { ArgAsResponse };
|
|
25
22
|
//# sourceMappingURL=ArgAsResponse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArgAsResponse.js","sourceRoot":"","sources":["../../src/route-args/ArgAsResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ArgAsResponse.js","sourceRoot":"","sources":["../../src/route-args/ArgAsResponse.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAmB,aAAa,EAAuB,MAAM,kBAAkB,CAAC;AAEvF,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,SAAS;IAC1C,IAAW,aAAa;QACtB,OAAO,aAAa,CAAC,GAAG,CAAC;IAC3B,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,QAAoB,EAAE,MAAuB,EAAE,IAAa,EAAE,GAAqB;QACtG,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAC3C,CAAC;CACF,CAAA;AARY,aAAa;IADzB,UAAU,EAAE;GACA,aAAa,CAQzB;SARY,aAAa"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { IRouteParameter } from '../interfaces';
|
|
1
|
+
import { IRouteParameter } from '../interfaces.js';
|
|
2
2
|
export declare abstract class ArgHydrator {
|
|
3
3
|
abstract hydrate(input: any, parameter: IRouteParameter): Promise<any>;
|
|
4
4
|
}
|
|
5
|
+
//# sourceMappingURL=ArgHydrator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArgHydrator.d.ts","sourceRoot":"","sources":["../../src/route-args/ArgHydrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEnD,8BAAsB,WAAW;aACf,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,eAAe,GAAG,OAAO,CAAC,GAAG,CAAC;CAC9E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArgHydrator.js","sourceRoot":"","sources":["../../src/route-args/ArgHydrator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ArgHydrator.js","sourceRoot":"","sources":["../../src/route-args/ArgHydrator.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,WAAW;CAEhC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RouteArgs } from './RouteArgs';
|
|
2
|
-
import { IRouteParameter, ParameterType, IRouteCall, IRoute, Request } from '../interfaces';
|
|
1
|
+
import { RouteArgs } from './RouteArgs.js';
|
|
2
|
+
import { IRouteParameter, ParameterType, IRouteCall, IRoute, Request } from '../interfaces.js';
|
|
3
3
|
import * as express from 'express';
|
|
4
4
|
export declare class FromBody extends RouteArgs {
|
|
5
5
|
get SupportedType(): ParameterType;
|
|
@@ -8,3 +8,4 @@ export declare class FromBody extends RouteArgs {
|
|
|
8
8
|
Args: any;
|
|
9
9
|
}>;
|
|
10
10
|
}
|
|
11
|
+
//# sourceMappingURL=FromBody.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FromBody.d.ts","sourceRoot":"","sources":["../../src/route-args/FromBody.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,qBACa,QAAS,SAAQ,SAAS;IACrC,IAAW,aAAa,IAAI,aAAa,CAExC;IAEY,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM;;;;CAKvH"}
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
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;
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const di_1 = require("@spinajs/di");
|
|
13
|
-
let FromBody = class FromBody extends RouteArgs_1.RouteArgs {
|
|
7
|
+
import { RouteArgs } from './RouteArgs.js';
|
|
8
|
+
import { ParameterType } from '../interfaces.js';
|
|
9
|
+
import { Injectable } from '@spinajs/di';
|
|
10
|
+
let FromBody = class FromBody extends RouteArgs {
|
|
14
11
|
get SupportedType() {
|
|
15
|
-
return
|
|
12
|
+
return ParameterType.FromBody;
|
|
16
13
|
}
|
|
17
14
|
async extract(callData, param, req, _res, route) {
|
|
18
|
-
const arg = req.body[param.Name] ? req.body[param.Name] : [...route.Parameters.values()].filter((p) => p.Type ===
|
|
15
|
+
const arg = req.body[param.Name] ? req.body[param.Name] : [...route.Parameters.values()].filter((p) => p.Type === ParameterType.FromBody).length === 1 ? req.body : null;
|
|
19
16
|
let result = await this.tryHydrateParam(arg, param, route);
|
|
20
17
|
return { CallData: callData, Args: result };
|
|
21
18
|
}
|
|
22
19
|
};
|
|
23
20
|
FromBody = __decorate([
|
|
24
|
-
|
|
21
|
+
Injectable()
|
|
25
22
|
], FromBody);
|
|
26
|
-
|
|
23
|
+
export { FromBody };
|
|
27
24
|
//# sourceMappingURL=FromBody.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FromBody.js","sourceRoot":"","sources":["../../src/route-args/FromBody.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FromBody.js","sourceRoot":"","sources":["../../src/route-args/FromBody.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAmB,aAAa,EAA+B,MAAM,kBAAkB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlC,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,SAAS;IACrC,IAAW,aAAa;QACtB,OAAO,aAAa,CAAC,QAAQ,CAAC;IAChC,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,QAAoB,EAAE,KAAsB,EAAE,GAAY,EAAE,IAAsB,EAAE,KAAa;QACpH,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;QACzK,IAAI,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC9C,CAAC;CACF,CAAA;AAVY,QAAQ;IADpB,UAAU,EAAE;GACA,QAAQ,CAUpB;SAVY,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RouteArgs } from './RouteArgs';
|
|
2
|
-
import { IRouteParameter, ParameterType, IRouteCall, IRoute, Request } from '../interfaces';
|
|
1
|
+
import { RouteArgs } from './RouteArgs.js';
|
|
2
|
+
import { IRouteParameter, ParameterType, IRouteCall, IRoute, Request } from '../interfaces.js';
|
|
3
3
|
import * as express from 'express';
|
|
4
4
|
import { Configuration } from '@spinajs/configuration';
|
|
5
5
|
export declare class FromCookie extends RouteArgs {
|
|
@@ -11,3 +11,4 @@ export declare class FromCookie extends RouteArgs {
|
|
|
11
11
|
Args: any;
|
|
12
12
|
}>;
|
|
13
13
|
}
|
|
14
|
+
//# sourceMappingURL=FromCookie.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FromCookie.d.ts","sourceRoot":"","sources":["../../src/route-args/FromCookie.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC/F,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,qBAEa,UAAW,SAAQ,SAAS;IACvC,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC;gBAErB,GAAG,EAAE,aAAa;IAM9B,IAAW,aAAa,IAAI,aAAa,CAExC;IAEY,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM;;;;CAmBvH"}
|
|
@@ -1,57 +1,30 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
4
|
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;
|
|
22
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
6
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const cs = __importStar(require("cookie-signature"));
|
|
41
|
-
let FromCookie = class FromCookie extends RouteArgs_1.RouteArgs {
|
|
10
|
+
import { RouteArgs } from './RouteArgs.js';
|
|
11
|
+
import { ParameterType } from '../interfaces.js';
|
|
12
|
+
import { Inject, Injectable } from '@spinajs/di';
|
|
13
|
+
import { Configuration } from '@spinajs/configuration';
|
|
14
|
+
import * as cs from 'cookie-signature';
|
|
15
|
+
let FromCookie = class FromCookie extends RouteArgs {
|
|
42
16
|
constructor(cfg) {
|
|
43
17
|
super();
|
|
44
18
|
this._coockieSecret = cfg.get('http.coockie.secret');
|
|
45
19
|
}
|
|
46
20
|
get SupportedType() {
|
|
47
|
-
return
|
|
21
|
+
return ParameterType.FromCookie;
|
|
48
22
|
}
|
|
49
23
|
async extract(callData, param, req, _res, route) {
|
|
50
|
-
var _a;
|
|
51
24
|
const arg = req.cookies[param.Name];
|
|
52
25
|
if (arg !== null) {
|
|
53
26
|
let result = null;
|
|
54
|
-
if (
|
|
27
|
+
if (param.Options?.secure) {
|
|
55
28
|
result = cs.unsign(arg, this._coockieSecret);
|
|
56
29
|
if (result === false) {
|
|
57
30
|
return { CallData: callData, Args: null };
|
|
@@ -66,9 +39,9 @@ let FromCookie = class FromCookie extends RouteArgs_1.RouteArgs {
|
|
|
66
39
|
}
|
|
67
40
|
};
|
|
68
41
|
FromCookie = __decorate([
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
__metadata("design:paramtypes", [
|
|
42
|
+
Inject(Configuration),
|
|
43
|
+
Injectable(),
|
|
44
|
+
__metadata("design:paramtypes", [Configuration])
|
|
72
45
|
], FromCookie);
|
|
73
|
-
|
|
46
|
+
export { FromCookie };
|
|
74
47
|
//# sourceMappingURL=FromCookie.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FromCookie.js","sourceRoot":"","sources":["../../src/route-args/FromCookie.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FromCookie.js","sourceRoot":"","sources":["../../src/route-args/FromCookie.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAmB,aAAa,EAA+B,MAAM,kBAAkB,CAAC;AAE/F,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AA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, IRouteCall, Request } from '../interfaces';
|
|
1
|
+
import { IRouteArgs } from './RouteArgs.js';
|
|
2
|
+
import { IRouteParameter, ParameterType, IRouteCall, Request } from '../interfaces.js';
|
|
3
3
|
import { AsyncService, IContainer } from '@spinajs/di';
|
|
4
4
|
export declare class FromDi extends AsyncService implements IRouteArgs {
|
|
5
5
|
protected Container: IContainer;
|
|
@@ -11,3 +11,4 @@ export declare class FromDi extends AsyncService implements IRouteArgs {
|
|
|
11
11
|
Args: unknown;
|
|
12
12
|
}>;
|
|
13
13
|
}
|
|
14
|
+
//# sourceMappingURL=FromDi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FromDi.d.ts","sourceRoot":"","sources":["../../src/route-args/FromDi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,UAAU,EAAiC,MAAM,aAAa,CAAC;AAEtF,qBAEa,MAAO,SAAQ,YAAa,YAAW,UAAU;IAC5D,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC;gBAEpB,CAAC,EAAE,UAAU;IAMnB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAE9B,IAAW,aAAa,IAAI,aAAa,CAExC;IAEY,OAAO,CAAC,QAAQ,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,OAAO;;;;CAIjF"}
|
package/lib/route-args/FromDi.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,18 +7,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const di_1 = require("@spinajs/di");
|
|
15
|
-
let FromDi = class FromDi extends di_1.AsyncService {
|
|
10
|
+
import { ParameterType } from '../interfaces.js';
|
|
11
|
+
import { AsyncService, Inject, Injectable, Container } from '@spinajs/di';
|
|
12
|
+
let FromDi = class FromDi extends AsyncService {
|
|
16
13
|
constructor(c) {
|
|
17
14
|
super();
|
|
18
15
|
this.Container = c;
|
|
19
16
|
}
|
|
20
17
|
async resolve() { }
|
|
21
18
|
get SupportedType() {
|
|
22
|
-
return
|
|
19
|
+
return ParameterType.FromDi;
|
|
23
20
|
}
|
|
24
21
|
async extract(callData, param, _req) {
|
|
25
22
|
const srv = await this.Container.resolve(param.RuntimeType, param.Options);
|
|
@@ -27,9 +24,9 @@ let FromDi = class FromDi extends di_1.AsyncService {
|
|
|
27
24
|
}
|
|
28
25
|
};
|
|
29
26
|
FromDi = __decorate([
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
Injectable(),
|
|
28
|
+
Inject(Container),
|
|
32
29
|
__metadata("design:paramtypes", [Object])
|
|
33
30
|
], FromDi);
|
|
34
|
-
|
|
31
|
+
export { FromDi };
|
|
35
32
|
//# sourceMappingURL=FromDi.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FromDi.js","sourceRoot":"","sources":["../../src/route-args/FromDi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FromDi.js","sourceRoot":"","sources":["../../src/route-args/FromDi.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAmB,aAAa,EAAuB,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,YAAY,EAAc,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAI/E,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,YAAY;IAGtC,YAAY,CAAa;QACvB,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,OAAO,KAAmB,CAAC;IAEjC,IAAW,aAAa;QACtB,OAAO,aAAa,CAAC,MAAM,CAAC;IAC9B,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,QAAoB,EAAE,KAAsB,EAAE,IAAa;QAC9E,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC;IAC3C,CAAC;CACF,CAAA;AAnBY,MAAM;IAFlB,UAAU,EAAE;IACZ,MAAM,CAAC,SAAS,CAAC;;GACL,MAAM,CAmBlB;SAnBY,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RouteArgs } from './RouteArgs';
|
|
2
|
-
import { IRouteParameter, ParameterType, IRouteCall, Request } from '../interfaces';
|
|
1
|
+
import { RouteArgs } from './RouteArgs.js';
|
|
2
|
+
import { IRouteParameter, ParameterType, IRouteCall, Request } from '../interfaces.js';
|
|
3
3
|
import * as express from 'express';
|
|
4
4
|
import { Fields, Files } from 'formidable';
|
|
5
5
|
import { Configuration } from '@spinajs/configuration';
|
|
@@ -8,7 +8,7 @@ interface FormData {
|
|
|
8
8
|
Fields: Fields;
|
|
9
9
|
Files: Files;
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type FormOptionsCallback = (conf: Configuration) => Promise<FormOptions>;
|
|
12
12
|
export interface FormOptions {
|
|
13
13
|
encoding?: string;
|
|
14
14
|
/**
|
|
@@ -87,3 +87,4 @@ export declare class FromForm extends FromFormBase {
|
|
|
87
87
|
}>;
|
|
88
88
|
}
|
|
89
89
|
export {};
|
|
90
|
+
//# sourceMappingURL=FromForm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FromForm.d.ts","sourceRoot":"","sources":["../../src/route-args/FromForm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAsB,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAIjC,UAAU,QAAQ;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;CACd;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAEhF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,8BAAsB,YAAa,SAAQ,SAAS;IAC3C,IAAI,EAAE,QAAQ,CAAC;IA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