@atlantjs/backend 10.0.1 → 10.0.2
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.
|
@@ -2,7 +2,9 @@ import { FailureAbstract, HttpStatusCodes } from "@atlantjs/arch";
|
|
|
2
2
|
import { Response } from "express";
|
|
3
3
|
import { ForceResponse } from "./force-response.abstract";
|
|
4
4
|
export declare abstract class ForceAbstract {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
protected res: Response;
|
|
6
|
+
constructor(res: Response);
|
|
7
|
+
abstract apply(...args: unknown[]): Promise<Response>;
|
|
8
|
+
protected onSuccess(response: ForceResponse): Promise<Response>;
|
|
9
|
+
protected onFailure(failure: FailureAbstract, httpStatusCode?: HttpStatusCodes): Response;
|
|
8
10
|
}
|
|
@@ -1,18 +1,38 @@
|
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.ForceAbstract = void 0;
|
|
4
16
|
const arch_1 = require("@atlantjs/arch");
|
|
5
17
|
const class_validator_1 = require("class-validator");
|
|
6
|
-
|
|
7
|
-
|
|
18
|
+
const routing_controllers_1 = require("routing-controllers");
|
|
19
|
+
let ForceAbstract = class ForceAbstract {
|
|
20
|
+
constructor(res) {
|
|
21
|
+
this.res = res;
|
|
22
|
+
}
|
|
23
|
+
async onSuccess(response) {
|
|
8
24
|
if (arch_1._.isNotUndefined(response)) {
|
|
9
25
|
await (0, class_validator_1.validateOrReject)(response);
|
|
10
26
|
}
|
|
11
27
|
const data = response.data;
|
|
12
|
-
return res.status(response.statusCode).send(data);
|
|
28
|
+
return this.res.status(response.statusCode).send(data);
|
|
13
29
|
}
|
|
14
|
-
onFailure(
|
|
15
|
-
return
|
|
30
|
+
onFailure(failure, httpStatusCode = arch_1.HttpStatusCodes.BAD_REQUEST) {
|
|
31
|
+
return this.res.status(httpStatusCode).send(failure.toPolygon());
|
|
16
32
|
}
|
|
17
|
-
}
|
|
33
|
+
};
|
|
18
34
|
exports.ForceAbstract = ForceAbstract;
|
|
35
|
+
exports.ForceAbstract = ForceAbstract = __decorate([
|
|
36
|
+
__param(0, (0, routing_controllers_1.Res)()),
|
|
37
|
+
__metadata("design:paramtypes", [Object])
|
|
38
|
+
], ForceAbstract);
|