@spinajs/http 2.0.45 → 2.0.48
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/interfaces.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DataTransformer = exports.BasePolicy = exports.Response = exports.RouteMiddleware = exports.ParameterType = exports.UuidVersion = exports.RouteType = exports.HTTP_STATUS_CODE = exports.ServerMiddleware = exports.HttpAcceptHeaders = void 0;
|
|
4
|
-
const di_1 = require("@spinajs/di");
|
|
1
|
+
import { AsyncService } from '@spinajs/di';
|
|
5
2
|
/**
|
|
6
3
|
* Accept header enum
|
|
7
4
|
*/
|
|
8
|
-
var HttpAcceptHeaders;
|
|
5
|
+
export var HttpAcceptHeaders;
|
|
9
6
|
(function (HttpAcceptHeaders) {
|
|
10
7
|
/**
|
|
11
8
|
* Accept header for JSON
|
|
@@ -23,14 +20,13 @@ var HttpAcceptHeaders;
|
|
|
23
20
|
* Accept all accept headers shorcut
|
|
24
21
|
*/
|
|
25
22
|
HttpAcceptHeaders[HttpAcceptHeaders["ALL"] = 7] = "ALL";
|
|
26
|
-
})(HttpAcceptHeaders
|
|
27
|
-
class ServerMiddleware extends
|
|
23
|
+
})(HttpAcceptHeaders || (HttpAcceptHeaders = {}));
|
|
24
|
+
export class ServerMiddleware extends AsyncService {
|
|
28
25
|
}
|
|
29
|
-
exports.ServerMiddleware = ServerMiddleware;
|
|
30
26
|
/**
|
|
31
27
|
* HTTP response statuses
|
|
32
28
|
*/
|
|
33
|
-
var HTTP_STATUS_CODE;
|
|
29
|
+
export var HTTP_STATUS_CODE;
|
|
34
30
|
(function (HTTP_STATUS_CODE) {
|
|
35
31
|
/**
|
|
36
32
|
* All ok with content
|
|
@@ -94,11 +90,11 @@ var HTTP_STATUS_CODE;
|
|
|
94
90
|
* Method not implemented
|
|
95
91
|
*/
|
|
96
92
|
HTTP_STATUS_CODE[HTTP_STATUS_CODE["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
97
|
-
})(HTTP_STATUS_CODE
|
|
93
|
+
})(HTTP_STATUS_CODE || (HTTP_STATUS_CODE = {}));
|
|
98
94
|
/**
|
|
99
95
|
* Avaible route types, match HTTP methods
|
|
100
96
|
*/
|
|
101
|
-
var RouteType;
|
|
97
|
+
export var RouteType;
|
|
102
98
|
(function (RouteType) {
|
|
103
99
|
/**
|
|
104
100
|
* POST method - used to create new resource or send data to server
|
|
@@ -129,18 +125,18 @@ var RouteType;
|
|
|
129
125
|
*/
|
|
130
126
|
RouteType["FILE"] = "file";
|
|
131
127
|
RouteType["UNKNOWN"] = "unknown";
|
|
132
|
-
})(RouteType
|
|
133
|
-
var UuidVersion;
|
|
128
|
+
})(RouteType || (RouteType = {}));
|
|
129
|
+
export var UuidVersion;
|
|
134
130
|
(function (UuidVersion) {
|
|
135
131
|
UuidVersion[UuidVersion["v1"] = 0] = "v1";
|
|
136
132
|
UuidVersion[UuidVersion["v3"] = 1] = "v3";
|
|
137
133
|
UuidVersion[UuidVersion["v4"] = 2] = "v4";
|
|
138
134
|
UuidVersion[UuidVersion["v5"] = 3] = "v5";
|
|
139
|
-
})(UuidVersion
|
|
135
|
+
})(UuidVersion || (UuidVersion = {}));
|
|
140
136
|
/**
|
|
141
137
|
* Avaible route parameters type
|
|
142
138
|
*/
|
|
143
|
-
var ParameterType;
|
|
139
|
+
export var ParameterType;
|
|
144
140
|
(function (ParameterType) {
|
|
145
141
|
/**
|
|
146
142
|
* Parameter is injected from DI container & resolved
|
|
@@ -200,28 +196,25 @@ var ParameterType;
|
|
|
200
196
|
* Other custom arguments
|
|
201
197
|
*/
|
|
202
198
|
ParameterType["Other"] = "Other";
|
|
203
|
-
})(ParameterType
|
|
199
|
+
})(ParameterType || (ParameterType = {}));
|
|
204
200
|
/**
|
|
205
201
|
* Middlewares are classes that can change request object or perform specific task before & after route execution
|
|
206
202
|
* eg. route parameter logging / headers check etc.
|
|
207
203
|
*/
|
|
208
|
-
class RouteMiddleware {
|
|
204
|
+
export class RouteMiddleware {
|
|
209
205
|
}
|
|
210
|
-
|
|
211
|
-
class Response {
|
|
206
|
+
export class Response {
|
|
212
207
|
constructor(responseData) {
|
|
213
208
|
this.responseData = responseData;
|
|
214
209
|
}
|
|
215
210
|
}
|
|
216
|
-
exports.Response = Response;
|
|
217
211
|
/**
|
|
218
212
|
* Base class for policies.
|
|
219
213
|
*
|
|
220
214
|
* Policies checks if route can be executed eg. user have proper role
|
|
221
215
|
*/
|
|
222
|
-
class BasePolicy {
|
|
216
|
+
export class BasePolicy {
|
|
223
217
|
}
|
|
224
|
-
exports.BasePolicy = BasePolicy;
|
|
225
218
|
/**
|
|
226
219
|
* Base class for data transformers.
|
|
227
220
|
*
|
|
@@ -230,7 +223,6 @@ exports.BasePolicy = BasePolicy;
|
|
|
230
223
|
* to easily transform data for some client
|
|
231
224
|
* eg. plain array to format that datatables.net can easily read
|
|
232
225
|
*/
|
|
233
|
-
class DataTransformer {
|
|
226
|
+
export class DataTransformer {
|
|
234
227
|
}
|
|
235
|
-
exports.DataTransformer = DataTransformer;
|
|
236
228
|
//# sourceMappingURL=interfaces.js.map
|
package/lib/interfaces.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,YAAY,EAAE,MAAM,aAAa,CAAC;AAGxD;;GAEG;AACH,MAAM,CAAN,IAAY,iBAoBX;AApBD,WAAY,iBAAiB;IAC3B;;OAEG;IACH,yDAAQ,CAAA;IAER;;OAEG;IACH,yDAAQ,CAAA;IAER;;OAEG;IACH,uDAAO,CAAA;IAEP;;OAEG;IACH,uDAAe,CAAA;AACjB,CAAC,EApBW,iBAAiB,KAAjB,iBAAiB,QAoB5B;AAsCD,MAAM,OAAgB,gBAAiB,SAAQ,YAAY;CAK1D;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,gBA6EX;AA7ED,WAAY,gBAAgB;IAC1B;;OAEG;IACH,qDAAQ,CAAA;IAER;;OAEG;IACH,+DAAa,CAAA;IAEb;;OAEG;IACH,iEAAc,CAAA;IAEd;;OAEG;IACH,qEAAgB,CAAA;IAEhB;;;;OAIG;IACH,+EAAqB,CAAA;IAErB;;OAEG;IACH,yEAAkB,CAAA;IAElB;;OAEG;IACH,uEAAiB,CAAA;IAEjB;;OAEG;IACH,yEAAkB,CAAA;IAElB;;OAEG;IACH,mEAAe,CAAA;IAEf;;OAEG;IACH,mEAAe,CAAA;IAEf;;OAEG;IACH,6EAAoB,CAAA;IAEpB;;OAEG;IACH,uEAAiB,CAAA;IAEjB;;OAEG;IACH,iEAAc,CAAA;IAEd;;OAEG;IACH,6EAAoB,CAAA;IAEpB;;OAEG;IACH,+EAAqB,CAAA;AACvB,CAAC,EA7EW,gBAAgB,KAAhB,gBAAgB,QA6E3B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SAqCX;AArCD,WAAY,SAAS;IACnB;;OAEG;IACH,0BAAa,CAAA;IAEb;;OAEG;IACH,wBAAW,CAAA;IAEX;;OAEG;IACH,wBAAW,CAAA;IAEX;;OAEG;IACH,8BAAiB,CAAA;IAEjB;;OAEG;IACH,4BAAe,CAAA;IAEf;;OAEG;IACH,0BAAa,CAAA;IAEb;;OAEG;IACH,0BAAa,CAAA;IAEb,gCAAmB,CAAA;AACrB,CAAC,EArCW,SAAS,KAAT,SAAS,QAqCpB;AAED,MAAM,CAAN,IAAY,WAKX;AALD,WAAY,WAAW;IACrB,yCAAE,CAAA;IACF,yCAAE,CAAA;IACF,yCAAE,CAAA;IACF,yCAAE,CAAA;AACJ,CAAC,EALW,WAAW,KAAX,WAAW,QAKtB;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,aAyEX;AAzED,WAAY,aAAa;IACvB;;OAEG;IACH,kCAAiB,CAAA;IAEjB;;OAEG;IACH,wCAAuB,CAAA;IAEvB;;OAEG;IACH,sCAAqB,CAAA;IAErB;;OAEG;IACH,0CAAyB,CAAA;IAEzB;;OAEG;IACH,sCAAqB,CAAA;IAErB;;OAEG;IACH,sCAAqB,CAAA;IAErB;;OAEG;IACH,oCAAmB,CAAA;IAEnB;;OAEG;IACH,8CAA6B,CAAA;IAE7B;;OAEG;IACH,4CAA2B,CAAA;IAE3B;;OAEG;IACH,wCAAuB,CAAA;IAEvB;;OAEG;IACH,0CAAyB,CAAA;IAEzB;;OAEG;IACH,0CAAyB,CAAA;IAEzB;;OAEG;IACH,qCAAoB,CAAA;IAEpB,mBAAmB;IACnB,sCAAqB,CAAA;IAErB;;OAEG;IACH,gCAAe,CAAA;AACjB,CAAC,EAzEW,aAAa,KAAb,aAAa,QAyExB;AAqLD;;;GAGG;AACH,MAAM,OAAgB,eAAe;CAyBpC;AAaD,MAAM,OAAgB,QAAQ;IAC5B,YAAsB,YAAiB;QAAjB,iBAAY,GAAZ,YAAY,CAAK;IAAG,CAAC;CAG5C;AAED;;;;GAIG;AACH,MAAM,OAAgB,UAAU;CAgB/B;AA2BD;;;;;;;GAOG;AACH,MAAM,OAAgB,eAAe;CASpC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Response, NextFunction } from 'express';
|
|
2
|
-
import { ServerMiddleware, Request as sRequest } from '../interfaces';
|
|
2
|
+
import { ServerMiddleware, Request as sRequest } from '../interfaces.js';
|
|
3
3
|
import * as express from 'express';
|
|
4
4
|
export declare class RequestId extends ServerMiddleware {
|
|
5
5
|
constructor();
|
|
6
6
|
after(): (_req: sRequest, _res: express.Response, _next: express.NextFunction) => void;
|
|
7
7
|
before(): (req: sRequest, res: Response<any, Record<string, any>>, next: NextFunction) => void;
|
|
8
8
|
}
|
|
9
|
+
//# sourceMappingURL=RequestId.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RequestId.d.ts","sourceRoot":"","sources":["../../src/middlewares/RequestId.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAInC,qBACa,SAAU,SAAQ,gBAAgB;;IAMtC,KAAK,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,YAAY,KAAK,IAAI;IAItF,MAAM,IAAI,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,KAAK,IAAI;CAMtG"}
|
|
@@ -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,12 +7,10 @@ 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
|
-
|
|
15
|
-
const di_1 = require("@spinajs/di");
|
|
16
|
-
let RequestId = class RequestId extends interfaces_1.ServerMiddleware {
|
|
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 {
|
|
17
14
|
constructor() {
|
|
18
15
|
super();
|
|
19
16
|
this.Order = 1;
|
|
@@ -23,14 +20,14 @@ let RequestId = class RequestId extends interfaces_1.ServerMiddleware {
|
|
|
23
20
|
}
|
|
24
21
|
before() {
|
|
25
22
|
return (req, _res, next) => {
|
|
26
|
-
req.storage.requestId = (
|
|
23
|
+
req.storage.requestId = uuidv4();
|
|
27
24
|
next();
|
|
28
25
|
};
|
|
29
26
|
}
|
|
30
27
|
};
|
|
31
28
|
RequestId = __decorate([
|
|
32
|
-
|
|
29
|
+
Injectable(ServerMiddleware),
|
|
33
30
|
__metadata("design:paramtypes", [])
|
|
34
31
|
], RequestId);
|
|
35
|
-
|
|
32
|
+
export { RequestId };
|
|
36
33
|
//# sourceMappingURL=RequestId.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RequestId.js","sourceRoot":"","sources":["../../src/middlewares/RequestId.ts"],"names":[],"mappings":"
|
|
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;SAhBY,SAAS"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Request, Response, NextFunction } from 'express';
|
|
2
2
|
import { ParamsDictionary } from 'express-serve-static-core';
|
|
3
3
|
import { ParsedQs } from 'qs';
|
|
4
|
-
import { ServerMiddleware } from '../interfaces';
|
|
4
|
+
import { ServerMiddleware } from '../interfaces.js';
|
|
5
5
|
import * as express from 'express';
|
|
6
6
|
export declare class ResponseTime extends ServerMiddleware {
|
|
7
7
|
constructor();
|
|
8
8
|
after(): (req: express.Request, _res: express.Response, _next: express.NextFunction) => void;
|
|
9
9
|
before(): (_req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>>, next: NextFunction) => void;
|
|
10
10
|
}
|
|
11
|
+
//# sourceMappingURL=ResponseTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseTime.d.ts","sourceRoot":"","sources":["../../src/middlewares/ResponseTime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAuB,MAAM,kBAAkB,CAAC;AACzE,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,qBACa,YAAa,SAAQ,gBAAgB;;IAMzC,KAAK,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,YAAY,KAAK,IAAI;IAS5F,MAAM,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,gBAAgB,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,KAAK,IAAI;CAMjK"}
|
|
@@ -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,11 +7,9 @@ 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 ResponseTime = class ResponseTime extends interfaces_1.ServerMiddleware {
|
|
10
|
+
import { ServerMiddleware } from '../interfaces.js';
|
|
11
|
+
import { Injectable } from '@spinajs/di';
|
|
12
|
+
let ResponseTime = class ResponseTime extends ServerMiddleware {
|
|
16
13
|
constructor() {
|
|
17
14
|
super();
|
|
18
15
|
this.Order = -1;
|
|
@@ -33,8 +30,8 @@ let ResponseTime = class ResponseTime extends interfaces_1.ServerMiddleware {
|
|
|
33
30
|
}
|
|
34
31
|
};
|
|
35
32
|
ResponseTime = __decorate([
|
|
36
|
-
|
|
33
|
+
Injectable(ServerMiddleware),
|
|
37
34
|
__metadata("design:paramtypes", [])
|
|
38
35
|
], ResponseTime);
|
|
39
|
-
|
|
36
|
+
export { ResponseTime };
|
|
40
37
|
//# sourceMappingURL=ResponseTime.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseTime.js","sourceRoot":"","sources":["../../src/middlewares/ResponseTime.ts"],"names":[],"mappings":"
|
|
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;YACjE,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;AArBY,YAAY;IADxB,UAAU,CAAC,gBAAgB,CAAC;;GAChB,YAAY,CAqBxB;SArBY,YAAY"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
1
2
|
import * as express from 'express';
|
|
2
|
-
import { Response } from '../interfaces';
|
|
3
|
+
import { Response } from '../interfaces.js';
|
|
3
4
|
/**
|
|
4
5
|
* Internall response function.
|
|
5
6
|
* Returns HTTP 400 BAD REQUEST ERROR
|
|
@@ -9,3 +10,4 @@ export declare class BadRequest extends Response {
|
|
|
9
10
|
constructor(data: any);
|
|
10
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>;
|
|
11
12
|
}
|
|
13
|
+
//# sourceMappingURL=badRequest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"badRequest.d.ts","sourceRoot":"","sources":["../../src/response-methods/badRequest.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAoB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG9D;;;;GAIG;AAEH,qBAAa,UAAW,SAAQ,QAAQ;gBAC1B,IAAI,EAAE,GAAG;IAIR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ;CAGnE"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.BadRequest = void 0;
|
|
4
|
-
const interfaces_1 = require("../interfaces");
|
|
5
|
-
const responses_1 = require("../responses");
|
|
1
|
+
import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
|
|
2
|
+
import { httpResponse } from '../responses.js';
|
|
6
3
|
/**
|
|
7
4
|
* Internall response function.
|
|
8
5
|
* Returns HTTP 400 BAD REQUEST ERROR
|
|
9
6
|
* @param err - error to send
|
|
10
7
|
*/
|
|
11
|
-
class BadRequest extends
|
|
8
|
+
export class BadRequest extends Response {
|
|
12
9
|
constructor(data) {
|
|
13
10
|
super(data);
|
|
14
11
|
}
|
|
15
12
|
async execute(_req, _res) {
|
|
16
|
-
return await
|
|
13
|
+
return await httpResponse(this.responseData, HTTP_STATUS_CODE.BAD_REQUEST, 'responses/badRequest');
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
exports.BadRequest = BadRequest;
|
|
20
16
|
//# sourceMappingURL=badRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badRequest.js","sourceRoot":"","sources":["../../src/response-methods/badRequest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"badRequest.js","sourceRoot":"","sources":["../../src/response-methods/badRequest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;GAIG;AAEH,MAAM,OAAO,UAAW,SAAQ,QAAQ;IACtC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,WAAW,EAAE,sBAAsB,CAAC,CAAC;IACrG,CAAC;CACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
1
2
|
import * as express from 'express';
|
|
2
|
-
import { Response } from '../interfaces';
|
|
3
|
+
import { Response } from '../interfaces.js';
|
|
3
4
|
/**
|
|
4
5
|
* Internall response function.
|
|
5
6
|
* Returns HTTP 409 Conflict
|
|
@@ -9,3 +10,4 @@ export declare class Conflict extends Response {
|
|
|
9
10
|
constructor(data: any);
|
|
10
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>;
|
|
11
12
|
}
|
|
13
|
+
//# sourceMappingURL=conflict.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conflict.d.ts","sourceRoot":"","sources":["../../src/response-methods/conflict.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAoB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG9D;;;;GAIG;AAEH,qBAAa,QAAS,SAAQ,QAAQ;gBACxB,IAAI,EAAE,GAAG;IAIR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ;CAGnE"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Conflict = void 0;
|
|
4
|
-
const interfaces_1 = require("../interfaces");
|
|
5
|
-
const responses_1 = require("../responses");
|
|
1
|
+
import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
|
|
2
|
+
import { httpResponse } from '../responses.js';
|
|
6
3
|
/**
|
|
7
4
|
* Internall response function.
|
|
8
5
|
* Returns HTTP 409 Conflict
|
|
9
6
|
* @param err - error to send
|
|
10
7
|
*/
|
|
11
|
-
class Conflict extends
|
|
8
|
+
export class Conflict extends Response {
|
|
12
9
|
constructor(data) {
|
|
13
10
|
super(data);
|
|
14
11
|
}
|
|
15
12
|
async execute(_req, _res) {
|
|
16
|
-
return await
|
|
13
|
+
return await httpResponse(this.responseData, HTTP_STATUS_CODE.CONFLICT, 'responses/conflict');
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
exports.Conflict = Conflict;
|
|
20
16
|
//# sourceMappingURL=conflict.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conflict.js","sourceRoot":"","sources":["../../src/response-methods/conflict.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"conflict.js","sourceRoot":"","sources":["../../src/response-methods/conflict.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;GAIG;AAEH,MAAM,OAAO,QAAS,SAAQ,QAAQ;IACpC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IAChG,CAAC;CACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
1
2
|
import * as express from 'express';
|
|
2
|
-
import { ICookieOptions, Response } from '../interfaces';
|
|
3
|
+
import { ICookieOptions, Response } from '../interfaces.js';
|
|
3
4
|
/**
|
|
4
5
|
* Simpel wrapper for coockie response for api consistency.
|
|
5
6
|
* It also signs cookie with coockie-secure
|
|
@@ -16,3 +17,4 @@ export declare class CookieResponse extends Response {
|
|
|
16
17
|
constructor(name: string, coockieValue: string, cookieLifetime: number, signed?: boolean, data?: any, options?: ICookieOptions);
|
|
17
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>;
|
|
18
19
|
}
|
|
20
|
+
//# sourceMappingURL=cookieResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookieResponse.d.ts","sourceRoot":"","sources":["../../src/response-methods/cookieResponse.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAKnC,OAAO,EAAoB,cAAc,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG9E;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,QAAQ;IAC9B,SAAS,CAAC,IAAI,EAAE,MAAM;IAAE,SAAS,CAAC,YAAY,EAAE,MAAM;IAAE,SAAS,CAAC,cAAc,EAAE,MAAM;IAAE,SAAS,CAAC,MAAM,CAAC,EAAE,OAAO;IAAE,SAAS,CAAC,IAAI,CAAC,EAAE,GAAG;IAAE,SAAS,CAAC,OAAO,CAAC,EAAE,cAAc;gBAApK,IAAI,EAAE,MAAM,EAAY,YAAY,EAAE,MAAM,EAAY,cAAc,EAAE,MAAM,EAAY,MAAM,CAAC,EAAE,OAAO,EAAY,IAAI,CAAC,EAAE,GAAG,EAAY,OAAO,CAAC,EAAE,cAAc;IAI7K,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ;CA2BlE"}
|
|
@@ -1,41 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
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.CookieResponse = void 0;
|
|
27
|
-
const responses_1 = require("../responses");
|
|
28
|
-
const configuration_1 = require("@spinajs/configuration");
|
|
29
|
-
const di_1 = require("@spinajs/di");
|
|
30
|
-
const cs = __importStar(require("cookie-signature"));
|
|
31
|
-
const interfaces_1 = require("../interfaces");
|
|
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';
|
|
32
6
|
/**
|
|
33
7
|
* Simpel wrapper for coockie response for api consistency.
|
|
34
8
|
* It also signs cookie with coockie-secure
|
|
35
9
|
*
|
|
36
10
|
* @param cookieLifetime - cookie max age in seconds
|
|
37
11
|
*/
|
|
38
|
-
class CookieResponse extends
|
|
12
|
+
export class CookieResponse extends Response {
|
|
39
13
|
constructor(name, coockieValue, cookieLifetime, signed, data, options) {
|
|
40
14
|
super(coockieValue);
|
|
41
15
|
this.name = name;
|
|
@@ -46,7 +20,7 @@ class CookieResponse extends interfaces_1.Response {
|
|
|
46
20
|
this.options = options;
|
|
47
21
|
}
|
|
48
22
|
async execute(_req, res) {
|
|
49
|
-
const cfg =
|
|
23
|
+
const cfg = DI.get(Configuration);
|
|
50
24
|
const opt = cfg.get('http.cookie.options', {});
|
|
51
25
|
if (this.options) {
|
|
52
26
|
Object.assign(opt, this.options);
|
|
@@ -67,8 +41,7 @@ class CookieResponse extends interfaces_1.Response {
|
|
|
67
41
|
res.cookie(this.name, this.responseData, opt);
|
|
68
42
|
}
|
|
69
43
|
}
|
|
70
|
-
return await
|
|
44
|
+
return await httpResponse(this.data, HTTP_STATUS_CODE.OK, 'responses/ok');
|
|
71
45
|
}
|
|
72
46
|
}
|
|
73
|
-
exports.CookieResponse = CookieResponse;
|
|
74
47
|
//# sourceMappingURL=cookieResponse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cookieResponse.js","sourceRoot":"","sources":["../../src/response-methods/cookieResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cookieResponse.js","sourceRoot":"","sources":["../../src/response-methods/cookieResponse.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAkB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG9E;;;;;GAKG;AACH,MAAM,OAAO,cAAe,SAAQ,QAAQ;IAC1C,YAAsB,IAAY,EAAY,YAAoB,EAAY,cAAsB,EAAY,MAAgB,EAAY,IAAU,EAAY,OAAwB;QACxL,KAAK,CAAC,YAAY,CAAC,CAAC;QADA,SAAI,GAAJ,IAAI,CAAQ;QAAY,iBAAY,GAAZ,YAAY,CAAQ;QAAY,mBAAc,GAAd,cAAc,CAAQ;QAAY,WAAM,GAAN,MAAM,CAAU;QAAY,SAAI,GAAJ,IAAI,CAAM;QAAY,YAAO,GAAP,OAAO,CAAiB;IAE1L,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,GAAqB;QAC/D,MAAM,GAAG,GAAkB,EAAE,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAgB,qBAAqB,EAAE,EAAE,CAAC,CAAC;QAE9D,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;SAClC;QAED,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,cAAc,GAAG,IAAI,EAAE,CAAC,CAAC;SAC5D;QAED,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE;YACtB,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,GAAoB,CAAC,CAAC;SAClD;aAAM;YACL,IAAI,IAAI,CAAC,MAAM,EAAE;gBACf,MAAM,SAAS,GAAG,GAAG,CAAC,GAAG,CAAS,oBAAoB,CAAC,CAAC;gBACxD,MAAM,MAAM,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;gBAErD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAU,CAAC,CAAC;aAC3C;iBAAM;gBACL,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,GAAU,CAAC,CAAC;aACtD;SACF;QAED,OAAO,MAAM,YAAY,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAC5E,CAAC;CACF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="qs" />
|
|
1
2
|
import * as express from 'express';
|
|
2
|
-
import { Response } from '../interfaces';
|
|
3
|
+
import { Response } from '../interfaces.js';
|
|
3
4
|
/**
|
|
4
5
|
* Internall response function.
|
|
5
6
|
* Returns HTTP 201 CREATED
|
|
@@ -9,3 +10,4 @@ export declare class Created extends Response {
|
|
|
9
10
|
constructor(data: any);
|
|
10
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>;
|
|
11
12
|
}
|
|
13
|
+
//# sourceMappingURL=created.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"created.d.ts","sourceRoot":"","sources":["../../src/response-methods/created.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAoB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG9D;;;;GAIG;AACH,qBAAa,OAAQ,SAAQ,QAAQ;gBACvB,IAAI,EAAE,GAAG;IAIR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,QAAQ;CAGnE"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Created = void 0;
|
|
4
|
-
const interfaces_1 = require("../interfaces");
|
|
5
|
-
const responses_1 = require("../responses");
|
|
1
|
+
import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
|
|
2
|
+
import { httpResponse } from '../responses.js';
|
|
6
3
|
/**
|
|
7
4
|
* Internall response function.
|
|
8
5
|
* Returns HTTP 201 CREATED
|
|
9
6
|
* @param data - additional data eg. model pk
|
|
10
7
|
*/
|
|
11
|
-
class Created extends
|
|
8
|
+
export class Created extends Response {
|
|
12
9
|
constructor(data) {
|
|
13
10
|
super(data);
|
|
14
11
|
}
|
|
15
12
|
async execute(_req, _res) {
|
|
16
|
-
return await
|
|
13
|
+
return await httpResponse(this.responseData, HTTP_STATUS_CODE.CREATED, 'responses/created');
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
exports.Created = Created;
|
|
20
16
|
//# sourceMappingURL=created.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"created.js","sourceRoot":"","sources":["../../src/response-methods/created.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"created.js","sourceRoot":"","sources":["../../src/response-methods/created.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;;;GAIG;AACH,MAAM,OAAO,OAAQ,SAAQ,QAAQ;IACnC,YAAY,IAAS;QACnB,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,OAAO,CAAC,IAAqB,EAAE,IAAsB;QAChE,OAAO,MAAM,YAAY,CAAC,IAAI,CAAC,YAAY,EAAE,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;IAC9F,CAAC;CACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as express from 'express';
|
|
2
|
-
import { IFileResponseOptions, Response } from './../interfaces';
|
|
2
|
+
import { IFileResponseOptions, Response } from './../interfaces.js';
|
|
3
3
|
export declare class ZipResponse extends Response {
|
|
4
4
|
protected Options: IFileResponseOptions;
|
|
5
5
|
/**
|
|
@@ -24,3 +24,4 @@ export declare class JsonFileResponse extends Response {
|
|
|
24
24
|
constructor(data: any, filename: string);
|
|
25
25
|
execute(_req: express.Request, res: express.Response): Promise<void>;
|
|
26
26
|
}
|
|
27
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/response-methods/file.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAGpE,qBAAa,WAAY,SAAQ,QAAQ;IAK3B,SAAS,CAAC,OAAO,EAAE,oBAAoB;IAJnD;;;OAGG;gBACmB,OAAO,EAAE,oBAAoB;IAMtC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CA8BlF;AAED,qBAAa,YAAa,SAAQ,QAAQ;IAK5B,SAAS,CAAC,OAAO,EAAE,oBAAoB;IAJnD;;;OAGG;gBACmB,OAAO,EAAE,oBAAoB;IAMtC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CA2BlF;AAED,qBAAa,gBAAiB,SAAQ,QAAQ;IAChC,SAAS,CAAC,IAAI,EAAE,GAAG;IAAE,SAAS,CAAC,QAAQ,EAAE,MAAM;gBAArC,IAAI,EAAE,GAAG,EAAY,QAAQ,EAAE,MAAM;IAI9C,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;CAsBlF"}
|
|
@@ -1,50 +1,23 @@
|
|
|
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.JsonFileResponse = exports.FileResponse = exports.ZipResponse = void 0;
|
|
27
|
-
const di_1 = require("@spinajs/di");
|
|
28
|
-
const exceptions_1 = require("@spinajs/exceptions");
|
|
29
|
-
const _ = __importStar(require("lodash"));
|
|
30
|
-
const mime_1 = require("mime");
|
|
31
|
-
const interfaces_1 = require("./../interfaces");
|
|
32
|
-
class ZipResponse extends interfaces_1.Response {
|
|
1
|
+
import { DI } from '@spinajs/di';
|
|
2
|
+
import { ResourceNotFound } from '../../../exceptions/lib/index.js';
|
|
3
|
+
import _ from 'lodash';
|
|
4
|
+
import { getType } from 'mime';
|
|
5
|
+
import { Response } from './../interfaces.js';
|
|
6
|
+
export class ZipResponse extends Response {
|
|
33
7
|
/**
|
|
34
8
|
* Sends zipped to client at given path & filename. If file exists
|
|
35
9
|
* it will send file with 200 OK, if not exists 404 NOT FOUND
|
|
36
10
|
*/
|
|
37
11
|
constructor(Options) {
|
|
38
|
-
var _a;
|
|
39
12
|
super(null);
|
|
40
13
|
this.Options = Options;
|
|
41
|
-
this.Options.mimeType =
|
|
14
|
+
this.Options.mimeType = Options.mimeType ?? getType(Options.filename);
|
|
42
15
|
}
|
|
43
16
|
async execute(_req, res) {
|
|
44
|
-
const provider = await
|
|
17
|
+
const provider = await DI.resolve('__file_provider__', [this.Options.provider]);
|
|
45
18
|
const exists = await provider.exists(this.Options.path);
|
|
46
19
|
if (!exists) {
|
|
47
|
-
throw new
|
|
20
|
+
throw new ResourceNotFound(`File ${this.Options.path} not exists`);
|
|
48
21
|
}
|
|
49
22
|
const file = (await provider.zip(this.Options.path)).asFilePath();
|
|
50
23
|
return new Promise((resolve, reject) => {
|
|
@@ -69,23 +42,21 @@ class ZipResponse extends interfaces_1.Response {
|
|
|
69
42
|
});
|
|
70
43
|
}
|
|
71
44
|
}
|
|
72
|
-
|
|
73
|
-
class FileResponse extends interfaces_1.Response {
|
|
45
|
+
export class FileResponse extends Response {
|
|
74
46
|
/**
|
|
75
47
|
* Sends file to client at given path & filename. If file exists
|
|
76
48
|
* it will send file with 200 OK, if not exists 404 NOT FOUND
|
|
77
49
|
*/
|
|
78
50
|
constructor(Options) {
|
|
79
|
-
var _a;
|
|
80
51
|
super(null);
|
|
81
52
|
this.Options = Options;
|
|
82
|
-
this.Options.mimeType =
|
|
53
|
+
this.Options.mimeType = Options.mimeType ?? getType(Options.filename);
|
|
83
54
|
}
|
|
84
55
|
async execute(_req, res) {
|
|
85
|
-
const provider = await
|
|
56
|
+
const provider = await DI.resolve('__file_provider__', [this.Options.provider]);
|
|
86
57
|
const exists = await provider.exists(this.Options.path);
|
|
87
58
|
if (!exists) {
|
|
88
|
-
throw new
|
|
59
|
+
throw new ResourceNotFound(`File ${this.Options.path} not exists`);
|
|
89
60
|
}
|
|
90
61
|
const file = await provider.download(this.Options.path);
|
|
91
62
|
return new Promise((resolve, reject) => {
|
|
@@ -107,15 +78,14 @@ class FileResponse extends interfaces_1.Response {
|
|
|
107
78
|
});
|
|
108
79
|
}
|
|
109
80
|
}
|
|
110
|
-
|
|
111
|
-
class JsonFileResponse extends interfaces_1.Response {
|
|
81
|
+
export class JsonFileResponse extends Response {
|
|
112
82
|
constructor(data, filename) {
|
|
113
83
|
super(null);
|
|
114
84
|
this.data = data;
|
|
115
85
|
this.filename = filename;
|
|
116
86
|
}
|
|
117
87
|
async execute(_req, res) {
|
|
118
|
-
const provider = await
|
|
88
|
+
const provider = await DI.resolve('__file_provider__', ['fs-temp']);
|
|
119
89
|
const tmpPath = provider.tmppath();
|
|
120
90
|
provider.write(tmpPath, JSON.stringify(this.data));
|
|
121
91
|
return new Promise((resolve, reject) => {
|
|
@@ -137,5 +107,4 @@ class JsonFileResponse extends interfaces_1.Response {
|
|
|
137
107
|
});
|
|
138
108
|
}
|
|
139
109
|
}
|
|
140
|
-
exports.JsonFileResponse = JsonFileResponse;
|
|
141
110
|
//# sourceMappingURL=file.js.map
|