@atlantjs/backend 11.0.24 → 11.0.25
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/package.json +1 -1
- package/setup/index.d.ts +3 -0
- package/setup/index.js +2 -2
- package/setup/server/server.d.ts +1 -1
- package/setup/server/server.js +11 -3
- package/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
package/setup/index.d.ts
CHANGED
|
@@ -3,6 +3,9 @@ import { DatabaseConfigAbstract, DatabaseHelperAbstract, DatabaseLiteConfigAbstr
|
|
|
3
3
|
import express from "express";
|
|
4
4
|
import { interfaces } from "inversify";
|
|
5
5
|
export interface ServerProps {
|
|
6
|
+
application: {
|
|
7
|
+
ports: string[];
|
|
8
|
+
};
|
|
6
9
|
databases?: Array<{
|
|
7
10
|
token: interfaces.ServiceIdentifier<unknown>;
|
|
8
11
|
target: InstanceType<typeof DatabaseHelperAbstract>;
|
package/setup/index.js
CHANGED
|
@@ -43,8 +43,8 @@ async function initialize(props) {
|
|
|
43
43
|
}),
|
|
44
44
|
]);
|
|
45
45
|
}
|
|
46
|
-
task.title = `Server started on port \x1b[1m${
|
|
47
|
-
ctx.server = server_1.Server.initialize();
|
|
46
|
+
task.title = `Server started on port \x1b[1m${props.application.ports}\x1b`;
|
|
47
|
+
ctx.server = server_1.Server.initialize(props.application.ports);
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
50
|
]);
|
package/setup/server/server.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import express from "express";
|
|
|
2
2
|
export declare class Server {
|
|
3
3
|
static readonly instance: import("express-serve-static-core").Express;
|
|
4
4
|
private static readonly routingOptions;
|
|
5
|
-
static initialize(): express.Application;
|
|
5
|
+
static initialize(ports: string[]): express.Application;
|
|
6
6
|
}
|
package/setup/server/server.js
CHANGED
|
@@ -8,12 +8,12 @@ const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
|
8
8
|
const express_1 = __importDefault(require("express"));
|
|
9
9
|
const helmet_1 = __importDefault(require("helmet"));
|
|
10
10
|
const routing_controllers_1 = require("routing-controllers");
|
|
11
|
-
const verses_1 = require("../../backend/stitch/verses");
|
|
12
11
|
const body_parser_theta_1 = require("./body-parser-theta");
|
|
13
12
|
const cors_theta_1 = require("./cors-theta");
|
|
14
13
|
const default_error_handler_theta_1 = require("./default-error-handler-theta");
|
|
14
|
+
const signale_1 = __importDefault(require("signale"));
|
|
15
15
|
class Server {
|
|
16
|
-
static initialize() {
|
|
16
|
+
static initialize(ports) {
|
|
17
17
|
Server.instance.disable("x-powered-by");
|
|
18
18
|
Server.instance.set("trust proxy", ["uniquelocal", "loopback"]);
|
|
19
19
|
Server.instance.use((0, helmet_1.default)());
|
|
@@ -22,7 +22,15 @@ class Server {
|
|
|
22
22
|
Server.instance.use(body_parser_theta_1.BodyParserTheta.create());
|
|
23
23
|
Server.instance.use(default_error_handler_theta_1.DefaultErrorHandlerTheta.create());
|
|
24
24
|
(0, routing_controllers_1.useExpressServer)(Server.instance, Server.routingOptions);
|
|
25
|
-
|
|
25
|
+
let portsListened = [];
|
|
26
|
+
for (const port of ports) {
|
|
27
|
+
if (portsListened.includes(port)) {
|
|
28
|
+
signale_1.default.warn(`Port ${port} is already being listened to. Skipping...`);
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
Server.instance.listen(port);
|
|
32
|
+
portsListened.push(port);
|
|
33
|
+
}
|
|
26
34
|
return Server.instance;
|
|
27
35
|
}
|
|
28
36
|
}
|