c2-http 1.0.18 → 1.0.19
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/i18n.js +2 -0
- package/dist/model/Server.d.ts +3 -2
- package/dist/model/Server.js +8 -18
- package/package.json +1 -1
package/dist/i18n.js
CHANGED
|
@@ -16,7 +16,9 @@ let i18n = i18nCreate({
|
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
18
|
const initializei18n = (config) => {
|
|
19
|
+
console.log("Initializing i18n...");
|
|
19
20
|
i18n = i18nCreate(config);
|
|
21
|
+
console.log("Done i18n");
|
|
20
22
|
};
|
|
21
23
|
exports.initializei18n = initializei18n;
|
|
22
24
|
const getMessage = (message, ...parameters) => {
|
package/dist/model/Server.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import express, { Request, Response,
|
|
1
|
+
import express, { NextFunction, Request, Response, Router } from "express";
|
|
2
2
|
export interface IServerConfig {
|
|
3
3
|
port: string;
|
|
4
4
|
globalMiddleware: (app: express.Application) => void;
|
|
5
5
|
tokenCheckMiddleware: (request: Request, response: Response, next: NextFunction) => void;
|
|
6
6
|
routesWithToken: Router[];
|
|
7
7
|
routes: Router[];
|
|
8
|
+
i18n: any;
|
|
8
9
|
}
|
|
9
10
|
export declare class Server {
|
|
10
11
|
app: express.Application;
|
|
11
12
|
config: IServerConfig;
|
|
12
13
|
constructor(config: IServerConfig);
|
|
13
|
-
initialize(): Promise<void>;
|
|
14
|
+
initialize(callback?: () => void): Promise<void>;
|
|
14
15
|
}
|
package/dist/model/Server.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.Server = void 0;
|
|
7
7
|
const express_1 = __importDefault(require("express"));
|
|
8
|
+
const i18n_1 = require("../i18n");
|
|
8
9
|
class Server {
|
|
9
10
|
app;
|
|
10
11
|
config;
|
|
@@ -12,23 +13,9 @@ class Server {
|
|
|
12
13
|
this.app = (0, express_1.default)();
|
|
13
14
|
this.config = config;
|
|
14
15
|
}
|
|
15
|
-
async initialize() {
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
// })
|
|
16
|
+
async initialize(callback) {
|
|
17
|
+
(0, i18n_1.initializei18n)(this.config.i18n);
|
|
18
|
+
console.log(`Initializing server on ${this.config.port}...`);
|
|
32
19
|
this.config.globalMiddleware(this.app);
|
|
33
20
|
for (const router of this.config.routes) {
|
|
34
21
|
this.app.use(router);
|
|
@@ -37,8 +24,11 @@ class Server {
|
|
|
37
24
|
for (const router of this.config.routesWithToken) {
|
|
38
25
|
this.app.use(router);
|
|
39
26
|
}
|
|
40
|
-
this.app.listen(this.config.port, () => {
|
|
27
|
+
this.app.listen(this.config.port, async () => {
|
|
41
28
|
console.info(`Server running on port ${this.config.port}`);
|
|
29
|
+
if (callback) {
|
|
30
|
+
await callback();
|
|
31
|
+
}
|
|
42
32
|
});
|
|
43
33
|
}
|
|
44
34
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2-http",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
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>",
|