@ccci/micro-server 1.0.70 → 1.0.72
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 +10 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -113608,22 +113608,13 @@ class DatabaseConnector {
|
|
|
113608
113608
|
let files = fs.readdirSync(`${DatabaseConnector.rootDir}/models`).filter((file) => file.indexOf(".") !== 0 && file.slice(-3) === ".ts");
|
|
113609
113609
|
for (let i = 0;i < files.length; i++) {
|
|
113610
113610
|
let file = files[i];
|
|
113611
|
-
await import(`${DatabaseConnector.rootDir}/models/${file}`).then((
|
|
113612
|
-
console.log("Initializing Model :>> ",
|
|
113613
|
-
if (
|
|
113614
|
-
|
|
113611
|
+
await import(`${DatabaseConnector.rootDir}/models/${file}`).then((model) => {
|
|
113612
|
+
console.log("Initializing Model :>> ", model.default);
|
|
113613
|
+
if (model && model.default && model.default.associate) {
|
|
113614
|
+
model.default.associate();
|
|
113615
113615
|
}
|
|
113616
113616
|
});
|
|
113617
113617
|
}
|
|
113618
|
-
console.log("Sync STARTED :>> ");
|
|
113619
|
-
await DatabaseConnector.connection.sync({ force: true });
|
|
113620
|
-
let model = DatabaseConnector.connection.models["Chats"];
|
|
113621
|
-
model.sync({ force: true }).then((res) => {
|
|
113622
|
-
console.log("Sync Result:", res);
|
|
113623
|
-
}).catch((err) => {
|
|
113624
|
-
console.log("Sync Error:", err);
|
|
113625
|
-
});
|
|
113626
|
-
console.log("Sync ENDED :>> ");
|
|
113627
113618
|
} catch (error) {
|
|
113628
113619
|
console.log(error);
|
|
113629
113620
|
}
|
|
@@ -119176,6 +119167,7 @@ class ApplicationServer {
|
|
|
119176
119167
|
ApplicationServer.app.use(import_express_fileupload.default());
|
|
119177
119168
|
const db = new DatabaseConnector(process.cwd());
|
|
119178
119169
|
const conn = await DatabaseConnector.init();
|
|
119170
|
+
await db.connect(conn[0]);
|
|
119179
119171
|
await db.initializeModels();
|
|
119180
119172
|
ApplicationServer.app.get("/", (req, resp) => {
|
|
119181
119173
|
return resp.sendFile(path4.resolve("index.html"));
|
|
@@ -119193,6 +119185,11 @@ class ApplicationServer {
|
|
|
119193
119185
|
const mailer = Mailer.getInstance();
|
|
119194
119186
|
mailer.connect(options);
|
|
119195
119187
|
}
|
|
119188
|
+
if (sync) {
|
|
119189
|
+
sync.forEach(async (model) => {
|
|
119190
|
+
await DatabaseConnector.sync(model, true);
|
|
119191
|
+
});
|
|
119192
|
+
}
|
|
119196
119193
|
});
|
|
119197
119194
|
}
|
|
119198
119195
|
getInstance() {
|