@ccci/micro-server 1.0.4 → 1.0.5
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/index.js +15 -7
- package/dist/utils/ApplicationServer.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -86994,6 +86994,7 @@ var require_winston = __commonJS((exports) => {
|
|
|
86994
86994
|
// src/utils/ApplicationServer.ts
|
|
86995
86995
|
var import_express = __toESM(require_express2(), 1);
|
|
86996
86996
|
var import_cors = __toESM(require_lib3(), 1);
|
|
86997
|
+
import path2 from "path";
|
|
86997
86998
|
|
|
86998
86999
|
// node_modules/helmet/index.mjs
|
|
86999
87000
|
var normalizeDirectives = function(options) {
|
|
@@ -87760,25 +87761,32 @@ class RouterFactory {
|
|
|
87760
87761
|
|
|
87761
87762
|
// src/utils/ApplicationServer.ts
|
|
87762
87763
|
class ApplicationServer {
|
|
87764
|
+
static app;
|
|
87763
87765
|
static async bootstrap(port, options) {
|
|
87764
|
-
|
|
87766
|
+
ApplicationServer.app = import_express.default();
|
|
87765
87767
|
Logger.info("Setting up application middlewares...\n");
|
|
87766
|
-
app.use(import_cors.default());
|
|
87767
|
-
app.use(helmet());
|
|
87768
|
-
app.use(import_express.default.json());
|
|
87769
|
-
app.use(import_express_fileupload.default());
|
|
87768
|
+
ApplicationServer.app.use(import_cors.default());
|
|
87769
|
+
ApplicationServer.app.use(helmet());
|
|
87770
|
+
ApplicationServer.app.use(import_express.default.json());
|
|
87771
|
+
ApplicationServer.app.use(import_express_fileupload.default());
|
|
87770
87772
|
Logger.info("Initializing DB Connection...\n");
|
|
87771
87773
|
const db = new DatabaseConnector(process.cwd());
|
|
87772
87774
|
const conn = await DatabaseConnector.init();
|
|
87773
87775
|
await db.connect(conn[0]);
|
|
87774
87776
|
await db.initializeModels();
|
|
87777
|
+
ApplicationServer.app.get("/", (req, resp) => {
|
|
87778
|
+
return resp.sendFile(path2.resolve("index.html"));
|
|
87779
|
+
});
|
|
87775
87780
|
Logger.info("Create API Routes...\n");
|
|
87776
|
-
new RouterFactory(app, process.cwd(), "routes");
|
|
87781
|
+
new RouterFactory(ApplicationServer.app, process.cwd(), "routes");
|
|
87777
87782
|
Logger.info("Starting Server...\n");
|
|
87778
|
-
app.listen(port, () => {
|
|
87783
|
+
ApplicationServer.app.listen(port, () => {
|
|
87779
87784
|
Logger.info(`API Sever ready at: http://127.0.0.1:${port}\n`);
|
|
87780
87785
|
});
|
|
87781
87786
|
}
|
|
87787
|
+
getInstance() {
|
|
87788
|
+
return ApplicationServer.app;
|
|
87789
|
+
}
|
|
87782
87790
|
}
|
|
87783
87791
|
// src/utils/BaseRouter.ts
|
|
87784
87792
|
var import_express2 = __toESM(require_express2(), 1);
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
import express, { Application } from 'express';
|
|
1
2
|
import { ApplicationOptionType } from '@/types/ApplicationOptionType';
|
|
2
3
|
/**
|
|
3
4
|
* Application Sever class
|
|
4
5
|
*/
|
|
5
6
|
export default class ApplicationServer {
|
|
7
|
+
static app: Application;
|
|
6
8
|
/**
|
|
7
9
|
* Initializes the application server
|
|
8
10
|
* @param {number} port port for the micro service
|
|
9
11
|
* @param {ApplicationOptionType=} options additional server configuration
|
|
10
12
|
*/
|
|
11
13
|
static bootstrap(port: number, options?: ApplicationOptionType): Promise<void>;
|
|
14
|
+
getInstance(): express.Application;
|
|
12
15
|
}
|
|
13
16
|
//# sourceMappingURL=ApplicationServer.d.ts.map
|