@ccci/micro-server 1.0.41 → 1.0.42
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 +5 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -87552,6 +87552,7 @@ class DatabaseConnector {
|
|
|
87552
87552
|
DatabaseConnector.rootDir = path;
|
|
87553
87553
|
}
|
|
87554
87554
|
static async init() {
|
|
87555
|
+
Logger.info("Initializing DB Connection...\n");
|
|
87555
87556
|
return new Promise((resolve, reject) => {
|
|
87556
87557
|
let connections = [];
|
|
87557
87558
|
try {
|
|
@@ -87561,7 +87562,9 @@ class DatabaseConnector {
|
|
|
87561
87562
|
const config = configs.default[env];
|
|
87562
87563
|
const connection = new Sequelize(config);
|
|
87563
87564
|
DatabaseConnector.connection = connection;
|
|
87565
|
+
Logger.info("Connecting to:", connection);
|
|
87564
87566
|
connections.push(connection);
|
|
87567
|
+
Logger.info("Connecting to database:", connection);
|
|
87565
87568
|
resolve(connections);
|
|
87566
87569
|
});
|
|
87567
87570
|
} catch (error) {
|
|
@@ -87630,6 +87633,7 @@ var UNSECURED_DIR = ["dev", "public"];
|
|
|
87630
87633
|
class RouterFactory {
|
|
87631
87634
|
constructor(app, pathName, folderName = "routes", context = "api") {
|
|
87632
87635
|
try {
|
|
87636
|
+
Logger.info("Create API Routes...\n");
|
|
87633
87637
|
fs2.readdirSync(folderName).forEach((dir) => {
|
|
87634
87638
|
let isUnsecure = UNSECURED_DIR.findIndex((x) => x === dir) > -1;
|
|
87635
87639
|
var routerDir = path.join(folderName, dir);
|
|
@@ -87642,7 +87646,7 @@ class RouterFactory {
|
|
|
87642
87646
|
import(routeFile).then((routerClass) => {
|
|
87643
87647
|
let router = new routerClass.default;
|
|
87644
87648
|
app.use(endpoint, (req, res, next) => this.authenticate(req, res, next, isUnsecure || router.grantPublicAccess), router.getRoutes());
|
|
87645
|
-
Logger.info(
|
|
87649
|
+
Logger.info("Initializing endpoint:", endpoint);
|
|
87646
87650
|
});
|
|
87647
87651
|
}
|
|
87648
87652
|
});
|
|
@@ -87736,16 +87740,13 @@ class ApplicationServer {
|
|
|
87736
87740
|
ApplicationServer.app.use(helmet());
|
|
87737
87741
|
ApplicationServer.app.use(import_express.default.json());
|
|
87738
87742
|
ApplicationServer.app.use(import_express_fileupload.default());
|
|
87739
|
-
Logger.info("Initializing DB Connection...\n");
|
|
87740
87743
|
const db = new DatabaseConnector(process.cwd());
|
|
87741
87744
|
const conn = await DatabaseConnector.init();
|
|
87742
87745
|
await db.initializeModels();
|
|
87743
87746
|
ApplicationServer.app.get("/", (req, resp) => {
|
|
87744
87747
|
return resp.sendFile(path3.resolve("index.html"));
|
|
87745
87748
|
});
|
|
87746
|
-
Logger.info("Create API Routes...\n");
|
|
87747
87749
|
new RouterFactory(ApplicationServer.app, process.cwd(), "routes");
|
|
87748
|
-
Logger.info("Starting Server...\n");
|
|
87749
87750
|
const server = ApplicationServer.app.listen(port, () => {
|
|
87750
87751
|
Logger.info(`API Sever ready at: http://127.0.0.1:${port}\n`);
|
|
87751
87752
|
});
|