@spinajs/http 2.0.264 → 2.0.266
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.js +1 -1
- package/lib/cjs/bootstrap.js.map +1 -1
- package/lib/cjs/decorators.d.ts +2 -1
- package/lib/cjs/decorators.d.ts.map +1 -1
- package/lib/cjs/decorators.js +11 -1
- package/lib/cjs/decorators.js.map +1 -1
- package/lib/cjs/interfaces.d.ts +6 -3
- package/lib/cjs/interfaces.d.ts.map +1 -1
- package/lib/cjs/interfaces.js +10 -1
- package/lib/cjs/interfaces.js.map +1 -1
- package/lib/cjs/response-methods/badRequest.d.ts +4 -5
- package/lib/cjs/response-methods/badRequest.d.ts.map +1 -1
- package/lib/cjs/response-methods/badRequest.js +22 -22
- package/lib/cjs/response-methods/badRequest.js.map +1 -1
- package/lib/cjs/response-methods/conflict.d.ts +6 -7
- package/lib/cjs/response-methods/conflict.d.ts.map +1 -1
- package/lib/cjs/response-methods/conflict.js +23 -12
- package/lib/cjs/response-methods/conflict.js.map +1 -1
- package/lib/cjs/response-methods/created.d.ts +3 -4
- package/lib/cjs/response-methods/created.d.ts.map +1 -1
- package/lib/cjs/response-methods/created.js +3 -9
- package/lib/cjs/response-methods/created.js.map +1 -1
- package/lib/cjs/response-methods/entityTooLarge.d.ts +3 -4
- package/lib/cjs/response-methods/entityTooLarge.d.ts.map +1 -1
- package/lib/cjs/response-methods/entityTooLarge.js +22 -11
- package/lib/cjs/response-methods/entityTooLarge.js.map +1 -1
- package/lib/cjs/response-methods/forbidden.d.ts +6 -7
- package/lib/cjs/response-methods/forbidden.d.ts.map +1 -1
- package/lib/cjs/response-methods/forbidden.js +24 -13
- package/lib/cjs/response-methods/forbidden.js.map +1 -1
- package/lib/cjs/response-methods/noContent.d.ts +6 -7
- package/lib/cjs/response-methods/noContent.d.ts.map +1 -1
- package/lib/cjs/response-methods/noContent.js +4 -10
- package/lib/cjs/response-methods/noContent.js.map +1 -1
- package/lib/cjs/response-methods/notAcceptable.d.ts +6 -7
- package/lib/cjs/response-methods/notAcceptable.d.ts.map +1 -1
- package/lib/cjs/response-methods/notAcceptable.js +4 -10
- package/lib/cjs/response-methods/notAcceptable.js.map +1 -1
- package/lib/cjs/response-methods/notAllowed.d.ts +6 -7
- package/lib/cjs/response-methods/notAllowed.d.ts.map +1 -1
- package/lib/cjs/response-methods/notAllowed.js +4 -10
- package/lib/cjs/response-methods/notAllowed.js.map +1 -1
- package/lib/cjs/response-methods/notFound.d.ts +6 -7
- package/lib/cjs/response-methods/notFound.d.ts.map +1 -1
- package/lib/cjs/response-methods/notFound.js +22 -11
- package/lib/cjs/response-methods/notFound.js.map +1 -1
- package/lib/cjs/response-methods/ok.d.ts +3 -4
- package/lib/cjs/response-methods/ok.d.ts.map +1 -1
- package/lib/cjs/response-methods/ok.js +3 -9
- package/lib/cjs/response-methods/ok.js.map +1 -1
- package/lib/cjs/response-methods/serverError.d.ts +6 -7
- package/lib/cjs/response-methods/serverError.d.ts.map +1 -1
- package/lib/cjs/response-methods/serverError.js +22 -11
- package/lib/cjs/response-methods/serverError.js.map +1 -1
- package/lib/cjs/response-methods/unauthorized.d.ts +6 -7
- package/lib/cjs/response-methods/unauthorized.d.ts.map +1 -1
- package/lib/cjs/response-methods/unauthorized.js +22 -11
- package/lib/cjs/response-methods/unauthorized.js.map +1 -1
- package/lib/cjs/response-methods/validationError.d.ts +6 -7
- package/lib/cjs/response-methods/validationError.d.ts.map +1 -1
- package/lib/cjs/response-methods/validationError.js +22 -11
- package/lib/cjs/response-methods/validationError.js.map +1 -1
- package/lib/cjs/responses.d.ts.map +1 -1
- package/lib/cjs/responses.js +19 -11
- package/lib/cjs/responses.js.map +1 -1
- package/lib/cjs/route-args/FromParams.d.ts +9 -1
- package/lib/cjs/route-args/FromParams.d.ts.map +1 -1
- package/lib/cjs/route-args/FromParams.js +18 -2
- package/lib/cjs/route-args/FromParams.js.map +1 -1
- package/lib/cjs/route-args/FromQuery.d.ts +9 -1
- package/lib/cjs/route-args/FromQuery.d.ts.map +1 -1
- package/lib/cjs/route-args/FromQuery.js +17 -2
- package/lib/cjs/route-args/FromQuery.js.map +1 -1
- package/lib/cjs/server.d.ts +1 -0
- package/lib/cjs/server.d.ts.map +1 -1
- package/lib/cjs/server.js +21 -39
- package/lib/cjs/server.js.map +1 -1
- package/lib/cjs/transformers/DefaultErrorTransform.d.ts +17 -0
- package/lib/cjs/transformers/DefaultErrorTransform.d.ts.map +1 -0
- package/lib/cjs/transformers/DefaultErrorTransform.js +28 -0
- package/lib/cjs/transformers/DefaultErrorTransform.js.map +1 -0
- package/lib/cjs/transformers/index.d.ts +1 -0
- package/lib/cjs/transformers/index.d.ts.map +1 -1
- package/lib/cjs/transformers/index.js +1 -0
- package/lib/cjs/transformers/index.js.map +1 -1
- package/lib/mjs/bootstrap.js +1 -1
- package/lib/mjs/bootstrap.js.map +1 -1
- package/lib/mjs/decorators.d.ts +2 -1
- package/lib/mjs/decorators.d.ts.map +1 -1
- package/lib/mjs/decorators.js +9 -0
- package/lib/mjs/decorators.js.map +1 -1
- package/lib/mjs/interfaces.d.ts +6 -3
- package/lib/mjs/interfaces.d.ts.map +1 -1
- package/lib/mjs/interfaces.js +10 -1
- package/lib/mjs/interfaces.js.map +1 -1
- package/lib/mjs/response-methods/badRequest.d.ts +4 -5
- package/lib/mjs/response-methods/badRequest.d.ts.map +1 -1
- package/lib/mjs/response-methods/badRequest.js +23 -19
- package/lib/mjs/response-methods/badRequest.js.map +1 -1
- package/lib/mjs/response-methods/conflict.d.ts +6 -7
- package/lib/mjs/response-methods/conflict.d.ts.map +1 -1
- package/lib/mjs/response-methods/conflict.js +25 -13
- package/lib/mjs/response-methods/conflict.js.map +1 -1
- package/lib/mjs/response-methods/created.d.ts +3 -4
- package/lib/mjs/response-methods/created.d.ts.map +1 -1
- package/lib/mjs/response-methods/created.js +3 -9
- package/lib/mjs/response-methods/created.js.map +1 -1
- package/lib/mjs/response-methods/entityTooLarge.d.ts +3 -4
- package/lib/mjs/response-methods/entityTooLarge.d.ts.map +1 -1
- package/lib/mjs/response-methods/entityTooLarge.js +23 -11
- package/lib/mjs/response-methods/entityTooLarge.js.map +1 -1
- package/lib/mjs/response-methods/forbidden.d.ts +6 -7
- package/lib/mjs/response-methods/forbidden.d.ts.map +1 -1
- package/lib/mjs/response-methods/forbidden.js +24 -12
- package/lib/mjs/response-methods/forbidden.js.map +1 -1
- package/lib/mjs/response-methods/noContent.d.ts +6 -7
- package/lib/mjs/response-methods/noContent.d.ts.map +1 -1
- package/lib/mjs/response-methods/noContent.js +5 -11
- package/lib/mjs/response-methods/noContent.js.map +1 -1
- package/lib/mjs/response-methods/notAcceptable.d.ts +6 -7
- package/lib/mjs/response-methods/notAcceptable.d.ts.map +1 -1
- package/lib/mjs/response-methods/notAcceptable.js +5 -11
- package/lib/mjs/response-methods/notAcceptable.js.map +1 -1
- package/lib/mjs/response-methods/notAllowed.d.ts +6 -7
- package/lib/mjs/response-methods/notAllowed.d.ts.map +1 -1
- package/lib/mjs/response-methods/notAllowed.js +5 -11
- package/lib/mjs/response-methods/notAllowed.js.map +1 -1
- package/lib/mjs/response-methods/notFound.d.ts +6 -7
- package/lib/mjs/response-methods/notFound.d.ts.map +1 -1
- package/lib/mjs/response-methods/notFound.js +24 -12
- package/lib/mjs/response-methods/notFound.js.map +1 -1
- package/lib/mjs/response-methods/ok.d.ts +3 -4
- package/lib/mjs/response-methods/ok.d.ts.map +1 -1
- package/lib/mjs/response-methods/ok.js +3 -9
- package/lib/mjs/response-methods/ok.js.map +1 -1
- package/lib/mjs/response-methods/serverError.d.ts +6 -7
- package/lib/mjs/response-methods/serverError.d.ts.map +1 -1
- package/lib/mjs/response-methods/serverError.js +24 -12
- package/lib/mjs/response-methods/serverError.js.map +1 -1
- package/lib/mjs/response-methods/unauthorized.d.ts +6 -7
- package/lib/mjs/response-methods/unauthorized.d.ts.map +1 -1
- package/lib/mjs/response-methods/unauthorized.js +24 -12
- package/lib/mjs/response-methods/unauthorized.js.map +1 -1
- package/lib/mjs/response-methods/validationError.d.ts +6 -7
- package/lib/mjs/response-methods/validationError.d.ts.map +1 -1
- package/lib/mjs/response-methods/validationError.js +24 -12
- package/lib/mjs/response-methods/validationError.js.map +1 -1
- package/lib/mjs/responses.d.ts.map +1 -1
- package/lib/mjs/responses.js +19 -11
- package/lib/mjs/responses.js.map +1 -1
- package/lib/mjs/route-args/FromParams.d.ts +9 -1
- package/lib/mjs/route-args/FromParams.d.ts.map +1 -1
- package/lib/mjs/route-args/FromParams.js +18 -2
- package/lib/mjs/route-args/FromParams.js.map +1 -1
- package/lib/mjs/route-args/FromQuery.d.ts +9 -1
- package/lib/mjs/route-args/FromQuery.d.ts.map +1 -1
- package/lib/mjs/route-args/FromQuery.js +17 -2
- package/lib/mjs/route-args/FromQuery.js.map +1 -1
- package/lib/mjs/server.d.ts +1 -0
- package/lib/mjs/server.d.ts.map +1 -1
- package/lib/mjs/server.js +23 -41
- package/lib/mjs/server.js.map +1 -1
- package/lib/mjs/transformers/DefaultErrorTransform.d.ts +17 -0
- package/lib/mjs/transformers/DefaultErrorTransform.d.ts.map +1 -0
- package/lib/mjs/transformers/DefaultErrorTransform.js +25 -0
- package/lib/mjs/transformers/DefaultErrorTransform.js.map +1 -0
- package/lib/mjs/transformers/index.d.ts +1 -0
- package/lib/mjs/transformers/index.d.ts.map +1 -1
- package/lib/mjs/transformers/index.js +1 -0
- package/lib/mjs/transformers/index.js.map +1 -1
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +11 -11
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { IResponseOptions } from '../interfaces.js';
|
|
4
|
-
import { BadRequest } from './badRequest.js';
|
|
1
|
+
import { HTTP_STATUS_CODE, IResponseOptions } from '../interfaces.js';
|
|
2
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
5
3
|
/**
|
|
6
4
|
* Internall response function.
|
|
7
5
|
* Returns HTTP 406 NOT ACCEPTABLE
|
|
8
6
|
* When content requested in accept header format cannot be returned.
|
|
9
7
|
* @param err - error to send
|
|
10
8
|
*/
|
|
11
|
-
export declare class NotAcceptable extends
|
|
9
|
+
export declare class NotAcceptable extends BadRequestResponse {
|
|
12
10
|
protected options?: IResponseOptions;
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
protected _errorCode: HTTP_STATUS_CODE;
|
|
12
|
+
protected _template: string;
|
|
13
|
+
constructor(data: string | object | Promise<unknown>, options?: IResponseOptions);
|
|
15
14
|
}
|
|
16
15
|
//# sourceMappingURL=notAcceptable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notAcceptable.d.ts","sourceRoot":"","sources":["../../../src/response-methods/notAcceptable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notAcceptable.d.ts","sourceRoot":"","sources":["../../../src/response-methods/notAcceptable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,kBAAkB;IAIG,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB;IAH1F,SAAS,CAAC,UAAU,mBAAmC;IACvD,SAAS,CAAC,SAAS,SAAuB;gBAE9B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,EAAY,OAAO,CAAC,EAAE,gBAAgB;CAG3F"}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import { HTTP_STATUS_CODE } from '../interfaces.js';
|
|
2
|
-
import {
|
|
3
|
-
import { BadRequest } from './badRequest.js';
|
|
2
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
4
3
|
/**
|
|
5
4
|
* Internall response function.
|
|
6
5
|
* Returns HTTP 406 NOT ACCEPTABLE
|
|
7
6
|
* When content requested in accept header format cannot be returned.
|
|
8
7
|
* @param err - error to send
|
|
9
8
|
*/
|
|
10
|
-
export class NotAcceptable extends
|
|
9
|
+
export class NotAcceptable extends BadRequestResponse {
|
|
11
10
|
constructor(data, options) {
|
|
12
|
-
super(data);
|
|
11
|
+
super(data, options);
|
|
13
12
|
this.options = options;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const response = await this.prepareResponse();
|
|
17
|
-
return await httpResponse(response, 'notAcceptable.pug', {
|
|
18
|
-
...this.options,
|
|
19
|
-
StatusCode: HTTP_STATUS_CODE.NOT_ACCEPTABLE
|
|
20
|
-
});
|
|
13
|
+
this._errorCode = HTTP_STATUS_CODE.NOT_ACCEPTABLE;
|
|
14
|
+
this._template = 'notAcceptable.pug';
|
|
21
15
|
}
|
|
22
16
|
}
|
|
23
17
|
//# sourceMappingURL=notAcceptable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notAcceptable.js","sourceRoot":"","sources":["../../../src/response-methods/notAcceptable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notAcceptable.js","sourceRoot":"","sources":["../../../src/response-methods/notAcceptable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;;GAKG;AACH,MAAM,OAAO,aAAc,SAAQ,kBAAkB;IAInD,YAAY,IAAwC,EAAY,OAA0B;QACxF,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QADyC,YAAO,GAAP,OAAO,CAAmB;QAHhF,eAAU,GAAG,gBAAgB,CAAC,cAAc,CAAC;QAC7C,cAAS,GAAG,mBAAmB,CAAC;IAI1C,CAAC;CACF"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { IResponseOptions } from '../interfaces.js';
|
|
4
|
-
import { BadRequest } from './badRequest.js';
|
|
1
|
+
import { HTTP_STATUS_CODE, IResponseOptions } from '../interfaces.js';
|
|
2
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
5
3
|
/**
|
|
6
4
|
* Internall response function.
|
|
7
5
|
* Returns HTTP 403 FORBIDDEN ERROR
|
|
8
6
|
* @param err - error to send
|
|
9
7
|
*/
|
|
10
|
-
export declare class NotAllowed extends
|
|
8
|
+
export declare class NotAllowed extends BadRequestResponse {
|
|
11
9
|
protected options?: IResponseOptions;
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
protected _errorCode: HTTP_STATUS_CODE;
|
|
11
|
+
protected _template: string;
|
|
12
|
+
constructor(data: string | object | Promise<unknown>, options?: IResponseOptions);
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=notAllowed.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notAllowed.d.ts","sourceRoot":"","sources":["../../../src/response-methods/notAllowed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notAllowed.d.ts","sourceRoot":"","sources":["../../../src/response-methods/notAllowed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;GAIG;AAEH,qBAAa,UAAW,SAAQ,kBAAkB;IAIM,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB;IAH1F,SAAS,CAAC,UAAU,mBAAgC;IACpD,SAAS,CAAC,SAAS,SAAqB;gBAE5B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,EAAY,OAAO,CAAC,EAAE,gBAAgB;CAG3F"}
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
import { HTTP_STATUS_CODE } from '../interfaces.js';
|
|
2
|
-
import {
|
|
3
|
-
import { BadRequest } from './badRequest.js';
|
|
2
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
4
3
|
/**
|
|
5
4
|
* Internall response function.
|
|
6
5
|
* Returns HTTP 403 FORBIDDEN ERROR
|
|
7
6
|
* @param err - error to send
|
|
8
7
|
*/
|
|
9
|
-
export class NotAllowed extends
|
|
8
|
+
export class NotAllowed extends BadRequestResponse {
|
|
10
9
|
constructor(data, options) {
|
|
11
|
-
super(data);
|
|
10
|
+
super(data, options);
|
|
12
11
|
this.options = options;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const response = await this.prepareResponse();
|
|
16
|
-
return await httpResponse(response, 'not-allowed.pug', {
|
|
17
|
-
...this.options,
|
|
18
|
-
StatusCode: HTTP_STATUS_CODE.NOT_ALLOWED,
|
|
19
|
-
});
|
|
12
|
+
this._errorCode = HTTP_STATUS_CODE.NOT_ALLOWED;
|
|
13
|
+
this._template = 'not-allowed.pug';
|
|
20
14
|
}
|
|
21
15
|
}
|
|
22
16
|
//# sourceMappingURL=notAllowed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notAllowed.js","sourceRoot":"","sources":["../../../src/response-methods/notAllowed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notAllowed.js","sourceRoot":"","sources":["../../../src/response-methods/notAllowed.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD;;;;GAIG;AAEH,MAAM,OAAO,UAAW,SAAQ,kBAAkB;IAIhD,YAAY,IAAwC,EAAY,OAA0B;QACxF,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QADyC,YAAO,GAAP,OAAO,CAAmB;QAHhF,eAAU,GAAG,gBAAgB,CAAC,WAAW,CAAC;QAC1C,cAAS,GAAG,iBAAiB,CAAC;IAIxC,CAAC;CACF"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { IResponseOptions } from '../interfaces.js';
|
|
4
|
-
import { BadRequest } from './badRequest.js';
|
|
1
|
+
import { HTTP_STATUS_CODE, IResponseOptions } from '../interfaces.js';
|
|
2
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
5
3
|
/**
|
|
6
4
|
* Internall response function.
|
|
7
5
|
* Returns HTTP 404 NOT FOUND ERROR
|
|
8
6
|
* @param err - error to send
|
|
9
7
|
*/
|
|
10
|
-
export declare class NotFound extends
|
|
8
|
+
export declare class NotFound extends BadRequestResponse {
|
|
11
9
|
protected options?: IResponseOptions;
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
protected _errorCode: HTTP_STATUS_CODE;
|
|
11
|
+
protected _template: string;
|
|
12
|
+
constructor(data: string | object | Promise<unknown>, options?: IResponseOptions);
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=notFound.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/response-methods/notFound.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../../src/response-methods/notFound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAKrD;;;;GAIG;AACH,qBAEa,QAAS,SAAQ,kBAAkB;IAIQ,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB;IAH1F,SAAS,CAAC,UAAU,mBAA8B;IAClD,SAAS,CAAC,SAAS,SAAkB;gBAEzB,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,EAAY,OAAO,CAAC,EAAE,gBAAgB;CAG3F"}
|
|
@@ -1,22 +1,34 @@
|
|
|
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
|
+
};
|
|
1
10
|
import { HTTP_STATUS_CODE } from '../interfaces.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
11
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
12
|
+
import { HandleException } from '../decorators.js';
|
|
13
|
+
import { ResourceNotFound } from '@spinajs/exceptions';
|
|
14
|
+
import { Injectable } from '@spinajs/di';
|
|
4
15
|
/**
|
|
5
16
|
* Internall response function.
|
|
6
17
|
* Returns HTTP 404 NOT FOUND ERROR
|
|
7
18
|
* @param err - error to send
|
|
8
19
|
*/
|
|
9
|
-
|
|
20
|
+
let NotFound = class NotFound extends BadRequestResponse {
|
|
10
21
|
constructor(data, options) {
|
|
11
|
-
super(data);
|
|
22
|
+
super(data, options);
|
|
12
23
|
this.options = options;
|
|
24
|
+
this._errorCode = HTTP_STATUS_CODE.NOT_FOUND;
|
|
25
|
+
this._template = 'notFound.pug';
|
|
13
26
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
27
|
+
};
|
|
28
|
+
NotFound = __decorate([
|
|
29
|
+
HandleException(ResourceNotFound),
|
|
30
|
+
Injectable(Response),
|
|
31
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
32
|
+
], NotFound);
|
|
33
|
+
export { NotFound };
|
|
22
34
|
//# sourceMappingURL=notFound.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notFound.js","sourceRoot":"","sources":["../../../src/response-methods/notFound.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notFound.js","sourceRoot":"","sources":["../../../src/response-methods/notFound.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AAGI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,kBAAkB;IAI9C,YAAY,IAAwC,EAAY,OAA0B;QACxF,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QADyC,YAAO,GAAP,OAAO,CAAmB;QAHhF,eAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC;QACxC,cAAS,GAAG,cAAc,CAAC;IAIrC,CAAC;CACF,CAAA;AAPY,QAAQ;IAFpB,eAAe,CAAC,gBAAgB,CAAC;IACjC,UAAU,CAAC,QAAQ,CAAC;;GACR,QAAQ,CAOpB"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import * as express from 'express';
|
|
3
|
-
import { IResponseOptions, Response } from '../interfaces.js';
|
|
1
|
+
import { HTTP_STATUS_CODE, IResponseOptions, Response } from '../interfaces.js';
|
|
4
2
|
/**
|
|
5
3
|
* Internall response function.
|
|
6
4
|
* Returns HTTP 200 OK response with json content
|
|
@@ -8,7 +6,8 @@ import { IResponseOptions, Response } from '../interfaces.js';
|
|
|
8
6
|
*/
|
|
9
7
|
export declare class Ok extends Response {
|
|
10
8
|
protected options?: IResponseOptions;
|
|
9
|
+
protected _errorCode: HTTP_STATUS_CODE;
|
|
10
|
+
protected _template: string;
|
|
11
11
|
constructor(data?: string | object | Promise<unknown>, options?: IResponseOptions);
|
|
12
|
-
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>;
|
|
13
12
|
}
|
|
14
13
|
//# sourceMappingURL=ok.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ok.d.ts","sourceRoot":"","sources":["../../../src/response-methods/ok.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ok.d.ts","sourceRoot":"","sources":["../../../src/response-methods/ok.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEhF;;;;GAIG;AACH,qBAAa,EAAG,SAAQ,QAAQ;IAIyB,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB;IAH3F,SAAS,CAAC,UAAU,mBAAuB;IAC3C,SAAS,CAAC,SAAS,SAAY;gBAEnB,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,EAAY,OAAO,CAAC,EAAE,gBAAgB;CAG5F"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { HTTP_STATUS_CODE, Response } from '../interfaces.js';
|
|
2
|
-
import { httpResponse } from '../responses.js';
|
|
3
2
|
/**
|
|
4
3
|
* Internall response function.
|
|
5
4
|
* Returns HTTP 200 OK response with json content
|
|
@@ -7,15 +6,10 @@ import { httpResponse } from '../responses.js';
|
|
|
7
6
|
*/
|
|
8
7
|
export class Ok extends Response {
|
|
9
8
|
constructor(data, options) {
|
|
10
|
-
super(data);
|
|
9
|
+
super(data, options);
|
|
11
10
|
this.options = options;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const response = await this.prepareResponse();
|
|
15
|
-
return await httpResponse(response, 'ok.pug', {
|
|
16
|
-
...this.options,
|
|
17
|
-
StatusCode: HTTP_STATUS_CODE.OK,
|
|
18
|
-
});
|
|
11
|
+
this._errorCode = HTTP_STATUS_CODE.OK;
|
|
12
|
+
this._template = 'ok.pug';
|
|
19
13
|
}
|
|
20
14
|
}
|
|
21
15
|
//# sourceMappingURL=ok.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ok.js","sourceRoot":"","sources":["../../../src/response-methods/ok.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ok.js","sourceRoot":"","sources":["../../../src/response-methods/ok.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAoB,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEhF;;;;GAIG;AACH,MAAM,OAAO,EAAG,SAAQ,QAAQ;IAI9B,YAAY,IAAyC,EAAY,OAA0B;QACzF,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAD0C,YAAO,GAAP,OAAO,CAAmB;QAHjF,eAAU,GAAG,gBAAgB,CAAC,EAAE,CAAC;QACjC,cAAS,GAAG,QAAQ,CAAC;IAI/B,CAAC;CACF"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { IResponseOptions } from '../interfaces.js';
|
|
4
|
-
import { BadRequest } from './badRequest.js';
|
|
1
|
+
import { HTTP_STATUS_CODE, IResponseOptions } from '../interfaces.js';
|
|
2
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
5
3
|
/**
|
|
6
4
|
* Internall response function.
|
|
7
5
|
* Returns HTTP 500 INTERNAL SERVER ERROR
|
|
8
6
|
* @param err - error to send
|
|
9
7
|
*/
|
|
10
|
-
export declare class ServerError extends
|
|
8
|
+
export declare class ServerError extends BadRequestResponse {
|
|
11
9
|
protected options?: IResponseOptions;
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
protected _errorCode: HTTP_STATUS_CODE;
|
|
11
|
+
protected _template: string;
|
|
12
|
+
constructor(data: string | object | Promise<unknown>, options?: IResponseOptions);
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=serverError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/response-methods/serverError.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serverError.d.ts","sourceRoot":"","sources":["../../../src/response-methods/serverError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAKrD;;;;GAIG;AAEH,qBAEa,WAAY,SAAQ,kBAAkB;IAIK,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB;IAH1F,SAAS,CAAC,UAAU,mBAAmC;IACvD,SAAS,CAAC,SAAS,SAAqB;gBAE5B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,EAAY,OAAO,CAAC,EAAE,gBAAgB;CAG3F"}
|
|
@@ -1,22 +1,34 @@
|
|
|
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
|
+
};
|
|
1
10
|
import { HTTP_STATUS_CODE } from '../interfaces.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
11
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
12
|
+
import { HandleException } from '../decorators.js';
|
|
13
|
+
import { Injectable } from '@spinajs/di';
|
|
14
|
+
import { IOFail, MethodNotImplemented, UnexpectedServerError } from '@spinajs/exceptions';
|
|
4
15
|
/**
|
|
5
16
|
* Internall response function.
|
|
6
17
|
* Returns HTTP 500 INTERNAL SERVER ERROR
|
|
7
18
|
* @param err - error to send
|
|
8
19
|
*/
|
|
9
|
-
|
|
20
|
+
let ServerError = class ServerError extends BadRequestResponse {
|
|
10
21
|
constructor(data, options) {
|
|
11
|
-
super(data);
|
|
22
|
+
super(data, options);
|
|
12
23
|
this.options = options;
|
|
24
|
+
this._errorCode = HTTP_STATUS_CODE.INTERNAL_ERROR;
|
|
25
|
+
this._template = 'serverError.pug';
|
|
13
26
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
27
|
+
};
|
|
28
|
+
ServerError = __decorate([
|
|
29
|
+
HandleException([MethodNotImplemented, IOFail, UnexpectedServerError]),
|
|
30
|
+
Injectable(Response),
|
|
31
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
32
|
+
], ServerError);
|
|
33
|
+
export { ServerError };
|
|
22
34
|
//# sourceMappingURL=serverError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serverError.js","sourceRoot":"","sources":["../../../src/response-methods/serverError.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serverError.js","sourceRoot":"","sources":["../../../src/response-methods/serverError.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE1F;;;;GAIG;AAII,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,kBAAkB;IAIjD,YAAY,IAAwC,EAAY,OAA0B;QACxF,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QADyC,YAAO,GAAP,OAAO,CAAmB;QAHhF,eAAU,GAAG,gBAAgB,CAAC,cAAc,CAAC;QAC7C,cAAS,GAAG,iBAAiB,CAAC;IAIxC,CAAC;CACF,CAAA;AAPY,WAAW;IAFvB,eAAe,CAAC,CAAC,oBAAoB,EAAE,MAAM,EAAE,qBAAqB,CAAC,CAAC;IACtE,UAAU,CAAC,QAAQ,CAAC;;GACR,WAAW,CAOvB"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { IResponseOptions } from '../interfaces.js';
|
|
4
|
-
import { BadRequest } from './badRequest.js';
|
|
1
|
+
import { HTTP_STATUS_CODE, IResponseOptions } from '../interfaces.js';
|
|
2
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
5
3
|
/**
|
|
6
4
|
* Internall response function.
|
|
7
5
|
* Returns HTTP 401 UNAHTORIZED response with json content
|
|
8
6
|
* @param data - data to send
|
|
9
7
|
*/
|
|
10
|
-
export declare class Unauthorized extends
|
|
8
|
+
export declare class Unauthorized extends BadRequestResponse {
|
|
11
9
|
protected options?: IResponseOptions;
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
protected _errorCode: HTTP_STATUS_CODE;
|
|
11
|
+
protected _template: string;
|
|
12
|
+
constructor(data: string | object | Promise<unknown>, options?: IResponseOptions);
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=unauthorized.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../../src/response-methods/unauthorized.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unauthorized.d.ts","sourceRoot":"","sources":["../../../src/response-methods/unauthorized.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAKrD;;;;GAIG;AAEH,qBAEa,YAAa,SAAQ,kBAAkB;IAII,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB;IAH1F,SAAS,CAAC,UAAU,mBAAiC;IACrD,SAAS,CAAC,SAAS,SAAsB;gBAE7B,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,EAAY,OAAO,CAAC,EAAE,gBAAgB;CAG3F"}
|
|
@@ -1,22 +1,34 @@
|
|
|
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
|
+
};
|
|
1
10
|
import { HTTP_STATUS_CODE } from '../interfaces.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
11
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
12
|
+
import { AuthenticationFailed } from '@spinajs/exceptions';
|
|
13
|
+
import { HandleException } from '../decorators.js';
|
|
14
|
+
import { Injectable } from '@spinajs/di';
|
|
4
15
|
/**
|
|
5
16
|
* Internall response function.
|
|
6
17
|
* Returns HTTP 401 UNAHTORIZED response with json content
|
|
7
18
|
* @param data - data to send
|
|
8
19
|
*/
|
|
9
|
-
|
|
20
|
+
let Unauthorized = class Unauthorized extends BadRequestResponse {
|
|
10
21
|
constructor(data, options) {
|
|
11
|
-
super(data);
|
|
22
|
+
super(data, options);
|
|
12
23
|
this.options = options;
|
|
24
|
+
this._errorCode = HTTP_STATUS_CODE.UNAUTHORIZED;
|
|
25
|
+
this._template = 'unauthorized.pug';
|
|
13
26
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
27
|
+
};
|
|
28
|
+
Unauthorized = __decorate([
|
|
29
|
+
HandleException(AuthenticationFailed),
|
|
30
|
+
Injectable(Response),
|
|
31
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
32
|
+
], Unauthorized);
|
|
33
|
+
export { Unauthorized };
|
|
22
34
|
//# sourceMappingURL=unauthorized.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unauthorized.js","sourceRoot":"","sources":["../../../src/response-methods/unauthorized.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"unauthorized.js","sourceRoot":"","sources":["../../../src/response-methods/unauthorized.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AAII,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,kBAAkB;IAIlD,YAAY,IAAwC,EAAY,OAA0B;QACxF,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QADyC,YAAO,GAAP,OAAO,CAAmB;QAHhF,eAAU,GAAG,gBAAgB,CAAC,YAAY,CAAC;QAC3C,cAAS,GAAG,kBAAkB,CAAC;IAIzC,CAAC;CACF,CAAA;AAPY,YAAY;IAFxB,eAAe,CAAC,oBAAoB,CAAC;IACrC,UAAU,CAAC,QAAQ,CAAC;;GACR,YAAY,CAOxB"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { IResponseOptions } from '../interfaces.js';
|
|
4
|
-
import { BadRequest } from './badRequest.js';
|
|
1
|
+
import { HTTP_STATUS_CODE, IResponseOptions } from '../interfaces.js';
|
|
2
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
5
3
|
/**
|
|
6
4
|
* Internall response function.
|
|
7
5
|
* Returns HTTP 400 BAD REQUEST ERROR
|
|
8
6
|
* @param err - error to send
|
|
9
7
|
*/
|
|
10
|
-
export declare class ValidationError extends
|
|
8
|
+
export declare class ValidationError extends BadRequestResponse {
|
|
11
9
|
protected options?: IResponseOptions;
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
protected _errorCode: HTTP_STATUS_CODE;
|
|
11
|
+
protected _template: string;
|
|
12
|
+
constructor(data: string | object | Promise<unknown>, options?: IResponseOptions);
|
|
14
13
|
}
|
|
15
14
|
//# sourceMappingURL=validationError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationError.d.ts","sourceRoot":"","sources":["../../../src/response-methods/validationError.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validationError.d.ts","sourceRoot":"","sources":["../../../src/response-methods/validationError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAKrD;;;;GAIG;AAEH,qBAEa,eAAgB,SAAQ,kBAAkB;IAIC,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB;IAH1F,SAAS,CAAC,UAAU,mBAAgC;IACpD,SAAS,CAAC,SAAS,SAAyB;gBAEhC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,EAAY,OAAO,CAAC,EAAE,gBAAgB;CAG3F"}
|
|
@@ -1,22 +1,34 @@
|
|
|
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
|
+
};
|
|
1
10
|
import { HTTP_STATUS_CODE } from '../interfaces.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
11
|
+
import { BadRequestResponse } from './badRequest.js';
|
|
12
|
+
import { HandleException } from '../decorators.js';
|
|
13
|
+
import { ValidationFailed } from '@spinajs/validation';
|
|
14
|
+
import { Injectable } from '@spinajs/di';
|
|
4
15
|
/**
|
|
5
16
|
* Internall response function.
|
|
6
17
|
* Returns HTTP 400 BAD REQUEST ERROR
|
|
7
18
|
* @param err - error to send
|
|
8
19
|
*/
|
|
9
|
-
|
|
20
|
+
let ValidationError = class ValidationError extends BadRequestResponse {
|
|
10
21
|
constructor(data, options) {
|
|
11
|
-
super(data);
|
|
22
|
+
super(data, options);
|
|
12
23
|
this.options = options;
|
|
24
|
+
this._errorCode = HTTP_STATUS_CODE.BAD_REQUEST;
|
|
25
|
+
this._template = 'validationError.pug';
|
|
13
26
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
27
|
+
};
|
|
28
|
+
ValidationError = __decorate([
|
|
29
|
+
HandleException(ValidationFailed),
|
|
30
|
+
Injectable(Response),
|
|
31
|
+
__metadata("design:paramtypes", [Object, Object])
|
|
32
|
+
], ValidationError);
|
|
33
|
+
export { ValidationError };
|
|
22
34
|
//# sourceMappingURL=validationError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validationError.js","sourceRoot":"","sources":["../../../src/response-methods/validationError.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validationError.js","sourceRoot":"","sources":["../../../src/response-methods/validationError.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAoB,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;;;GAIG;AAII,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,kBAAkB;IAIrD,YAAY,IAAwC,EAAY,OAA0B;QACxF,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QADyC,YAAO,GAAP,OAAO,CAAmB;QAHhF,eAAU,GAAG,gBAAgB,CAAC,WAAW,CAAC;QAC1C,cAAS,GAAG,qBAAqB,CAAC;IAI5C,CAAC;CACF,CAAA;AAPY,eAAe;IAF3B,eAAe,CAAC,gBAAgB,CAAC;IACjC,UAAU,CAAC,QAAQ,CAAC;;GACR,eAAe,CAO3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAwD,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAYzG,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,gBAAgB,QAwB7E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,gBAAgB,QAI5E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,gBAAgB,UACnD,eAAe,OAAO,gBAAgB,UAYrD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,gBAAgB,UACnD,eAAe,OAAO,gBAAgB,UAWrD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,gBAAgB,SAGlE,eAAe,OAAO,gBAAgB,UA0DpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/responses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAwD,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAYzG,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,gBAAgB,QAwB7E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,gBAAgB,QAI5E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,gBAAgB,UACnD,eAAe,OAAO,gBAAgB,UAYrD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,gBAAgB,UACnD,eAAe,OAAO,gBAAgB,UAWrD;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,gBAAgB,SAGlE,eAAe,OAAO,gBAAgB,UA0DpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,SAmCtE,eAAe,OAAO,gBAAgB,UA0CpD"}
|
package/lib/mjs/responses.js
CHANGED
|
@@ -133,16 +133,24 @@ export function httpResponse(model, template, options) {
|
|
|
133
133
|
const cfg = DI.get(Configuration);
|
|
134
134
|
const acceptedHeaders = cfg.get('http.AcceptHeaders');
|
|
135
135
|
const transformers = DI.resolve(Array.ofType(DataTransformer));
|
|
136
|
-
const
|
|
137
|
-
const
|
|
136
|
+
const errorTransform = function (req, res) {
|
|
137
|
+
const transformerName = req.headers['x-error-transform'] ?? 'default-http-error-transform';
|
|
138
|
+
return transform(req, res, transformerName);
|
|
139
|
+
};
|
|
140
|
+
const dataTransform = function (req, res) {
|
|
141
|
+
const transformerName = req.headers['x-data-transform'] ?? 'invalid-x-data-transform-header';
|
|
142
|
+
return transform(req, res, transformerName);
|
|
143
|
+
};
|
|
144
|
+
const transform = function (req, res, dataTransformer) {
|
|
145
|
+
const transformer = transformers.find((t) => t.Type === dataTransformer);
|
|
138
146
|
if (transformer) {
|
|
139
147
|
jsonResponse(transformer.transform(model, req), options)(req, res);
|
|
140
148
|
}
|
|
141
149
|
else {
|
|
142
150
|
jsonResponse({
|
|
143
151
|
error: {
|
|
144
|
-
message: `invalid data transformer
|
|
145
|
-
code:
|
|
152
|
+
message: `invalid data transformer ${dataTransformer}`,
|
|
153
|
+
code: HTTP_STATUS_CODE.BAD_REQUEST,
|
|
146
154
|
},
|
|
147
155
|
}, {
|
|
148
156
|
...options,
|
|
@@ -174,15 +182,15 @@ export function httpResponse(model, template, options) {
|
|
|
174
182
|
}
|
|
175
183
|
else if (req.accepts('json') && (acceptedHeaders & HttpAcceptHeaders.JSON) === HttpAcceptHeaders.JSON) {
|
|
176
184
|
if (options.StatusCode >= 400) {
|
|
177
|
-
|
|
178
|
-
transform(req, res, 'x-error-transform');
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
if (req.headers['x-data-transform']) {
|
|
182
|
-
transform(req, res, 'x-data-transform');
|
|
185
|
+
errorTransform(req, res);
|
|
183
186
|
}
|
|
184
187
|
else {
|
|
185
|
-
|
|
188
|
+
if (req.headers['x-data-transform']) {
|
|
189
|
+
dataTransform(req, res);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
jsonResponse(model, options)(req, res);
|
|
193
|
+
}
|
|
186
194
|
}
|
|
187
195
|
}
|
|
188
196
|
else {
|