c2-http 1.0.16 → 1.0.18
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/dist/model/Server.d.ts +3 -0
- package/dist/model/Server.js +27 -4
- package/package.json +1 -1
package/dist/model/Server.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import express, { Request, Response, NextFunction, Router } from "express";
|
|
2
2
|
export interface IServerConfig {
|
|
3
|
+
port: string;
|
|
3
4
|
globalMiddleware: (app: express.Application) => void;
|
|
4
5
|
tokenCheckMiddleware: (request: Request, response: Response, next: NextFunction) => void;
|
|
5
6
|
routesWithToken: Router[];
|
|
@@ -7,5 +8,7 @@ export interface IServerConfig {
|
|
|
7
8
|
}
|
|
8
9
|
export declare class Server {
|
|
9
10
|
app: express.Application;
|
|
11
|
+
config: IServerConfig;
|
|
10
12
|
constructor(config: IServerConfig);
|
|
13
|
+
initialize(): Promise<void>;
|
|
11
14
|
}
|
package/dist/model/Server.js
CHANGED
|
@@ -7,16 +7,39 @@ exports.Server = void 0;
|
|
|
7
7
|
const express_1 = __importDefault(require("express"));
|
|
8
8
|
class Server {
|
|
9
9
|
app;
|
|
10
|
+
config;
|
|
10
11
|
constructor(config) {
|
|
11
12
|
this.app = (0, express_1.default)();
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
this.config = config;
|
|
14
|
+
}
|
|
15
|
+
async initialize() {
|
|
16
|
+
// const port = httpPort || "8085";
|
|
17
|
+
// console.info(`Server starting... on port ${port}`);
|
|
18
|
+
// await Database.createConnection()
|
|
19
|
+
// initializei18n({
|
|
20
|
+
// defaultLocale: "pt-br",
|
|
21
|
+
// warn: false, // optional
|
|
22
|
+
// allowFallback: true, // optional
|
|
23
|
+
// messages: {
|
|
24
|
+
// "en": en,
|
|
25
|
+
// "en-US": en,
|
|
26
|
+
// "en_US": en,
|
|
27
|
+
// "pt": pt_BR,
|
|
28
|
+
// "pt-br": pt_BR,
|
|
29
|
+
// "pt_BR": pt_BR
|
|
30
|
+
// }
|
|
31
|
+
// })
|
|
32
|
+
this.config.globalMiddleware(this.app);
|
|
33
|
+
for (const router of this.config.routes) {
|
|
14
34
|
this.app.use(router);
|
|
15
35
|
}
|
|
16
|
-
config.tokenCheckMiddleware;
|
|
17
|
-
for (const router of config.routesWithToken) {
|
|
36
|
+
this.app.use(this.config.tokenCheckMiddleware);
|
|
37
|
+
for (const router of this.config.routesWithToken) {
|
|
18
38
|
this.app.use(router);
|
|
19
39
|
}
|
|
40
|
+
this.app.listen(this.config.port, () => {
|
|
41
|
+
console.info(`Server running on port ${this.config.port}`);
|
|
42
|
+
});
|
|
20
43
|
}
|
|
21
44
|
}
|
|
22
45
|
exports.Server = Server;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2-http",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.18",
|
|
4
4
|
"description": "Biblioteca Typescript para API NodeJS",
|
|
5
5
|
"repository": "https://cabralsilva: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@github.com/cabralsilva/c2-http.git",
|
|
6
6
|
"author": "Daniel Cabral <cabralconsultoriaemsoftware@gmail.com>",
|