@spinajs/http 2.0.179 → 2.0.181
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/lib/cjs/bootstrap.d.ts +4 -4
- package/lib/cjs/bootstrap.js +29 -29
- package/lib/cjs/bootstrap.js.map +1 -1
- package/lib/cjs/config/http.d.ts +58 -58
- package/lib/cjs/config/http.js +86 -86
- package/lib/cjs/controllers.d.ts +48 -48
- package/lib/cjs/controllers.d.ts.map +1 -1
- package/lib/cjs/controllers.js +307 -312
- package/lib/cjs/controllers.js.map +1 -1
- package/lib/cjs/decorators.d.ts +183 -183
- package/lib/cjs/decorators.js +441 -441
- package/lib/cjs/hydrators/DateTimeHydrator.d.ts +5 -5
- package/lib/cjs/hydrators/DateTimeHydrator.js +36 -36
- package/lib/cjs/hydrators/DateTimeHydrator.js.map +1 -1
- package/lib/cjs/index.d.ts +9 -9
- package/lib/cjs/index.js +25 -25
- package/lib/cjs/interfaces.d.ts +569 -550
- package/lib/cjs/interfaces.d.ts.map +1 -1
- package/lib/cjs/interfaces.js +266 -259
- package/lib/cjs/interfaces.js.map +1 -1
- package/lib/cjs/middlewares/RealIp.d.ts +8 -8
- package/lib/cjs/middlewares/RealIp.js +34 -34
- package/lib/cjs/middlewares/RealIp.js.map +1 -1
- package/lib/cjs/middlewares/RequestId.d.ts +8 -8
- package/lib/cjs/middlewares/RequestId.js +35 -35
- package/lib/cjs/middlewares/RequestId.js.map +1 -1
- package/lib/cjs/middlewares/ResponseTime.d.ts +10 -10
- package/lib/cjs/middlewares/ResponseTime.js +41 -41
- package/lib/cjs/middlewares/ResponseTime.js.map +1 -1
- package/lib/cjs/response-methods/badRequest.d.ts +12 -12
- package/lib/cjs/response-methods/badRequest.js +20 -20
- package/lib/cjs/response-methods/conflict.d.ts +12 -12
- package/lib/cjs/response-methods/conflict.js +20 -20
- package/lib/cjs/response-methods/cookieResponse.d.ts +19 -19
- package/lib/cjs/response-methods/cookieResponse.js +73 -73
- package/lib/cjs/response-methods/created.d.ts +12 -12
- package/lib/cjs/response-methods/created.js +19 -19
- package/lib/cjs/response-methods/errorResponse.d.ts +7 -7
- package/lib/cjs/response-methods/errorResponse.js +24 -24
- package/lib/cjs/response-methods/file.d.ts +26 -26
- package/lib/cjs/response-methods/file.d.ts.map +1 -1
- package/lib/cjs/response-methods/file.js +112 -133
- package/lib/cjs/response-methods/file.js.map +1 -1
- package/lib/cjs/response-methods/forbidden.d.ts +12 -12
- package/lib/cjs/response-methods/forbidden.js +20 -20
- package/lib/cjs/response-methods/index.d.ts +13 -13
- package/lib/cjs/response-methods/index.js +29 -29
- package/lib/cjs/response-methods/noContent.d.ts +12 -12
- package/lib/cjs/response-methods/noContent.js +20 -20
- package/lib/cjs/response-methods/notAcceptable.d.ts +13 -13
- package/lib/cjs/response-methods/notAcceptable.js +21 -21
- package/lib/cjs/response-methods/notAllowed.d.ts +12 -12
- package/lib/cjs/response-methods/notAllowed.js +20 -20
- package/lib/cjs/response-methods/notFound.d.ts +12 -12
- package/lib/cjs/response-methods/notFound.js +20 -20
- package/lib/cjs/response-methods/ok.d.ts +12 -12
- package/lib/cjs/response-methods/ok.js +19 -19
- package/lib/cjs/response-methods/redirect.d.ts +12 -12
- package/lib/cjs/response-methods/redirect.js +19 -19
- package/lib/cjs/response-methods/serverError.d.ts +12 -12
- package/lib/cjs/response-methods/serverError.js +20 -20
- package/lib/cjs/response-methods/template.d.ts +15 -15
- package/lib/cjs/response-methods/template.js +36 -36
- package/lib/cjs/response-methods/unauthorized.d.ts +12 -12
- package/lib/cjs/response-methods/unauthorized.js +20 -20
- package/lib/cjs/response-methods/validationError.d.ts +12 -12
- package/lib/cjs/response-methods/validationError.js +20 -20
- package/lib/cjs/responses.d.ts +34 -34
- package/lib/cjs/responses.js +173 -173
- package/lib/cjs/route-args/ArgAsRequest.d.ts +11 -11
- package/lib/cjs/route-args/ArgAsRequest.js +24 -24
- package/lib/cjs/route-args/ArgAsRequest.js.map +1 -1
- package/lib/cjs/route-args/ArgAsResponse.d.ts +10 -10
- package/lib/cjs/route-args/ArgAsResponse.js +24 -24
- package/lib/cjs/route-args/ArgAsResponse.js.map +1 -1
- package/lib/cjs/route-args/ArgHydrator.d.ts +4 -4
- package/lib/cjs/route-args/ArgHydrator.js +6 -6
- package/lib/cjs/route-args/FromBody.d.ts +10 -10
- package/lib/cjs/route-args/FromBody.js +26 -26
- package/lib/cjs/route-args/FromBody.js.map +1 -1
- package/lib/cjs/route-args/FromCookie.d.ts +13 -13
- package/lib/cjs/route-args/FromCookie.js +72 -72
- package/lib/cjs/route-args/FromCookie.js.map +1 -1
- package/lib/cjs/route-args/FromDi.d.ts +13 -13
- package/lib/cjs/route-args/FromDi.js +35 -35
- package/lib/cjs/route-args/FromDi.js.map +1 -1
- package/lib/cjs/route-args/FromForm.d.ts +66 -92
- package/lib/cjs/route-args/FromForm.d.ts.map +1 -1
- package/lib/cjs/route-args/FromForm.js +214 -291
- package/lib/cjs/route-args/FromForm.js.map +1 -1
- package/lib/cjs/route-args/FromHeaderArg.d.ts +10 -10
- package/lib/cjs/route-args/FromHeaderArg.js +25 -25
- package/lib/cjs/route-args/FromHeaderArg.js.map +1 -1
- package/lib/cjs/route-args/FromParams.d.ts +10 -10
- package/lib/cjs/route-args/FromParams.js +27 -27
- package/lib/cjs/route-args/FromParams.js.map +1 -1
- package/lib/cjs/route-args/FromQuery.d.ts +10 -10
- package/lib/cjs/route-args/FromQuery.js +27 -27
- package/lib/cjs/route-args/FromQuery.js.map +1 -1
- package/lib/cjs/route-args/RequestFields.d.ts +40 -40
- package/lib/cjs/route-args/RequestFields.js +110 -110
- package/lib/cjs/route-args/RequestFields.js.map +1 -1
- package/lib/cjs/route-args/RouteArgs.d.ts +22 -22
- package/lib/cjs/route-args/RouteArgs.js +114 -114
- package/lib/cjs/route-args/RouteArgs.js.map +1 -1
- package/lib/cjs/route-args/index.d.ts +12 -12
- package/lib/cjs/route-args/index.js +28 -28
- package/lib/cjs/schemas/RouteArgsSchemas.d.ts +36 -36
- package/lib/cjs/schemas/RouteArgsSchemas.js +26 -26
- package/lib/cjs/server.d.ts +50 -50
- package/lib/cjs/server.js +272 -272
- package/lib/cjs/server.js.map +1 -1
- package/lib/cjs/transformers/PureTransformer.d.ts +9 -9
- package/lib/cjs/transformers/PureTransformer.js +27 -27
- package/lib/cjs/transformers/PureTransformer.js.map +1 -1
- package/lib/cjs/transformers/index.d.ts +1 -1
- package/lib/cjs/transformers/index.js +17 -17
- package/lib/cjs/uploaders/ImmediateFileUploader.d.ts +19 -0
- package/lib/cjs/uploaders/ImmediateFileUploader.d.ts.map +1 -0
- package/lib/cjs/uploaders/ImmediateFileUploader.js +69 -0
- package/lib/cjs/uploaders/ImmediateFileUploader.js.map +1 -0
- package/lib/mjs/bootstrap.d.ts +4 -4
- package/lib/mjs/bootstrap.js +26 -26
- package/lib/mjs/bootstrap.js.map +1 -1
- package/lib/mjs/config/http.d.ts +58 -58
- package/lib/mjs/config/http.js +81 -81
- package/lib/mjs/controllers.d.ts +48 -48
- package/lib/mjs/controllers.d.ts.map +1 -1
- package/lib/mjs/controllers.js +276 -281
- package/lib/mjs/controllers.js.map +1 -1
- package/lib/mjs/decorators.d.ts +183 -183
- package/lib/mjs/decorators.js +404 -404
- package/lib/mjs/exceptions.d.ts +1 -1
- package/lib/mjs/exceptions.js +1 -1
- package/lib/mjs/hydrators/DateTimeHydrator.d.ts +5 -5
- package/lib/mjs/hydrators/DateTimeHydrator.js +30 -30
- package/lib/mjs/hydrators/DateTimeHydrator.js.map +1 -1
- package/lib/mjs/index.d.ts +9 -9
- package/lib/mjs/index.js +9 -9
- package/lib/mjs/interfaces.d.ts +569 -550
- package/lib/mjs/interfaces.d.ts.map +1 -1
- package/lib/mjs/interfaces.js +257 -251
- package/lib/mjs/interfaces.js.map +1 -1
- package/lib/mjs/middlewares/RealIp.d.ts +8 -8
- package/lib/mjs/middlewares/RealIp.js +31 -31
- package/lib/mjs/middlewares/RealIp.js.map +1 -1
- package/lib/mjs/middlewares/RequestId.d.ts +8 -8
- package/lib/mjs/middlewares/RequestId.js +32 -32
- package/lib/mjs/middlewares/RequestId.js.map +1 -1
- package/lib/mjs/middlewares/ResponseTime.d.ts +10 -10
- package/lib/mjs/middlewares/ResponseTime.js +38 -38
- package/lib/mjs/middlewares/ResponseTime.js.map +1 -1
- package/lib/mjs/response-methods/badRequest.d.ts +12 -12
- package/lib/mjs/response-methods/badRequest.js +16 -16
- package/lib/mjs/response-methods/conflict.d.ts +12 -12
- package/lib/mjs/response-methods/conflict.js +16 -16
- package/lib/mjs/response-methods/cookieResponse.d.ts +19 -19
- package/lib/mjs/response-methods/cookieResponse.js +46 -46
- package/lib/mjs/response-methods/created.d.ts +12 -12
- package/lib/mjs/response-methods/created.js +15 -15
- package/lib/mjs/response-methods/errorResponse.d.ts +7 -7
- package/lib/mjs/response-methods/errorResponse.js +17 -17
- package/lib/mjs/response-methods/file.d.ts +26 -26
- package/lib/mjs/response-methods/file.d.ts.map +1 -1
- package/lib/mjs/response-methods/file.js +103 -124
- package/lib/mjs/response-methods/file.js.map +1 -1
- package/lib/mjs/response-methods/forbidden.d.ts +12 -12
- package/lib/mjs/response-methods/forbidden.js +16 -16
- package/lib/mjs/response-methods/index.d.ts +13 -13
- package/lib/mjs/response-methods/index.js +13 -13
- package/lib/mjs/response-methods/noContent.d.ts +12 -12
- package/lib/mjs/response-methods/noContent.js +16 -16
- package/lib/mjs/response-methods/notAcceptable.d.ts +13 -13
- package/lib/mjs/response-methods/notAcceptable.js +17 -17
- package/lib/mjs/response-methods/notAllowed.d.ts +12 -12
- package/lib/mjs/response-methods/notAllowed.js +16 -16
- package/lib/mjs/response-methods/notFound.d.ts +12 -12
- package/lib/mjs/response-methods/notFound.js +16 -16
- package/lib/mjs/response-methods/ok.d.ts +12 -12
- package/lib/mjs/response-methods/ok.js +15 -15
- package/lib/mjs/response-methods/redirect.d.ts +12 -12
- package/lib/mjs/response-methods/redirect.js +15 -15
- package/lib/mjs/response-methods/serverError.d.ts +12 -12
- package/lib/mjs/response-methods/serverError.js +16 -16
- package/lib/mjs/response-methods/template.d.ts +15 -15
- package/lib/mjs/response-methods/template.js +29 -29
- package/lib/mjs/response-methods/unauthorized.d.ts +12 -12
- package/lib/mjs/response-methods/unauthorized.js +16 -16
- package/lib/mjs/response-methods/validationError.d.ts +12 -12
- package/lib/mjs/response-methods/validationError.js +16 -16
- package/lib/mjs/responses.d.ts +34 -34
- package/lib/mjs/responses.js +143 -143
- package/lib/mjs/route-args/ArgAsRequest.d.ts +11 -11
- package/lib/mjs/route-args/ArgAsRequest.js +21 -21
- package/lib/mjs/route-args/ArgAsRequest.js.map +1 -1
- package/lib/mjs/route-args/ArgAsResponse.d.ts +10 -10
- package/lib/mjs/route-args/ArgAsResponse.js +21 -21
- package/lib/mjs/route-args/ArgAsResponse.js.map +1 -1
- package/lib/mjs/route-args/ArgHydrator.d.ts +4 -4
- package/lib/mjs/route-args/ArgHydrator.js +2 -2
- package/lib/mjs/route-args/FromBody.d.ts +10 -10
- package/lib/mjs/route-args/FromBody.js +23 -23
- package/lib/mjs/route-args/FromBody.js.map +1 -1
- package/lib/mjs/route-args/FromCookie.d.ts +13 -13
- package/lib/mjs/route-args/FromCookie.js +46 -46
- package/lib/mjs/route-args/FromCookie.js.map +1 -1
- package/lib/mjs/route-args/FromDi.d.ts +13 -13
- package/lib/mjs/route-args/FromDi.js +32 -32
- package/lib/mjs/route-args/FromDi.js.map +1 -1
- package/lib/mjs/route-args/FromForm.d.ts +66 -92
- package/lib/mjs/route-args/FromForm.d.ts.map +1 -1
- package/lib/mjs/route-args/FromForm.js +210 -284
- package/lib/mjs/route-args/FromForm.js.map +1 -1
- package/lib/mjs/route-args/FromHeaderArg.d.ts +10 -10
- package/lib/mjs/route-args/FromHeaderArg.js +22 -22
- package/lib/mjs/route-args/FromHeaderArg.js.map +1 -1
- package/lib/mjs/route-args/FromParams.d.ts +10 -10
- package/lib/mjs/route-args/FromParams.js +24 -24
- package/lib/mjs/route-args/FromParams.js.map +1 -1
- package/lib/mjs/route-args/FromQuery.d.ts +10 -10
- package/lib/mjs/route-args/FromQuery.js +24 -24
- package/lib/mjs/route-args/FromQuery.js.map +1 -1
- package/lib/mjs/route-args/RequestFields.d.ts +40 -40
- package/lib/mjs/route-args/RequestFields.js +107 -107
- package/lib/mjs/route-args/RequestFields.js.map +1 -1
- package/lib/mjs/route-args/RouteArgs.d.ts +22 -22
- package/lib/mjs/route-args/RouteArgs.js +107 -107
- package/lib/mjs/route-args/RouteArgs.js.map +1 -1
- package/lib/mjs/route-args/index.d.ts +12 -12
- package/lib/mjs/route-args/index.js +12 -12
- package/lib/mjs/schemas/RouteArgsSchemas.d.ts +36 -36
- package/lib/mjs/schemas/RouteArgsSchemas.js +23 -23
- package/lib/mjs/server.d.ts +50 -50
- package/lib/mjs/server.js +266 -266
- package/lib/mjs/server.js.map +1 -1
- package/lib/mjs/transformers/PureTransformer.d.ts +9 -9
- package/lib/mjs/transformers/PureTransformer.js +24 -24
- package/lib/mjs/transformers/PureTransformer.js.map +1 -1
- package/lib/mjs/transformers/index.d.ts +1 -1
- package/lib/mjs/transformers/index.js +1 -1
- package/lib/mjs/uploaders/ImmediateFileUploader.d.ts +19 -0
- package/lib/mjs/uploaders/ImmediateFileUploader.d.ts.map +1 -0
- package/lib/mjs/uploaders/ImmediateFileUploader.js +66 -0
- package/lib/mjs/uploaders/ImmediateFileUploader.js.map +1 -0
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +17 -17
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { ServerMiddleware } from '../interfaces.js';
|
|
11
|
-
import { Injectable } from '@spinajs/di';
|
|
12
|
-
let RealIp = class RealIp extends ServerMiddleware {
|
|
13
|
-
constructor() {
|
|
14
|
-
super();
|
|
15
|
-
this.Order = 1;
|
|
16
|
-
}
|
|
17
|
-
after() {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
before() {
|
|
21
|
-
return (req, _res, next) => {
|
|
22
|
-
req.storage.realIp = req.headers['x-forwarded-for']?.split(',').shift() || req.socket?.remoteAddress;
|
|
23
|
-
next();
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
RealIp = __decorate([
|
|
28
|
-
Injectable(ServerMiddleware),
|
|
29
|
-
__metadata("design:paramtypes", [])
|
|
30
|
-
], RealIp);
|
|
31
|
-
export { RealIp };
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ServerMiddleware } from '../interfaces.js';
|
|
11
|
+
import { Injectable } from '@spinajs/di';
|
|
12
|
+
let RealIp = class RealIp extends ServerMiddleware {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.Order = 1;
|
|
16
|
+
}
|
|
17
|
+
after() {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
before() {
|
|
21
|
+
return (req, _res, next) => {
|
|
22
|
+
req.storage.realIp = req.headers['x-forwarded-for']?.split(',').shift() || req.socket?.remoteAddress;
|
|
23
|
+
next();
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
RealIp = __decorate([
|
|
28
|
+
Injectable(ServerMiddleware),
|
|
29
|
+
__metadata("design:paramtypes", [])
|
|
30
|
+
], RealIp);
|
|
31
|
+
export { RealIp };
|
|
32
32
|
//# sourceMappingURL=RealIp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealIp.js","sourceRoot":"","sources":["../../../src/middlewares/RealIp.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlC,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,gBAAgB;IAC1C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM;QACX,OAAO,CAAC,GAAa,EAAE,IAAsB,EAAE,IAA0B,EAAE,EAAE;YAC3E,GAAG,CAAC,OAAO,CAAC,MAAM,GAAI,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;YACjH,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,MAAM;IADlB,UAAU,CAAC,gBAAgB,CAAC;;GAChB,MAAM,CAgBlB
|
|
1
|
+
{"version":3,"file":"RealIp.js","sourceRoot":"","sources":["../../../src/middlewares/RealIp.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlC,IAAM,MAAM,GAAZ,MAAM,MAAO,SAAQ,gBAAgB;IAC1C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM;QACX,OAAO,CAAC,GAAa,EAAE,IAAsB,EAAE,IAA0B,EAAE,EAAE;YAC3E,GAAG,CAAC,OAAO,CAAC,MAAM,GAAI,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAY,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;YACjH,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,MAAM;IADlB,UAAU,CAAC,gBAAgB,CAAC;;GAChB,MAAM,CAgBlB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Response, NextFunction } from 'express';
|
|
2
|
-
import { ServerMiddleware, Request as sRequest } from '../interfaces.js';
|
|
3
|
-
import * as express from 'express';
|
|
4
|
-
export declare class RequestId extends ServerMiddleware {
|
|
5
|
-
constructor();
|
|
6
|
-
after(): (_req: sRequest, _res: express.Response, _next: express.NextFunction) => void;
|
|
7
|
-
before(): (req: sRequest, res: Response<any, Record<string, any>>, next: NextFunction) => void;
|
|
8
|
-
}
|
|
1
|
+
import { Response, NextFunction } from 'express';
|
|
2
|
+
import { ServerMiddleware, Request as sRequest } from '../interfaces.js';
|
|
3
|
+
import * as express from 'express';
|
|
4
|
+
export declare class RequestId extends ServerMiddleware {
|
|
5
|
+
constructor();
|
|
6
|
+
after(): (_req: sRequest, _res: express.Response, _next: express.NextFunction) => void;
|
|
7
|
+
before(): (req: sRequest, res: Response<any, Record<string, any>>, next: NextFunction) => void;
|
|
8
|
+
}
|
|
9
9
|
//# sourceMappingURL=RequestId.d.ts.map
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { ServerMiddleware } from '../interfaces.js';
|
|
11
|
-
import { v4 as uuidv4 } from 'uuid';
|
|
12
|
-
import { Injectable } from '@spinajs/di';
|
|
13
|
-
let RequestId = class RequestId extends ServerMiddleware {
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
this.Order = 1;
|
|
17
|
-
}
|
|
18
|
-
after() {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
before() {
|
|
22
|
-
return (req, _res, next) => {
|
|
23
|
-
req.storage.requestId = uuidv4();
|
|
24
|
-
next();
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
RequestId = __decorate([
|
|
29
|
-
Injectable(ServerMiddleware),
|
|
30
|
-
__metadata("design:paramtypes", [])
|
|
31
|
-
], RequestId);
|
|
32
|
-
export { RequestId };
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ServerMiddleware } from '../interfaces.js';
|
|
11
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
12
|
+
import { Injectable } from '@spinajs/di';
|
|
13
|
+
let RequestId = class RequestId extends ServerMiddleware {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.Order = 1;
|
|
17
|
+
}
|
|
18
|
+
after() {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
before() {
|
|
22
|
+
return (req, _res, next) => {
|
|
23
|
+
req.storage.requestId = uuidv4();
|
|
24
|
+
next();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
RequestId = __decorate([
|
|
29
|
+
Injectable(ServerMiddleware),
|
|
30
|
+
__metadata("design:paramtypes", [])
|
|
31
|
+
], RequestId);
|
|
32
|
+
export { RequestId };
|
|
33
33
|
//# sourceMappingURL=RequestId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestId.js","sourceRoot":"","sources":["../../../src/middlewares/RequestId.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlC,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,gBAAgB;IAC7C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM;QACX,OAAO,CAAC,GAAa,EAAE,IAAsB,EAAE,IAA0B,EAAE,EAAE;YAC3E,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC;YACjC,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,SAAS;IADrB,UAAU,CAAC,gBAAgB,CAAC;;GAChB,SAAS,CAgBrB
|
|
1
|
+
{"version":3,"file":"RequestId.js","sourceRoot":"","sources":["../../../src/middlewares/RequestId.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlC,IAAM,SAAS,GAAf,MAAM,SAAU,SAAQ,gBAAgB;IAC7C;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;IACjB,CAAC;IAEM,KAAK;QACV,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM;QACX,OAAO,CAAC,GAAa,EAAE,IAAsB,EAAE,IAA0B,EAAE,EAAE;YAC3E,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,MAAM,EAAE,CAAC;YACjC,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAhBY,SAAS;IADrB,UAAU,CAAC,gBAAgB,CAAC;;GAChB,SAAS,CAgBrB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Request, Response, NextFunction } from 'express';
|
|
2
|
-
import { ParamsDictionary } from 'express-serve-static-core';
|
|
3
|
-
import { ParsedQs } from 'qs';
|
|
4
|
-
import { ServerMiddleware } from '../interfaces.js';
|
|
5
|
-
import * as express from 'express';
|
|
6
|
-
export declare class ResponseTime extends ServerMiddleware {
|
|
7
|
-
constructor();
|
|
8
|
-
after(): (req: express.Request, _res: express.Response, _next: express.NextFunction) => void;
|
|
9
|
-
before(): (_req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: NextFunction) => void;
|
|
10
|
-
}
|
|
1
|
+
import { Request, Response, NextFunction } from 'express';
|
|
2
|
+
import { ParamsDictionary } from 'express-serve-static-core';
|
|
3
|
+
import { ParsedQs } from 'qs';
|
|
4
|
+
import { ServerMiddleware } from '../interfaces.js';
|
|
5
|
+
import * as express from 'express';
|
|
6
|
+
export declare class ResponseTime extends ServerMiddleware {
|
|
7
|
+
constructor();
|
|
8
|
+
after(): (req: express.Request, _res: express.Response, _next: express.NextFunction) => void;
|
|
9
|
+
before(): (_req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: NextFunction) => void;
|
|
10
|
+
}
|
|
11
11
|
//# sourceMappingURL=ResponseTime.d.ts.map
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
import { ServerMiddleware } from '../interfaces.js';
|
|
11
|
-
import { Injectable } from '@spinajs/di';
|
|
12
|
-
let ResponseTime = class ResponseTime extends ServerMiddleware {
|
|
13
|
-
constructor() {
|
|
14
|
-
super();
|
|
15
|
-
this.Order = -1;
|
|
16
|
-
}
|
|
17
|
-
after() {
|
|
18
|
-
return (req, res, next) => {
|
|
19
|
-
const end = new Date();
|
|
20
|
-
const diff = end.getTime() - req.storage.responseStart.getTime();
|
|
21
|
-
req.storage.responseEnd = end;
|
|
22
|
-
req.storage.responseTime = diff;
|
|
23
|
-
res.header('x-response-time', diff.toString());
|
|
24
|
-
next();
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
before() {
|
|
28
|
-
return (req, _res, next) => {
|
|
29
|
-
req.storage.responseStart = new Date();
|
|
30
|
-
next();
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
ResponseTime = __decorate([
|
|
35
|
-
Injectable(ServerMiddleware),
|
|
36
|
-
__metadata("design:paramtypes", [])
|
|
37
|
-
], ResponseTime);
|
|
38
|
-
export { ResponseTime };
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ServerMiddleware } from '../interfaces.js';
|
|
11
|
+
import { Injectable } from '@spinajs/di';
|
|
12
|
+
let ResponseTime = class ResponseTime extends ServerMiddleware {
|
|
13
|
+
constructor() {
|
|
14
|
+
super();
|
|
15
|
+
this.Order = -1;
|
|
16
|
+
}
|
|
17
|
+
after() {
|
|
18
|
+
return (req, res, next) => {
|
|
19
|
+
const end = new Date();
|
|
20
|
+
const diff = end.getTime() - req.storage.responseStart.getTime();
|
|
21
|
+
req.storage.responseEnd = end;
|
|
22
|
+
req.storage.responseTime = diff;
|
|
23
|
+
res.header('x-response-time', diff.toString());
|
|
24
|
+
next();
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
before() {
|
|
28
|
+
return (req, _res, next) => {
|
|
29
|
+
req.storage.responseStart = new Date();
|
|
30
|
+
next();
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
ResponseTime = __decorate([
|
|
35
|
+
Injectable(ServerMiddleware),
|
|
36
|
+
__metadata("design:paramtypes", [])
|
|
37
|
+
], ResponseTime);
|
|
38
|
+
export { ResponseTime };
|
|
39
39
|
//# sourceMappingURL=ResponseTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseTime.js","sourceRoot":"","sources":["../../../src/middlewares/ResponseTime.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,gBAAgB;IAChD;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAClB,CAAC;IAEM,KAAK;QACV,OAAO,CAAC,GAAa,EAAE,GAAqB,EAAE,IAA0B,EAAE,EAAE;YAC1E,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YAEjE,GAAG,CAAC,OAAO,CAAC,WAAW,GAAG,GAAG,CAAC;YAC9B,GAAG,CAAC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;YAChC,GAAG,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC/C,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;IAEM,MAAM;QACX,OAAO,CAAC,GAAa,EAAE,IAAsB,EAAE,IAA0B,EAAE,EAAE;YAC3E,GAAG,CAAC,OAAO,CAAC,aAAa,GAAG,IAAI,IAAI,EAAE,CAAC;YACvC,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAxBY,YAAY;IADxB,UAAU,CAAC,gBAAgB,CAAC;;GAChB,YAAY,CAwBxB
|
|
1
|
+
{"version":3,"file":"ResponseTime.js","sourceRoot":"","sources":["../../../src/middlewares/ResponseTime.ts"],"names":[],"mappings":";;;;;;;;;AAGA,OAAO,EAAE,gBAAgB,EAAuB,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlC,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,gBAAgB;IAChD;QACE,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IAClB,CAAC;IAEM,KAAK;QACV,OAAO,CAAC,GAAa,EAAE,GAAqB,EAAE,IAA0B,EAAE,EAAE;YAC1E,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC;YAEjE,GAAG,CAAC,OAAO,CAAC,WAAW,GAAG,GAAG,CAAC;YAC9B,GAAG,CAAC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;YAChC,GAAG,CAAC,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC/C,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;IAEM,MAAM;QACX,OAAO,CAAC,GAAa,EAAE,IAAsB,EAAE,IAA0B,EAAE,EAAE;YAC3E,GAAG,CAAC,OAAO,CAAC,aAAa,GAAG,IAAI,IAAI,EAAE,CAAC;YACvC,IAAI,EAAE,CAAC;QACT,CAAC,CAAC;IACJ,CAAC;CACF,CAAA;AAxBY,YAAY;IADxB,UAAU,CAAC,gBAAgB,CAAC;;GAChB,YAAY,CAwBxB"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
|
-
import * as express from 'express';
|
|
3
|
-
import { ErrorResponse } from './errorResponse.js';
|
|
4
|
-
/**
|
|
5
|
-
* Internall response function.
|
|
6
|
-
* Returns HTTP 400 BAD REQUEST ERROR
|
|
7
|
-
* @param err - error to send
|
|
8
|
-
*/
|
|
9
|
-
export declare class BadRequest extends ErrorResponse {
|
|
10
|
-
constructor(data: any);
|
|
11
|
-
execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
|
|
12
|
-
}
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import * as express from 'express';
|
|
3
|
+
import { ErrorResponse } from './errorResponse.js';
|
|
4
|
+
/**
|
|
5
|
+
* Internall response function.
|
|
6
|
+
* Returns HTTP 400 BAD REQUEST ERROR
|
|
7
|
+
* @param err - error to send
|
|
8
|
+
*/
|
|
9
|
+
export declare class BadRequest extends ErrorResponse {
|
|
10
|
+
constructor(data: any);
|
|
11
|
+
execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=badRequest.d.ts.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { HTTP_STATUS_CODE } from '../interfaces.js';
|
|
2
|
-
import { httpResponse } from '../responses.js';
|
|
3
|
-
import { ErrorResponse } from './errorResponse.js';
|
|
4
|
-
/**
|
|
5
|
-
* Internall response function.
|
|
6
|
-
* Returns HTTP 400 BAD REQUEST ERROR
|
|
7
|
-
* @param err - error to send
|
|
8
|
-
*/
|
|
9
|
-
export class BadRequest extends ErrorResponse {
|
|
10
|
-
constructor(data) {
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
async execute(_req, _res) {
|
|
14
|
-
return await httpResponse(this.responseData, HTTP_STATUS_CODE.BAD_REQUEST, 'badRequest.pug');
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
import { HTTP_STATUS_CODE } from '../interfaces.js';
|
|
2
|
+
import { httpResponse } from '../responses.js';
|
|
3
|
+
import { ErrorResponse } from './errorResponse.js';
|
|
4
|
+
/**
|
|
5
|
+
* Internall response function.
|
|
6
|
+
* Returns HTTP 400 BAD REQUEST ERROR
|
|
7
|
+
* @param err - error to send
|
|
8
|
+
*/
|
|
9
|
+
export class BadRequest extends ErrorResponse {
|
|
10
|
+
constructor(data) {
|
|
11
|
+
super(data);
|
|
12
|
+
}
|
|
13
|
+
async execute(_req, _res) {
|
|
14
|
+
return await httpResponse(this.responseData, HTTP_STATUS_CODE.BAD_REQUEST, 'badRequest.pug');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
17
|
//# sourceMappingURL=badRequest.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
|
-
import * as express from 'express';
|
|
3
|
-
import { ErrorResponse } from './errorResponse.js';
|
|
4
|
-
/**
|
|
5
|
-
* Internall response function.
|
|
6
|
-
* Returns HTTP 409 Conflict
|
|
7
|
-
* @param err - error to send
|
|
8
|
-
*/
|
|
9
|
-
export declare class Conflict extends ErrorResponse {
|
|
10
|
-
constructor(data: any);
|
|
11
|
-
execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
|
|
12
|
-
}
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import * as express from 'express';
|
|
3
|
+
import { ErrorResponse } from './errorResponse.js';
|
|
4
|
+
/**
|
|
5
|
+
* Internall response function.
|
|
6
|
+
* Returns HTTP 409 Conflict
|
|
7
|
+
* @param err - error to send
|
|
8
|
+
*/
|
|
9
|
+
export declare class Conflict extends ErrorResponse {
|
|
10
|
+
constructor(data: any);
|
|
11
|
+
execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=conflict.d.ts.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { HTTP_STATUS_CODE } from '../interfaces.js';
|
|
2
|
-
import { httpResponse } from '../responses.js';
|
|
3
|
-
import { ErrorResponse } from './errorResponse.js';
|
|
4
|
-
/**
|
|
5
|
-
* Internall response function.
|
|
6
|
-
* Returns HTTP 409 Conflict
|
|
7
|
-
* @param err - error to send
|
|
8
|
-
*/
|
|
9
|
-
export class Conflict extends ErrorResponse {
|
|
10
|
-
constructor(data) {
|
|
11
|
-
super(data);
|
|
12
|
-
}
|
|
13
|
-
async execute(_req, _res) {
|
|
14
|
-
return await httpResponse(this.responseData, HTTP_STATUS_CODE.CONFLICT, 'conflict.pug');
|
|
15
|
-
}
|
|
16
|
-
}
|
|
1
|
+
import { HTTP_STATUS_CODE } from '../interfaces.js';
|
|
2
|
+
import { httpResponse } from '../responses.js';
|
|
3
|
+
import { ErrorResponse } from './errorResponse.js';
|
|
4
|
+
/**
|
|
5
|
+
* Internall response function.
|
|
6
|
+
* Returns HTTP 409 Conflict
|
|
7
|
+
* @param err - error to send
|
|
8
|
+
*/
|
|
9
|
+
export class Conflict extends ErrorResponse {
|
|
10
|
+
constructor(data) {
|
|
11
|
+
super(data);
|
|
12
|
+
}
|
|
13
|
+
async execute(_req, _res) {
|
|
14
|
+
return await httpResponse(this.responseData, HTTP_STATUS_CODE.CONFLICT, 'conflict.pug');
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
17
|
//# sourceMappingURL=conflict.js.map
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
|
-
import * as express from 'express';
|
|
3
|
-
import { ICookieOptions, Response } from '../interfaces.js';
|
|
4
|
-
/**
|
|
5
|
-
* Simpel wrapper for coockie response for api consistency.
|
|
6
|
-
* It also signs cookie with coockie-secure
|
|
7
|
-
*
|
|
8
|
-
* @param cookieLifetime - cookie max age in seconds
|
|
9
|
-
*/
|
|
10
|
-
export declare class CookieResponse extends Response {
|
|
11
|
-
protected name: string;
|
|
12
|
-
protected coockieValue: string;
|
|
13
|
-
protected cookieLifetime: number;
|
|
14
|
-
protected signed?: boolean;
|
|
15
|
-
protected data?: any;
|
|
16
|
-
protected options?: ICookieOptions;
|
|
17
|
-
constructor(name: string, coockieValue: string, cookieLifetime: number, signed?: boolean, data?: any, options?: ICookieOptions);
|
|
18
|
-
execute(_req: express.Request, res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
|
|
19
|
-
}
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import * as express from 'express';
|
|
3
|
+
import { ICookieOptions, Response } from '../interfaces.js';
|
|
4
|
+
/**
|
|
5
|
+
* Simpel wrapper for coockie response for api consistency.
|
|
6
|
+
* It also signs cookie with coockie-secure
|
|
7
|
+
*
|
|
8
|
+
* @param cookieLifetime - cookie max age in seconds
|
|
9
|
+
*/
|
|
10
|
+
export declare class CookieResponse extends Response {
|
|
11
|
+
protected name: string;
|
|
12
|
+
protected coockieValue: string;
|
|
13
|
+
protected cookieLifetime: number;
|
|
14
|
+
protected signed?: boolean;
|
|
15
|
+
protected data?: any;
|
|
16
|
+
protected options?: ICookieOptions;
|
|
17
|
+
constructor(name: string, coockieValue: string, cookieLifetime: number, signed?: boolean, data?: any, options?: ICookieOptions);
|
|
18
|
+
execute(_req: express.Request, res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
|
|
19
|
+
}
|
|
20
20
|
//# sourceMappingURL=cookieResponse.d.ts.map
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { httpResponse } from '../responses.js';
|
|
2
|
-
import { Configuration } from '@spinajs/configuration';
|
|
3
|
-
import { DI } from '@spinajs/di';
|
|
4
|
-
import * as cs from 'cookie-signature';
|
|
5
|
-
import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
|
|
6
|
-
/**
|
|
7
|
-
* Simpel wrapper for coockie response for api consistency.
|
|
8
|
-
* It also signs cookie with coockie-secure
|
|
9
|
-
*
|
|
10
|
-
* @param cookieLifetime - cookie max age in seconds
|
|
11
|
-
*/
|
|
12
|
-
export class CookieResponse extends Response {
|
|
13
|
-
constructor(name, coockieValue, cookieLifetime, signed, data, options) {
|
|
14
|
-
super(coockieValue);
|
|
15
|
-
this.name = name;
|
|
16
|
-
this.coockieValue = coockieValue;
|
|
17
|
-
this.cookieLifetime = cookieLifetime;
|
|
18
|
-
this.signed = signed;
|
|
19
|
-
this.data = data;
|
|
20
|
-
this.options = options;
|
|
21
|
-
}
|
|
22
|
-
async execute(_req, res) {
|
|
23
|
-
const cfg = DI.get(Configuration);
|
|
24
|
-
const opt = cfg.get('http.cookie.options', {});
|
|
25
|
-
if (this.options) {
|
|
26
|
-
Object.assign(opt, this.options);
|
|
27
|
-
}
|
|
28
|
-
if (this.cookieLifetime) {
|
|
29
|
-
Object.assign(opt, { maxAge: this.cookieLifetime * 1000 });
|
|
30
|
-
}
|
|
31
|
-
if (!this.responseData) {
|
|
32
|
-
res.clearCookie(this.name, opt);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
if (this.signed) {
|
|
36
|
-
const secureKey = cfg.get('http.cookie.secret');
|
|
37
|
-
const signed = cs.sign(this.responseData, secureKey);
|
|
38
|
-
res.cookie(this.name, signed, opt);
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
res.cookie(this.name, this.responseData, opt);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return await httpResponse(this.data, HTTP_STATUS_CODE.OK, 'responses/ok');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
1
|
+
import { httpResponse } from '../responses.js';
|
|
2
|
+
import { Configuration } from '@spinajs/configuration';
|
|
3
|
+
import { DI } from '@spinajs/di';
|
|
4
|
+
import * as cs from 'cookie-signature';
|
|
5
|
+
import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
|
|
6
|
+
/**
|
|
7
|
+
* Simpel wrapper for coockie response for api consistency.
|
|
8
|
+
* It also signs cookie with coockie-secure
|
|
9
|
+
*
|
|
10
|
+
* @param cookieLifetime - cookie max age in seconds
|
|
11
|
+
*/
|
|
12
|
+
export class CookieResponse extends Response {
|
|
13
|
+
constructor(name, coockieValue, cookieLifetime, signed, data, options) {
|
|
14
|
+
super(coockieValue);
|
|
15
|
+
this.name = name;
|
|
16
|
+
this.coockieValue = coockieValue;
|
|
17
|
+
this.cookieLifetime = cookieLifetime;
|
|
18
|
+
this.signed = signed;
|
|
19
|
+
this.data = data;
|
|
20
|
+
this.options = options;
|
|
21
|
+
}
|
|
22
|
+
async execute(_req, res) {
|
|
23
|
+
const cfg = DI.get(Configuration);
|
|
24
|
+
const opt = cfg.get('http.cookie.options', {});
|
|
25
|
+
if (this.options) {
|
|
26
|
+
Object.assign(opt, this.options);
|
|
27
|
+
}
|
|
28
|
+
if (this.cookieLifetime) {
|
|
29
|
+
Object.assign(opt, { maxAge: this.cookieLifetime * 1000 });
|
|
30
|
+
}
|
|
31
|
+
if (!this.responseData) {
|
|
32
|
+
res.clearCookie(this.name, opt);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
if (this.signed) {
|
|
36
|
+
const secureKey = cfg.get('http.cookie.secret');
|
|
37
|
+
const signed = cs.sign(this.responseData, secureKey);
|
|
38
|
+
res.cookie(this.name, signed, opt);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
res.cookie(this.name, this.responseData, opt);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return await httpResponse(this.data, HTTP_STATUS_CODE.OK, 'responses/ok');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
47
|
//# sourceMappingURL=cookieResponse.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
|
-
import * as express from 'express';
|
|
3
|
-
import { Response } from '../interfaces.js';
|
|
4
|
-
/**
|
|
5
|
-
* Internall response function.
|
|
6
|
-
* Returns HTTP 201 CREATED
|
|
7
|
-
* @param data - additional data eg. model pk
|
|
8
|
-
*/
|
|
9
|
-
export declare class Created extends Response {
|
|
10
|
-
constructor(data: any);
|
|
11
|
-
execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
|
|
12
|
-
}
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import * as express from 'express';
|
|
3
|
+
import { Response } from '../interfaces.js';
|
|
4
|
+
/**
|
|
5
|
+
* Internall response function.
|
|
6
|
+
* Returns HTTP 201 CREATED
|
|
7
|
+
* @param data - additional data eg. model pk
|
|
8
|
+
*/
|
|
9
|
+
export declare class Created extends Response {
|
|
10
|
+
constructor(data: any);
|
|
11
|
+
execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
|
|
12
|
+
}
|
|
13
13
|
//# sourceMappingURL=created.d.ts.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
|
|
2
|
-
import { httpResponse } from '../responses.js';
|
|
3
|
-
/**
|
|
4
|
-
* Internall response function.
|
|
5
|
-
* Returns HTTP 201 CREATED
|
|
6
|
-
* @param data - additional data eg. model pk
|
|
7
|
-
*/
|
|
8
|
-
export class Created extends Response {
|
|
9
|
-
constructor(data) {
|
|
10
|
-
super(data);
|
|
11
|
-
}
|
|
12
|
-
async execute(_req, _res) {
|
|
13
|
-
return await httpResponse(this.responseData, HTTP_STATUS_CODE.CREATED, 'created.pug');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
|
|
2
|
+
import { httpResponse } from '../responses.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internall response function.
|
|
5
|
+
* Returns HTTP 201 CREATED
|
|
6
|
+
* @param data - additional data eg. model pk
|
|
7
|
+
*/
|
|
8
|
+
export class Created extends Response {
|
|
9
|
+
constructor(data) {
|
|
10
|
+
super(data);
|
|
11
|
+
}
|
|
12
|
+
async execute(_req, _res) {
|
|
13
|
+
return await httpResponse(this.responseData, HTTP_STATUS_CODE.CREATED, 'created.pug');
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
16
|
//# sourceMappingURL=created.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/// <reference types="qs" />
|
|
2
|
-
import * as express from 'express';
|
|
3
|
-
import { Response } from '../interfaces.js';
|
|
4
|
-
export declare class ErrorResponse extends Response {
|
|
5
|
-
constructor(error: any);
|
|
6
|
-
execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
|
|
7
|
-
}
|
|
1
|
+
/// <reference types="qs" />
|
|
2
|
+
import * as express from 'express';
|
|
3
|
+
import { Response } from '../interfaces.js';
|
|
4
|
+
export declare class ErrorResponse extends Response {
|
|
5
|
+
constructor(error: any);
|
|
6
|
+
execute(_req: express.Request, _res: express.Response): Promise<(req: express.Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>, res: express.Response<any, Record<string, any>>) => void>;
|
|
7
|
+
}
|
|
8
8
|
//# sourceMappingURL=errorResponse.d.ts.map
|