@atlantjs/backend 8.0.0 → 10.0.0
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/backend/boundary/{controllers/controller-response.abstract.d.ts → forces/force-response.abstract.d.ts} +1 -1
- package/backend/boundary/{controllers/controller-response.abstract.js → forces/force-response.abstract.js} +3 -3
- package/backend/boundary/{controllers/controller.abstract.d.ts → forces/force.abstract.d.ts} +3 -3
- package/backend/boundary/{controllers/controller.abstract.js → forces/force.abstract.js} +3 -3
- package/backend/mesh/{middlewares/middleware.handler.abstract.d.ts → thetas/theta.handler.abstract.d.ts} +1 -1
- package/backend/mesh/thetas/theta.handler.abstract.js +6 -0
- package/backend/mesh/{commands/command.abstract.d.ts → works/work.abstract.d.ts} +1 -1
- package/backend/mesh/works/work.abstract.js +6 -0
- package/backend/stitch/stitch-points.point.d.ts +3 -3
- package/backend/stitch/stitches.abstract.d.ts +1 -1
- package/backend/stitch/stitches.abstract.js +6 -6
- package/backend/stitch/stitches.abstract.type.d.ts +6 -6
- package/index.d.ts +8 -8
- package/index.js +16 -16
- package/package.json +1 -1
- package/setup/dependency-injections/di-container.abstract.d.ts +9 -9
- package/setup/dependency-injections/di-container.abstract.js +9 -9
- package/setup/server/{body-parser-middleware.d.ts → body-parser-theta.d.ts} +1 -1
- package/setup/server/{body-parser-middleware.js → body-parser-theta.js} +5 -5
- package/setup/server/{cors-middleware.d.ts → cors-theta.d.ts} +1 -1
- package/setup/server/{cors-middleware.js → cors-theta.js} +5 -5
- package/setup/server/{default-error-handler-middleware.d.ts → default-error-handler-theta.d.ts} +1 -1
- package/setup/server/{default-error-handler-middleware.js → default-error-handler-theta.js} +5 -5
- package/setup/server/server.js +6 -6
- package/tsconfig.tsbuildinfo +1 -1
- package/backend/mesh/commands/command.abstract.js +0 -6
- package/backend/mesh/middlewares/middleware.handler.abstract.js +0 -6
- /package/backend/boundary/{controllers → forces}/payloads/validators/validator.abstract.d.ts +0 -0
- /package/backend/boundary/{controllers → forces}/payloads/validators/validator.abstract.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpStatusCodes, InstanceOf, Plainify, ResponseAbstract } from "@atlantjs/arch";
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class ForceResponse<T extends ResponseAbstract | (new (...args: any[]) => ResponseAbstract) = ResponseAbstract> {
|
|
3
3
|
protected _statusCode: HttpStatusCodes;
|
|
4
4
|
protected _schema?: T;
|
|
5
5
|
protected _data?: Partial<Plainify<InstanceOf<T>>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
class
|
|
3
|
+
exports.ForceResponse = void 0;
|
|
4
|
+
class ForceResponse {
|
|
5
5
|
constructor(statusCode, schema, data) {
|
|
6
6
|
this._statusCode = statusCode;
|
|
7
7
|
this._schema = schema;
|
|
@@ -17,4 +17,4 @@ class ControllerResponse {
|
|
|
17
17
|
return this._data;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
exports.
|
|
20
|
+
exports.ForceResponse = ForceResponse;
|
package/backend/boundary/{controllers/controller.abstract.d.ts → forces/force.abstract.d.ts}
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FailureAbstract, HttpStatusCodes } from "@atlantjs/arch";
|
|
2
2
|
import { Response } from "express";
|
|
3
|
-
import {
|
|
4
|
-
export declare abstract class
|
|
3
|
+
import { ForceResponse } from "./force-response.abstract";
|
|
4
|
+
export declare abstract class ForceAbstract {
|
|
5
5
|
abstract handler(response: Response, ...args: unknown[]): Promise<Response>;
|
|
6
|
-
protected onSuccess(res: Response, response:
|
|
6
|
+
protected onSuccess(res: Response, response: ForceResponse): Promise<Response>;
|
|
7
7
|
protected onFailure(response: Response, failure: FailureAbstract, httpStatusCode?: HttpStatusCodes): Response;
|
|
8
8
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ForceAbstract = void 0;
|
|
4
4
|
const arch_1 = require("@atlantjs/arch");
|
|
5
5
|
const class_validator_1 = require("class-validator");
|
|
6
|
-
class
|
|
6
|
+
class ForceAbstract {
|
|
7
7
|
async onSuccess(res, response) {
|
|
8
8
|
if (arch_1._.isNotUndefined(response)) {
|
|
9
9
|
await (0, class_validator_1.validateOrReject)(response);
|
|
@@ -15,4 +15,4 @@ class ControllerAbstract {
|
|
|
15
15
|
return response.status(httpStatusCode).send(failure.toPolygon());
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
exports.
|
|
18
|
+
exports.ForceAbstract = ForceAbstract;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface StitchPoint {
|
|
2
|
-
|
|
2
|
+
force?: {
|
|
3
3
|
[key: string]: symbol;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
theta?: {
|
|
6
6
|
[key: string]: symbol;
|
|
7
7
|
};
|
|
8
8
|
service?: {
|
|
@@ -14,7 +14,7 @@ export interface StitchPoint {
|
|
|
14
14
|
repository?: {
|
|
15
15
|
[key: string]: symbol;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
work?: {
|
|
18
18
|
[key: string]: symbol;
|
|
19
19
|
};
|
|
20
20
|
helper?: {
|
|
@@ -3,7 +3,7 @@ export declare abstract class StitchesAbstract {
|
|
|
3
3
|
private readonly _stitches;
|
|
4
4
|
constructor(_stitches: Stitches);
|
|
5
5
|
private toStitchControllers;
|
|
6
|
-
private
|
|
6
|
+
private toStitchThetas;
|
|
7
7
|
private toStitchCommands;
|
|
8
8
|
private toStitchServices;
|
|
9
9
|
private toStitchRepositories;
|
|
@@ -6,24 +6,24 @@ class StitchesAbstract {
|
|
|
6
6
|
constructor(_stitches) {
|
|
7
7
|
this._stitches = _stitches;
|
|
8
8
|
this.toStitchControllers();
|
|
9
|
-
this.
|
|
9
|
+
this.toStitchThetas();
|
|
10
10
|
this.toStitchCommands();
|
|
11
11
|
this.toStitchServices();
|
|
12
12
|
this.toStitchRepositories();
|
|
13
13
|
this.toStitchProviders();
|
|
14
14
|
}
|
|
15
15
|
toStitchControllers() {
|
|
16
|
-
this._stitches.
|
|
16
|
+
this._stitches.forces?.map((controller) => {
|
|
17
17
|
dependency_injections_1.diContainer.bind(controller).toSelf();
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
this._stitches.
|
|
22
|
-
dependency_injections_1.diContainer.bind(
|
|
20
|
+
toStitchThetas() {
|
|
21
|
+
this._stitches.thetas?.map((theta) => {
|
|
22
|
+
dependency_injections_1.diContainer.bind(theta).toSelf();
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
toStitchCommands() {
|
|
26
|
-
this._stitches.
|
|
26
|
+
this._stitches.works?.map((command) => {
|
|
27
27
|
dependency_injections_1.diContainer.bind(command.stitchPoint).to(command.boundary);
|
|
28
28
|
});
|
|
29
29
|
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Newable } from "@atlantjs/arch";
|
|
2
2
|
import { interfaces } from "inversify";
|
|
3
|
-
import {
|
|
4
|
-
import { CommandAbstract } from "../mesh/commands/command.abstract";
|
|
5
|
-
import { MiddlewareHandlerAbstract } from "../mesh/middlewares/middleware.handler.abstract";
|
|
3
|
+
import { ForceAbstract } from "../boundary/forces/force.abstract";
|
|
6
4
|
import { RepositoryAbstract } from "../mesh/repositories/repository.abstract";
|
|
7
5
|
import { ServiceAbstract } from "../mesh/services/service.abstract";
|
|
6
|
+
import { ThetaHandlerAbstract } from "../mesh/thetas/theta.handler.abstract";
|
|
7
|
+
import { WorkAbstract } from "../mesh/works/work.abstract";
|
|
8
8
|
type BoundaryIdentifier<T> = interfaces.ServiceIdentifier<T>;
|
|
9
9
|
interface SewTo<T> {
|
|
10
10
|
stitchPoint: BoundaryIdentifier<unknown>;
|
|
11
11
|
boundary: Newable<T>;
|
|
12
12
|
}
|
|
13
13
|
export interface Stitches {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
forces?: BoundaryIdentifier<ForceAbstract>[];
|
|
15
|
+
thetas?: BoundaryIdentifier<ThetaHandlerAbstract>[];
|
|
16
|
+
works?: SewTo<WorkAbstract>[];
|
|
17
17
|
services?: SewTo<ServiceAbstract>[];
|
|
18
18
|
repositories?: SewTo<RepositoryAbstract>[];
|
|
19
19
|
providers?: SewTo<RepositoryAbstract>[];
|
package/index.d.ts
CHANGED
|
@@ -4,23 +4,23 @@ export { getFromContainer, Get, Post, Delete, Patch, UseBefore, JsonController,
|
|
|
4
4
|
export { NextFunction, Request, RequestHandler, Response } from "express";
|
|
5
5
|
export { APP_PORT, LOAD_MODULES, CORS_ALLOWED_ORIGINS, ENVIRONMENT, } from "./backend/stitch/verses";
|
|
6
6
|
export { PrimaryColumn, Column, Entity, JoinColumn, ManyToOne, OneToMany, OneToOne, ManyToMany, BeforeInsert, BeforeUpdate, } from "typeorm";
|
|
7
|
-
export {
|
|
7
|
+
export { ThetaHandlerAbstract } from "./backend/mesh/thetas/theta.handler.abstract";
|
|
8
8
|
export { ProviderAbstract } from "./backend/mesh/providers/provider.abstract";
|
|
9
9
|
export { RepositoryAbstract } from "./backend/mesh/repositories/repository.abstract";
|
|
10
10
|
export { ServiceAbstract } from "./backend/mesh/services/service.abstract";
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export { ValidatorAbstract } from "./backend/boundary/
|
|
11
|
+
export { WorkAbstract } from "./backend/mesh/works/work.abstract";
|
|
12
|
+
export { ForceAbstract } from "./backend/boundary/forces/force.abstract";
|
|
13
|
+
export { ValidatorAbstract } from "./backend/boundary/forces/payloads/validators/validator.abstract";
|
|
14
14
|
export { startContainer, diContainer } from "./setup/dependency-injections";
|
|
15
15
|
export { DiContainerAbstract } from "./setup/dependency-injections/di-container.abstract";
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
16
|
+
export { BodyParserTheta } from "./setup/server/body-parser-theta";
|
|
17
|
+
export { CorsTheta } from "./setup/server/cors-theta";
|
|
18
|
+
export { DefaultErrorHandlerTheta } from "./setup/server/default-error-handler-theta";
|
|
19
19
|
export { Server } from "./setup/server/server";
|
|
20
20
|
export { inject as toStitch, injectable as stitchable, } from "inversify";
|
|
21
21
|
export { initialize } from "./setup";
|
|
22
22
|
export { StitchesAbstract } from "./backend/stitch/stitches.abstract";
|
|
23
23
|
export { Stitches } from "./backend/stitch/stitches.abstract.type";
|
|
24
24
|
export { StitchPoint } from "./backend/stitch/stitch-points.point";
|
|
25
|
-
export {
|
|
25
|
+
export { ForceResponse } from "./backend/boundary/forces/force-response.abstract";
|
|
26
26
|
export { EmailDeliveryProvider } from "./email-delivery/email-delivery.factory";
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EmailDeliveryProvider = exports.
|
|
3
|
+
exports.EmailDeliveryProvider = exports.ForceResponse = exports.StitchesAbstract = exports.initialize = exports.stitchable = exports.toStitch = exports.Server = exports.DefaultErrorHandlerTheta = exports.CorsTheta = exports.BodyParserTheta = exports.DiContainerAbstract = exports.diContainer = exports.startContainer = exports.ValidatorAbstract = exports.ForceAbstract = exports.WorkAbstract = exports.ServiceAbstract = exports.RepositoryAbstract = exports.ProviderAbstract = exports.ThetaHandlerAbstract = exports.BeforeUpdate = exports.BeforeInsert = exports.ManyToMany = exports.OneToOne = exports.OneToMany = exports.ManyToOne = exports.JoinColumn = exports.Entity = exports.Column = exports.PrimaryColumn = exports.ENVIRONMENT = exports.CORS_ALLOWED_ORIGINS = exports.LOAD_MODULES = exports.APP_PORT = exports.Params = exports.Param = exports.Req = exports.Body = exports.Res = exports.JsonController = exports.UseBefore = exports.Patch = exports.Delete = exports.Post = exports.Get = exports.getFromContainer = void 0;
|
|
4
4
|
require("./backend/stitch/verses/load-verses");
|
|
5
5
|
require("reflect-metadata");
|
|
6
6
|
const setup_1 = require("./setup");
|
|
@@ -34,31 +34,31 @@ Object.defineProperty(exports, "OneToOne", { enumerable: true, get: function ()
|
|
|
34
34
|
Object.defineProperty(exports, "ManyToMany", { enumerable: true, get: function () { return typeorm_1.ManyToMany; } });
|
|
35
35
|
Object.defineProperty(exports, "BeforeInsert", { enumerable: true, get: function () { return typeorm_1.BeforeInsert; } });
|
|
36
36
|
Object.defineProperty(exports, "BeforeUpdate", { enumerable: true, get: function () { return typeorm_1.BeforeUpdate; } });
|
|
37
|
-
var
|
|
38
|
-
Object.defineProperty(exports, "
|
|
37
|
+
var theta_handler_abstract_1 = require("./backend/mesh/thetas/theta.handler.abstract");
|
|
38
|
+
Object.defineProperty(exports, "ThetaHandlerAbstract", { enumerable: true, get: function () { return theta_handler_abstract_1.ThetaHandlerAbstract; } });
|
|
39
39
|
var provider_abstract_1 = require("./backend/mesh/providers/provider.abstract");
|
|
40
40
|
Object.defineProperty(exports, "ProviderAbstract", { enumerable: true, get: function () { return provider_abstract_1.ProviderAbstract; } });
|
|
41
41
|
var repository_abstract_1 = require("./backend/mesh/repositories/repository.abstract");
|
|
42
42
|
Object.defineProperty(exports, "RepositoryAbstract", { enumerable: true, get: function () { return repository_abstract_1.RepositoryAbstract; } });
|
|
43
43
|
var service_abstract_1 = require("./backend/mesh/services/service.abstract");
|
|
44
44
|
Object.defineProperty(exports, "ServiceAbstract", { enumerable: true, get: function () { return service_abstract_1.ServiceAbstract; } });
|
|
45
|
-
var
|
|
46
|
-
Object.defineProperty(exports, "
|
|
47
|
-
var
|
|
48
|
-
Object.defineProperty(exports, "
|
|
49
|
-
var validator_abstract_1 = require("./backend/boundary/
|
|
45
|
+
var work_abstract_1 = require("./backend/mesh/works/work.abstract");
|
|
46
|
+
Object.defineProperty(exports, "WorkAbstract", { enumerable: true, get: function () { return work_abstract_1.WorkAbstract; } });
|
|
47
|
+
var force_abstract_1 = require("./backend/boundary/forces/force.abstract");
|
|
48
|
+
Object.defineProperty(exports, "ForceAbstract", { enumerable: true, get: function () { return force_abstract_1.ForceAbstract; } });
|
|
49
|
+
var validator_abstract_1 = require("./backend/boundary/forces/payloads/validators/validator.abstract");
|
|
50
50
|
Object.defineProperty(exports, "ValidatorAbstract", { enumerable: true, get: function () { return validator_abstract_1.ValidatorAbstract; } });
|
|
51
51
|
var dependency_injections_1 = require("./setup/dependency-injections");
|
|
52
52
|
Object.defineProperty(exports, "startContainer", { enumerable: true, get: function () { return dependency_injections_1.startContainer; } });
|
|
53
53
|
Object.defineProperty(exports, "diContainer", { enumerable: true, get: function () { return dependency_injections_1.diContainer; } });
|
|
54
54
|
var di_container_abstract_1 = require("./setup/dependency-injections/di-container.abstract");
|
|
55
55
|
Object.defineProperty(exports, "DiContainerAbstract", { enumerable: true, get: function () { return di_container_abstract_1.DiContainerAbstract; } });
|
|
56
|
-
var
|
|
57
|
-
Object.defineProperty(exports, "
|
|
58
|
-
var
|
|
59
|
-
Object.defineProperty(exports, "
|
|
60
|
-
var
|
|
61
|
-
Object.defineProperty(exports, "
|
|
56
|
+
var body_parser_theta_1 = require("./setup/server/body-parser-theta");
|
|
57
|
+
Object.defineProperty(exports, "BodyParserTheta", { enumerable: true, get: function () { return body_parser_theta_1.BodyParserTheta; } });
|
|
58
|
+
var cors_theta_1 = require("./setup/server/cors-theta");
|
|
59
|
+
Object.defineProperty(exports, "CorsTheta", { enumerable: true, get: function () { return cors_theta_1.CorsTheta; } });
|
|
60
|
+
var default_error_handler_theta_1 = require("./setup/server/default-error-handler-theta");
|
|
61
|
+
Object.defineProperty(exports, "DefaultErrorHandlerTheta", { enumerable: true, get: function () { return default_error_handler_theta_1.DefaultErrorHandlerTheta; } });
|
|
62
62
|
var server_1 = require("./setup/server/server");
|
|
63
63
|
Object.defineProperty(exports, "Server", { enumerable: true, get: function () { return server_1.Server; } });
|
|
64
64
|
var inversify_1 = require("inversify");
|
|
@@ -68,7 +68,7 @@ var setup_2 = require("./setup");
|
|
|
68
68
|
Object.defineProperty(exports, "initialize", { enumerable: true, get: function () { return setup_2.initialize; } });
|
|
69
69
|
var stitches_abstract_1 = require("./backend/stitch/stitches.abstract");
|
|
70
70
|
Object.defineProperty(exports, "StitchesAbstract", { enumerable: true, get: function () { return stitches_abstract_1.StitchesAbstract; } });
|
|
71
|
-
var
|
|
72
|
-
Object.defineProperty(exports, "
|
|
71
|
+
var force_response_abstract_1 = require("./backend/boundary/forces/force-response.abstract");
|
|
72
|
+
Object.defineProperty(exports, "ForceResponse", { enumerable: true, get: function () { return force_response_abstract_1.ForceResponse; } });
|
|
73
73
|
var email_delivery_factory_1 = require("./email-delivery/email-delivery.factory");
|
|
74
74
|
Object.defineProperty(exports, "EmailDeliveryProvider", { enumerable: true, get: function () { return email_delivery_factory_1.EmailDeliveryProvider; } });
|
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Newable } from "@atlantjs/arch";
|
|
2
|
-
import {
|
|
3
|
-
import { CommandAbstract } from "../../backend/mesh/commands/command.abstract";
|
|
4
|
-
import { MiddlewareHandlerAbstract } from "../../backend/mesh/middlewares/middleware.handler.abstract";
|
|
2
|
+
import { ForceAbstract } from "../../backend/boundary/forces/force.abstract";
|
|
5
3
|
import { ProviderAbstract } from "../../backend/mesh/providers/provider.abstract";
|
|
6
4
|
import { RepositoryAbstract } from "../../backend/mesh/repositories/repository.abstract";
|
|
7
5
|
import { ServiceAbstract } from "../../backend/mesh/services/service.abstract";
|
|
6
|
+
import { ThetaHandlerAbstract } from "../../backend/mesh/thetas/theta.handler.abstract";
|
|
7
|
+
import { WorkAbstract } from "../../backend/mesh/works/work.abstract";
|
|
8
8
|
interface BindTo<T> {
|
|
9
9
|
token: Symbol;
|
|
10
10
|
target: Newable<T>;
|
|
11
11
|
}
|
|
12
12
|
interface Dependencies {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
forces: ForceAbstract[];
|
|
14
|
+
thetas: ThetaHandlerAbstract[];
|
|
15
|
+
works: BindTo<WorkAbstract>[];
|
|
16
16
|
repositories: BindTo<RepositoryAbstract>[];
|
|
17
17
|
providers: BindTo<ProviderAbstract>[];
|
|
18
18
|
services: BindTo<ServiceAbstract>[];
|
|
@@ -23,8 +23,8 @@ export declare abstract class DiContainerAbstract {
|
|
|
23
23
|
private injectProviders;
|
|
24
24
|
private injectServices;
|
|
25
25
|
private injectRepositories;
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
private
|
|
26
|
+
private injectWorks;
|
|
27
|
+
private injectThetas;
|
|
28
|
+
private injectForces;
|
|
29
29
|
}
|
|
30
30
|
export {};
|
|
@@ -4,9 +4,9 @@ exports.DiContainerAbstract = void 0;
|
|
|
4
4
|
const di_container_1 = require("./di-container");
|
|
5
5
|
class DiContainerAbstract {
|
|
6
6
|
constructor() {
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
7
|
+
this.injectForces();
|
|
8
|
+
this.injectThetas();
|
|
9
|
+
this.injectWorks();
|
|
10
10
|
this.injectRepositories();
|
|
11
11
|
this.injectServices();
|
|
12
12
|
this.injectProviders();
|
|
@@ -26,18 +26,18 @@ class DiContainerAbstract {
|
|
|
26
26
|
di_container_1.diContainer.bind(dependency.token.valueOf).to(dependency.target);
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
this.dependencies.
|
|
29
|
+
injectWorks() {
|
|
30
|
+
this.dependencies.works.map((dependency) => {
|
|
31
31
|
di_container_1.diContainer.bind(dependency.token.valueOf).to(dependency.target);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
|
-
|
|
35
|
-
this.dependencies.
|
|
34
|
+
injectThetas() {
|
|
35
|
+
this.dependencies.thetas.map((dependency) => {
|
|
36
36
|
di_container_1.diContainer.bind(dependency.constructor).toSelf();
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
this.dependencies.
|
|
39
|
+
injectForces() {
|
|
40
|
+
this.dependencies.forces.map((dependency) => {
|
|
41
41
|
di_container_1.diContainer.bind(dependency.constructor).toSelf();
|
|
42
42
|
});
|
|
43
43
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextFunction, Request, RequestHandler, Response } from "express";
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class BodyParserTheta {
|
|
3
3
|
private readonly plainTextEndpoints;
|
|
4
4
|
private readonly bodyParserJson;
|
|
5
5
|
private readonly bodyParserText;
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.BodyParserTheta = void 0;
|
|
7
7
|
const body_parser_1 = __importDefault(require("body-parser"));
|
|
8
|
-
class
|
|
8
|
+
class BodyParserTheta {
|
|
9
9
|
constructor() {
|
|
10
10
|
this.plainTextEndpoints = ["/encrypted-webhook/notification"];
|
|
11
11
|
this.bodyParserJson = body_parser_1.default.json({ limit: "50mb" });
|
|
@@ -14,8 +14,8 @@ class BodyParserMiddleware {
|
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
static create() {
|
|
17
|
-
const
|
|
18
|
-
return (request, response, next) =>
|
|
17
|
+
const theta = new BodyParserTheta();
|
|
18
|
+
return (request, response, next) => theta.use(request, response, next);
|
|
19
19
|
}
|
|
20
20
|
use(request, response, next) {
|
|
21
21
|
if (this.isPlainTextEndpoint(request.url)) {
|
|
@@ -28,4 +28,4 @@ class BodyParserMiddleware {
|
|
|
28
28
|
return this.plainTextEndpoints.some((endpoint) => url.startsWith(endpoint));
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
exports.
|
|
31
|
+
exports.BodyParserTheta = BodyParserTheta;
|
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.CorsTheta = void 0;
|
|
7
7
|
const cors_1 = __importDefault(require("cors"));
|
|
8
8
|
const verses_1 = require("../../backend/stitch/verses");
|
|
9
|
-
class
|
|
9
|
+
class CorsTheta {
|
|
10
10
|
constructor(corsSpecs) {
|
|
11
11
|
this.corsSpecs = corsSpecs;
|
|
12
12
|
this.cors = (0, cors_1.default)({
|
|
@@ -15,8 +15,8 @@ class CorsMiddleware {
|
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
static create(corsSpecs = verses_1.CORS_ALLOWED_ORIGINS) {
|
|
18
|
-
const
|
|
19
|
-
return (request, response, next) =>
|
|
18
|
+
const theta = new CorsTheta(corsSpecs);
|
|
19
|
+
return (request, response, next) => theta.use(request, response, next);
|
|
20
20
|
}
|
|
21
21
|
use(request, response, next) {
|
|
22
22
|
this.cors(request, response, next);
|
|
@@ -35,4 +35,4 @@ class CorsMiddleware {
|
|
|
35
35
|
return new RegExp(pattern, flags);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
exports.
|
|
38
|
+
exports.CorsTheta = CorsTheta;
|
package/setup/server/{default-error-handler-middleware.d.ts → default-error-handler-theta.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorRequestHandler, NextFunction, Request, Response } from "express";
|
|
2
|
-
export declare class
|
|
2
|
+
export declare class DefaultErrorHandlerTheta {
|
|
3
3
|
static create(): ErrorRequestHandler;
|
|
4
4
|
use(error: Error, req: Request, res: Response, next: NextFunction): void;
|
|
5
5
|
private handleError;
|
|
@@ -3,15 +3,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.DefaultErrorHandlerTheta = void 0;
|
|
7
7
|
const lodash_1 = __importDefault(require("lodash"));
|
|
8
8
|
const routing_controllers_1 = require("routing-controllers");
|
|
9
9
|
const arch_1 = require("@atlantjs/arch");
|
|
10
10
|
const unknow_error_1 = require("./unknow.error");
|
|
11
|
-
class
|
|
11
|
+
class DefaultErrorHandlerTheta {
|
|
12
12
|
static create() {
|
|
13
|
-
const
|
|
14
|
-
return (error, req, res, next) =>
|
|
13
|
+
const theta = new DefaultErrorHandlerTheta();
|
|
14
|
+
return (error, req, res, next) => theta.use(error, req, res, next);
|
|
15
15
|
}
|
|
16
16
|
use(error, req, res, next) {
|
|
17
17
|
if (res.headersSent) {
|
|
@@ -47,4 +47,4 @@ class DefaultErrorHandlerMiddleware {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
exports.
|
|
50
|
+
exports.DefaultErrorHandlerTheta = DefaultErrorHandlerTheta;
|
package/setup/server/server.js
CHANGED
|
@@ -10,9 +10,9 @@ const express_1 = __importDefault(require("express"));
|
|
|
10
10
|
const helmet_1 = __importDefault(require("helmet"));
|
|
11
11
|
const routing_controllers_1 = require("routing-controllers");
|
|
12
12
|
const verses_1 = require("../../backend/stitch/verses");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
13
|
+
const body_parser_theta_1 = require("./body-parser-theta");
|
|
14
|
+
const cors_theta_1 = require("./cors-theta");
|
|
15
|
+
const default_error_handler_theta_1 = require("./default-error-handler-theta");
|
|
16
16
|
var LogMessage;
|
|
17
17
|
(function (LogMessage) {
|
|
18
18
|
LogMessage["$start_server"] = "\n\uD83D\uDDA5\uFE0F Starting server...";
|
|
@@ -26,10 +26,10 @@ class Server {
|
|
|
26
26
|
Server.instance.disable("x-powered-by");
|
|
27
27
|
Server.instance.set("trust proxy", ["uniquelocal", "loopback"]);
|
|
28
28
|
Server.instance.use((0, helmet_1.default)());
|
|
29
|
-
Server.instance.use(
|
|
29
|
+
Server.instance.use(cors_theta_1.CorsTheta.create());
|
|
30
30
|
Server.instance.use((0, cookie_parser_1.default)());
|
|
31
|
-
Server.instance.use(
|
|
32
|
-
Server.instance.use(
|
|
31
|
+
Server.instance.use(body_parser_theta_1.BodyParserTheta.create());
|
|
32
|
+
Server.instance.use(default_error_handler_theta_1.DefaultErrorHandlerTheta.create());
|
|
33
33
|
(0, routing_controllers_1.useExpressServer)(Server.instance, Server.routingOptions);
|
|
34
34
|
console.info(LogMessage.$start_server);
|
|
35
35
|
Server.instance.listen(verses_1.APP_PORT, () => {
|