@atlantjs/arch 3.2.21 → 3.2.22
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.
|
@@ -3,8 +3,7 @@ import { FailureAbstract } from "../../application/failures/failure.abstract";
|
|
|
3
3
|
import { HttpStatusCodes } from "../../domain/enums/http-status-codes.enum";
|
|
4
4
|
import { ResponseAbstract } from "./responses/response.abstract";
|
|
5
5
|
export declare abstract class ControllerAbstract {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
protected
|
|
9
|
-
protected onFailure(failure: FailureAbstract, httpStatusCode?: HttpStatusCodes): Response;
|
|
6
|
+
abstract handler(response: Response, ...args: unknown[]): Promise<Response>;
|
|
7
|
+
protected onSuccess<Payload extends ResponseAbstract>(response: Response, payload?: Payload, httpStatusCode?: HttpStatusCodes): Response;
|
|
8
|
+
protected onFailure(response: Response, failure: FailureAbstract, httpStatusCode?: HttpStatusCodes): Response;
|
|
10
9
|
}
|
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
3
|
exports.ControllerAbstract = void 0;
|
|
10
|
-
const routing_controllers_1 = require("routing-controllers");
|
|
11
4
|
const http_status_codes_enum_1 = require("../../domain/enums/http-status-codes.enum");
|
|
12
|
-
|
|
13
|
-
onSuccess(payload, httpStatusCode = http_status_codes_enum_1.HttpStatusCodes.OK) {
|
|
14
|
-
return
|
|
5
|
+
class ControllerAbstract {
|
|
6
|
+
onSuccess(response, payload, httpStatusCode = http_status_codes_enum_1.HttpStatusCodes.OK) {
|
|
7
|
+
return response.status(httpStatusCode).send(payload?.toPlain() ?? {});
|
|
15
8
|
}
|
|
16
|
-
onFailure(failure, httpStatusCode = http_status_codes_enum_1.HttpStatusCodes.BAD_REQUEST) {
|
|
17
|
-
return
|
|
9
|
+
onFailure(response, failure, httpStatusCode = http_status_codes_enum_1.HttpStatusCodes.BAD_REQUEST) {
|
|
10
|
+
return response.status(httpStatusCode).send(failure.toPlain());
|
|
18
11
|
}
|
|
19
|
-
}
|
|
12
|
+
}
|
|
20
13
|
exports.ControllerAbstract = ControllerAbstract;
|
|
21
|
-
exports.ControllerAbstract = ControllerAbstract = __decorate([
|
|
22
|
-
(0, routing_controllers_1.JsonController)()
|
|
23
|
-
], ControllerAbstract);
|