@atlantjs/arch 3.2.19 → 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.
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { Response } from "express";
|
|
1
2
|
import { FailureAbstract } from "../../application/failures/failure.abstract";
|
|
2
3
|
import { HttpStatusCodes } from "../../domain/enums/http-status-codes.enum";
|
|
3
4
|
import { ResponseAbstract } from "./responses/response.abstract";
|
|
4
|
-
import { Response } from "express";
|
|
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,30 +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
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.ControllerAbstract = void 0;
|
|
13
4
|
const http_status_codes_enum_1 = require("../../domain/enums/http-status-codes.enum");
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return this.response.status(httpStatusCode).send(payload?.toPlain() ?? {});
|
|
5
|
+
class ControllerAbstract {
|
|
6
|
+
onSuccess(response, payload, httpStatusCode = http_status_codes_enum_1.HttpStatusCodes.OK) {
|
|
7
|
+
return response.status(httpStatusCode).send(payload?.toPlain() ?? {});
|
|
18
8
|
}
|
|
19
|
-
onFailure(failure, httpStatusCode = http_status_codes_enum_1.HttpStatusCodes.BAD_REQUEST) {
|
|
20
|
-
return
|
|
9
|
+
onFailure(response, failure, httpStatusCode = http_status_codes_enum_1.HttpStatusCodes.BAD_REQUEST) {
|
|
10
|
+
return response.status(httpStatusCode).send(failure.toPlain());
|
|
21
11
|
}
|
|
22
|
-
}
|
|
12
|
+
}
|
|
23
13
|
exports.ControllerAbstract = ControllerAbstract;
|
|
24
|
-
__decorate([
|
|
25
|
-
(0, routing_controllers_1.Res)(),
|
|
26
|
-
__metadata("design:type", Object)
|
|
27
|
-
], ControllerAbstract.prototype, "response", void 0);
|
|
28
|
-
exports.ControllerAbstract = ControllerAbstract = __decorate([
|
|
29
|
-
(0, routing_controllers_1.JsonController)()
|
|
30
|
-
], ControllerAbstract);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlantjs/arch",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.22",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"module-alias": "^2.2.3",
|
|
49
49
|
"reflect-metadata": "^0.2.2",
|
|
50
50
|
"routing-controllers": "^0.10.4",
|
|
51
|
+
"routing-controllers-openapi": "^4.0.0",
|
|
51
52
|
"typeorm": "^0.3.20",
|
|
52
53
|
"uuid": "^10.0.0"
|
|
53
54
|
},
|