miqro 6.2.2 → 6.2.4
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/build/esm/src/common/arguments.js +25 -15
- package/build/esm/src/inflate/inflate-sea.d.ts +1 -1
- package/build/esm/src/inflate/inflate-sea.js +15 -13
- package/build/esm/src/inflate/inflate.d.ts +2 -1
- package/build/esm/src/inflate/inflate.js +2 -2
- package/build/esm/src/inflate/setup-auth.js +2 -1
- package/build/esm/src/inflate/setup-cors.js +2 -1
- package/build/esm/src/inflate/setup-db.js +4 -2
- package/build/esm/src/inflate/setup-error.js +2 -1
- package/build/esm/src/inflate/setup-http.js +2 -1
- package/build/esm/src/inflate/setup-log.js +2 -1
- package/build/esm/src/inflate/setup-middleware.js +2 -1
- package/build/esm/src/inflate/setup-server-config.js +2 -1
- package/build/esm/src/inflate/setup-ws.js +2 -1
- package/build/esm/src/services/app.js +21 -17
- package/build/esm/src/services/migrations.js +4 -2
- package/build/lib.cjs +42 -51
- package/package.json +1 -1
- package/src/common/arguments.ts +23 -15
- package/src/inflate/inflate-sea.ts +16 -13
- package/src/inflate/inflate.ts +3 -2
- package/src/inflate/setup-auth.ts +2 -1
- package/src/inflate/setup-cors.ts +2 -1
- package/src/inflate/setup-db.ts +4 -2
- package/src/inflate/setup-error.ts +2 -1
- package/src/inflate/setup-http.ts +2 -1
- package/src/inflate/setup-log.ts +2 -1
- package/src/inflate/setup-middleware.ts +2 -1
- package/src/inflate/setup-server-config.ts +2 -1
- package/src/inflate/setup-ws.ts +2 -1
- package/src/services/app.ts +9 -5
- package/src/services/migrations.ts +4 -2
package/build/lib.cjs
CHANGED
|
@@ -14780,7 +14780,7 @@ async function setupCORS(logger, servicePath, service, mainRouter, inflateDir, i
|
|
|
14780
14780
|
logger.debug("setting up cors from [%s]", (0, import_node_path6.join)(service, (0, import_node_path6.basename)(corsPath)));
|
|
14781
14781
|
mainRouter.use(CORS(corsOptions));
|
|
14782
14782
|
if (inflateDir && inflateSea) {
|
|
14783
|
-
const inflatePath = (0, import_node_path6.resolve)(inflateDir, service, "cors.
|
|
14783
|
+
const inflatePath = (0, import_node_path6.resolve)(inflateDir, service, "cors.cjs");
|
|
14784
14784
|
(0, import_node_fs7.mkdirSync)((0, import_node_path6.dirname)(inflatePath), {
|
|
14785
14785
|
recursive: true
|
|
14786
14786
|
});
|
|
@@ -14789,6 +14789,7 @@ async function setupCORS(logger, servicePath, service, mainRouter, inflateDir, i
|
|
|
14789
14789
|
embemedJSX: false,
|
|
14790
14790
|
minify: false,
|
|
14791
14791
|
useExport: true,
|
|
14792
|
+
platform: "node",
|
|
14792
14793
|
logger
|
|
14793
14794
|
}));
|
|
14794
14795
|
}
|
|
@@ -14815,7 +14816,7 @@ async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, i
|
|
|
14815
14816
|
logger.debug("setting up authentication from [%s]", (0, import_node_path7.join)(service, (0, import_node_path7.basename)(authPath)));
|
|
14816
14817
|
mainRouter.use(SessionHandler(authModule));
|
|
14817
14818
|
if (inflateDir && inflateSea) {
|
|
14818
|
-
const inflatePath = (0, import_node_path7.resolve)(inflateDir, service, "auth.
|
|
14819
|
+
const inflatePath = (0, import_node_path7.resolve)(inflateDir, service, "auth.cjs");
|
|
14819
14820
|
(0, import_node_fs8.mkdirSync)((0, import_node_path7.dirname)(inflatePath), {
|
|
14820
14821
|
recursive: true
|
|
14821
14822
|
});
|
|
@@ -14824,6 +14825,7 @@ async function setupAUTH(logger, servicePath, service, mainRouter, inflateDir, i
|
|
|
14824
14825
|
embemedJSX: false,
|
|
14825
14826
|
minify: false,
|
|
14826
14827
|
useExport: true,
|
|
14828
|
+
platform: "node",
|
|
14827
14829
|
logger
|
|
14828
14830
|
}));
|
|
14829
14831
|
}
|
|
@@ -14929,7 +14931,7 @@ async function setupMiddleware(logger, servicePath, service, mainRouter, inflate
|
|
|
14929
14931
|
}
|
|
14930
14932
|
}
|
|
14931
14933
|
if (inflateDir && inflateSea) {
|
|
14932
|
-
const inflatePath = (0, import_node_path10.resolve)(inflateDir, service, "middleware.
|
|
14934
|
+
const inflatePath = (0, import_node_path10.resolve)(inflateDir, service, "middleware.cjs");
|
|
14933
14935
|
(0, import_node_fs9.mkdirSync)((0, import_node_path10.dirname)(inflatePath), {
|
|
14934
14936
|
recursive: true
|
|
14935
14937
|
});
|
|
@@ -14937,6 +14939,7 @@ async function setupMiddleware(logger, servicePath, service, mainRouter, inflate
|
|
|
14937
14939
|
(0, import_node_fs9.writeFileSync)(inflatePath, await inflateJSX(middlewarePath, {
|
|
14938
14940
|
embemedJSX: false,
|
|
14939
14941
|
minify: false,
|
|
14942
|
+
platform: "node",
|
|
14940
14943
|
useExport: true,
|
|
14941
14944
|
logger
|
|
14942
14945
|
}));
|
|
@@ -14970,7 +14973,7 @@ async function setupError(logger, servicePath, service, mainRouter, inflateDir,
|
|
|
14970
14973
|
}
|
|
14971
14974
|
}
|
|
14972
14975
|
if (inflateDir && inflateSea) {
|
|
14973
|
-
const inflatePath = (0, import_node_path11.resolve)(inflateDir, service, "catch.
|
|
14976
|
+
const inflatePath = (0, import_node_path11.resolve)(inflateDir, service, "catch.cjs");
|
|
14974
14977
|
(0, import_node_fs10.mkdirSync)((0, import_node_path11.dirname)(inflatePath), {
|
|
14975
14978
|
recursive: true
|
|
14976
14979
|
});
|
|
@@ -14979,6 +14982,7 @@ async function setupError(logger, servicePath, service, mainRouter, inflateDir,
|
|
|
14979
14982
|
embemedJSX: false,
|
|
14980
14983
|
minify: false,
|
|
14981
14984
|
useExport: true,
|
|
14985
|
+
platform: "node",
|
|
14982
14986
|
logger
|
|
14983
14987
|
}));
|
|
14984
14988
|
}
|
|
@@ -15121,12 +15125,13 @@ async function createRouterFromDirectory(server2, hotreload, service, logger, di
|
|
|
15121
15125
|
embemedJSX: false,
|
|
15122
15126
|
minify: false,
|
|
15123
15127
|
useExport: true,
|
|
15128
|
+
platform: "node",
|
|
15124
15129
|
logger
|
|
15125
15130
|
}) : "";
|
|
15126
15131
|
for (const r of routes) {
|
|
15127
15132
|
if (inflateDir && r.defaultInflatePath && inflateSea) {
|
|
15128
15133
|
const rPath = r.defaultInflatePath;
|
|
15129
|
-
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "http", rPath + ".api.
|
|
15134
|
+
const inflatePath = (0, import_node_path12.join)(inflateDir, service, "http", rPath + ".api.cjs");
|
|
15130
15135
|
(0, import_node_fs11.mkdirSync)((0, import_node_path12.dirname)(inflatePath), {
|
|
15131
15136
|
recursive: true
|
|
15132
15137
|
});
|
|
@@ -15528,7 +15533,7 @@ async function inflateWSConfig(logger, servicePath, service, wsConfigList, infla
|
|
|
15528
15533
|
wsConfigList.push(wsConfig);
|
|
15529
15534
|
}
|
|
15530
15535
|
if (inflateDir) {
|
|
15531
|
-
const inflatePath = (0, import_node_path13.resolve)(inflateDir, service, "ws.
|
|
15536
|
+
const inflatePath = (0, import_node_path13.resolve)(inflateDir, service, "ws.cjs");
|
|
15532
15537
|
(0, import_node_fs12.mkdirSync)((0, import_node_path13.dirname)(inflatePath), {
|
|
15533
15538
|
recursive: true
|
|
15534
15539
|
});
|
|
@@ -15536,6 +15541,7 @@ async function inflateWSConfig(logger, servicePath, service, wsConfigList, infla
|
|
|
15536
15541
|
(0, import_node_fs12.writeFileSync)(inflatePath, await inflateJSX(wsPath, {
|
|
15537
15542
|
embemedJSX: false,
|
|
15538
15543
|
minify: false,
|
|
15544
|
+
platform: "node",
|
|
15539
15545
|
useExport: true,
|
|
15540
15546
|
logger
|
|
15541
15547
|
}));
|
|
@@ -15573,19 +15579,20 @@ async function inflateSeaAssets(logger, inflateDir) {
|
|
|
15573
15579
|
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "sign-remove.sh"), Buffer.from(getAsset("sign-remove.sh")));
|
|
15574
15580
|
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "install-nodejs.sh"), Buffer.from(getAsset("install-nodejs.sh")));
|
|
15575
15581
|
}
|
|
15576
|
-
async function inflateAppForSea(logger, inflateDir, services) {
|
|
15582
|
+
async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
15583
|
+
const PORT2 = port;
|
|
15577
15584
|
inflateSeaAssets(logger, inflateDir);
|
|
15578
15585
|
writeFile(logger, (0, import_node_path14.resolve)(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
|
|
15579
15586
|
const WSLIST = services.filter((service) => getWSConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
|
|
15580
|
-
return `(await import("../${service}/ws.
|
|
15587
|
+
return `(await import("../${service}/ws.cjs")).default`;
|
|
15581
15588
|
}).join(",");
|
|
15582
15589
|
const SERVERCONFIGLIST = services.filter((service) => getServerConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
|
|
15583
|
-
return `(await import("../${service}/server.
|
|
15590
|
+
return `(await import("../${service}/server.cjs")).default`;
|
|
15584
15591
|
}).join(",\n");
|
|
15585
15592
|
const DBCONFIGLIST = services.filter((service) => getDBConfigPath((0, import_node_path14.resolve)((0, import_node_process10.cwd)(), service))).map((service) => {
|
|
15586
15593
|
return `new Promise(async (resolve, reject) => {
|
|
15587
15594
|
try {
|
|
15588
|
-
const db = await dbManager.setupDB((await import("../${service}/db.
|
|
15595
|
+
const db = await dbManager.setupDB((await import("../${service}/db.cjs")).default);
|
|
15589
15596
|
await (await import("./${service}/migration-up.js")).runMigrations(db);
|
|
15590
15597
|
resolve();
|
|
15591
15598
|
} catch(e) {
|
|
@@ -15601,7 +15608,7 @@ async function inflateAppForSea(logger, inflateDir, services) {
|
|
|
15601
15608
|
`const { createServerInterface, ServerRequestHandler, WebSocketManager, initGlobals, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
|
|
15602
15609
|
|
|
15603
15610
|
async function main() {
|
|
15604
|
-
const PORT =
|
|
15611
|
+
const PORT = "${PORT2}";
|
|
15605
15612
|
const loggerProvider = new LogProvider();
|
|
15606
15613
|
const localCache = new LocalCache();
|
|
15607
15614
|
const cache = new ClusterCache();
|
|
@@ -15638,6 +15645,7 @@ async function main() {
|
|
|
15638
15645
|
await app.listen(PORT);
|
|
15639
15646
|
${SERVERCONFIGLIST ? `
|
|
15640
15647
|
await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.start).map(config=>config.start(serverInterface)));` : ""}
|
|
15648
|
+
loggerProvider.getLogger("server").info("listening on [%s]", PORT);
|
|
15641
15649
|
}
|
|
15642
15650
|
main().catch(e=>console.error(e));
|
|
15643
15651
|
`
|
|
@@ -15651,16 +15659,16 @@ async function inflateServiceForSea(logger, inflateDir, service, servicePath, se
|
|
|
15651
15659
|
export async function setupRouter() {
|
|
15652
15660
|
const router = new Router();
|
|
15653
15661
|
${getErrorConfigPath(servicePath) ? `
|
|
15654
|
-
const errorConfig = (await import("../../${service}/catch.
|
|
15662
|
+
const errorConfig = (await import("../../${service}/catch.cjs")).default.default;
|
|
15655
15663
|
if(errorConfig && errorConfig.catch) {
|
|
15656
15664
|
for(const m of errorConfig.catch) {
|
|
15657
15665
|
router.catch(m);
|
|
15658
15666
|
}
|
|
15659
15667
|
}` : ""}
|
|
15660
|
-
${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.
|
|
15661
|
-
${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.
|
|
15668
|
+
${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.cjs")).default.default));` : ""}
|
|
15669
|
+
${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.cjs")).default.default));` : ""}
|
|
15662
15670
|
${getMiddlewareConfigPath(servicePath) ? `
|
|
15663
|
-
const middlewareConfig = (await import("../../${service}/middleware.
|
|
15671
|
+
const middlewareConfig = (await import("../../${service}/middleware.cjs")).default.default;
|
|
15664
15672
|
if(middlewareConfig && middlewareConfig.middleware) {
|
|
15665
15673
|
for(const m of middlewareConfig.middleware) {
|
|
15666
15674
|
router.use(m);
|
|
@@ -15670,8 +15678,8 @@ ${Object.keys(serviceRouteFileMap).map((filePath) => serviceRouteFileMap[filePat
|
|
|
15670
15678
|
const rPath = (0, import_node_path14.join)((0, import_node_path14.relative)((0, import_node_process10.cwd)(), (0, import_node_path14.dirname)(data.filePath)), (0, import_node_path14.basename)(data.filePath));
|
|
15671
15679
|
if (rPath) {
|
|
15672
15680
|
const rPathExt = (0, import_node_path14.extname)(rPath);
|
|
15673
|
-
const apiInflatedPath = (0, import_node_path14.join)("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".
|
|
15674
|
-
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default);`;
|
|
15681
|
+
const apiInflatedPath = (0, import_node_path14.join)("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
|
|
15682
|
+
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default.default);`;
|
|
15675
15683
|
} else {
|
|
15676
15684
|
return "";
|
|
15677
15685
|
}
|
|
@@ -15693,7 +15701,7 @@ export async function runMigrations(db) {
|
|
|
15693
15701
|
await migration.init(db);
|
|
15694
15702
|
${serviceMigrations.map((file) => {
|
|
15695
15703
|
const name = `${file.substring(0, file.length - (0, import_node_path14.extname)(file).length)}`;
|
|
15696
|
-
return ` await migration.up.module(db, "${
|
|
15704
|
+
return ` await migration.up.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
|
|
15697
15705
|
}).join("\n")}
|
|
15698
15706
|
}`);
|
|
15699
15707
|
writeFile(logger, (0, import_node_path14.join)(inflateDir, "sea", service, "migration-down.js"), `import { migration } from "./../lib.cjs";
|
|
@@ -15702,7 +15710,7 @@ export async function runMigrations(db) {
|
|
|
15702
15710
|
await migration.init(db);
|
|
15703
15711
|
${serviceMigrations.reverse().map((file) => {
|
|
15704
15712
|
const name = `${file.substring(0, file.length - (0, import_node_path14.extname)(file).length)}`;
|
|
15705
|
-
return ` await migration.down.module(db, "${
|
|
15713
|
+
return ` await migration.down.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
|
|
15706
15714
|
}).join("\n")}
|
|
15707
15715
|
}`);
|
|
15708
15716
|
const staticFiles = Object.keys(serviceStaticFileMap);
|
|
@@ -15745,7 +15753,7 @@ async function setupLogConfig(logger, servicePath, service, logConfigMap, inflat
|
|
|
15745
15753
|
const logConfig = await importLogConfigModule(logPath, logger);
|
|
15746
15754
|
logConfigMap[service] = logConfig;
|
|
15747
15755
|
if (inflateDir) {
|
|
15748
|
-
const inflatePath = (0, import_node_path15.resolve)(inflateDir, service, "log.
|
|
15756
|
+
const inflatePath = (0, import_node_path15.resolve)(inflateDir, service, "log.cjs");
|
|
15749
15757
|
(0, import_node_fs14.mkdirSync)((0, import_node_path15.dirname)(inflatePath), {
|
|
15750
15758
|
recursive: true
|
|
15751
15759
|
});
|
|
@@ -15754,6 +15762,7 @@ async function setupLogConfig(logger, servicePath, service, logConfigMap, inflat
|
|
|
15754
15762
|
embemedJSX: false,
|
|
15755
15763
|
minify: false,
|
|
15756
15764
|
useExport: true,
|
|
15765
|
+
platform: "node",
|
|
15757
15766
|
logger
|
|
15758
15767
|
}));
|
|
15759
15768
|
}
|
|
@@ -16093,15 +16102,7 @@ async function setupDoc(logger, servicePath, service, mainRouter, fileMap, infla
|
|
|
16093
16102
|
}
|
|
16094
16103
|
|
|
16095
16104
|
// src/inflate/inflate.ts
|
|
16096
|
-
async function inflateApp({
|
|
16097
|
-
serverInterface,
|
|
16098
|
-
logger,
|
|
16099
|
-
hotreload,
|
|
16100
|
-
services,
|
|
16101
|
-
inflateDir,
|
|
16102
|
-
inflateSea
|
|
16103
|
-
/*, editor, inflateTests*/
|
|
16104
|
-
}) {
|
|
16105
|
+
async function inflateApp({ serverInterface, logger, hotreload, services, inflateDir, inflateSea, port }) {
|
|
16105
16106
|
logger.trace("inflateApp");
|
|
16106
16107
|
const errors = [];
|
|
16107
16108
|
let routeFileMap = {};
|
|
@@ -16126,7 +16127,7 @@ async function inflateApp({
|
|
|
16126
16127
|
}
|
|
16127
16128
|
}
|
|
16128
16129
|
if (inflateDir && inflateSea) {
|
|
16129
|
-
await inflateAppForSea(logger, inflateDir, services);
|
|
16130
|
+
await inflateAppForSea(logger, inflateDir, services, port);
|
|
16130
16131
|
}
|
|
16131
16132
|
router.use(assertGlobalTampered);
|
|
16132
16133
|
return errors.length === 0 ? [router, null, routeFileMap, wsConfigList, logConfigMap] : [router, errors, routeFileMap, wsConfigList, logConfigMap];
|
|
@@ -16143,7 +16144,7 @@ async function setupServerConfig(logger, servicePath, service, serverConfigMap,
|
|
|
16143
16144
|
const serverConfig = await importServerConfigModule(serverPath, logger);
|
|
16144
16145
|
serverConfigMap[service] = serverConfig;
|
|
16145
16146
|
if (inflateDir) {
|
|
16146
|
-
const inflatePath = (0, import_node_path17.resolve)(inflateDir, service, "server.
|
|
16147
|
+
const inflatePath = (0, import_node_path17.resolve)(inflateDir, service, "server.cjs");
|
|
16147
16148
|
(0, import_node_fs16.mkdirSync)((0, import_node_path17.dirname)(inflatePath), {
|
|
16148
16149
|
recursive: true
|
|
16149
16150
|
});
|
|
@@ -16151,6 +16152,7 @@ async function setupServerConfig(logger, servicePath, service, serverConfigMap,
|
|
|
16151
16152
|
(0, import_node_fs16.writeFileSync)(inflatePath, await inflateJSX(serverPath, {
|
|
16152
16153
|
embemedJSX: false,
|
|
16153
16154
|
minify: false,
|
|
16155
|
+
platform: "node",
|
|
16154
16156
|
useExport: true,
|
|
16155
16157
|
logger
|
|
16156
16158
|
}));
|
|
@@ -16494,7 +16496,7 @@ async function inflateDBConfig(logger, service, dbConfigList, inflateDir, errors
|
|
|
16494
16496
|
}
|
|
16495
16497
|
if (config) {
|
|
16496
16498
|
if (inflateDir) {
|
|
16497
|
-
const inflatePath = (0, import_node_path28.resolve)(inflateDir, service, "db.
|
|
16499
|
+
const inflatePath = (0, import_node_path28.resolve)(inflateDir, service, "db.cjs");
|
|
16498
16500
|
(0, import_node_fs25.mkdirSync)((0, import_node_path28.dirname)(inflatePath), {
|
|
16499
16501
|
recursive: true
|
|
16500
16502
|
});
|
|
@@ -16503,6 +16505,7 @@ async function inflateDBConfig(logger, service, dbConfigList, inflateDir, errors
|
|
|
16503
16505
|
embemedJSX: false,
|
|
16504
16506
|
minify: false,
|
|
16505
16507
|
useExport: true,
|
|
16508
|
+
platform: "node",
|
|
16506
16509
|
logger
|
|
16507
16510
|
}));
|
|
16508
16511
|
}
|
|
@@ -16538,7 +16541,7 @@ async function inflateDBMigrations(logger, service, dbName, inflateDir, errors)
|
|
|
16538
16541
|
...migrationModule
|
|
16539
16542
|
});
|
|
16540
16543
|
if (inflateDir) {
|
|
16541
|
-
const inflatePath = (0, import_node_path28.resolve)(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - (0, import_node_path28.extname)(migrationName).length) + ".
|
|
16544
|
+
const inflatePath = (0, import_node_path28.resolve)(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - (0, import_node_path28.extname)(migrationName).length) + ".cjs");
|
|
16542
16545
|
(0, import_node_fs25.mkdirSync)((0, import_node_path28.dirname)(inflatePath), {
|
|
16543
16546
|
recursive: true
|
|
16544
16547
|
});
|
|
@@ -16547,6 +16550,7 @@ async function inflateDBMigrations(logger, service, dbName, inflateDir, errors)
|
|
|
16547
16550
|
embemedJSX: false,
|
|
16548
16551
|
minify: false,
|
|
16549
16552
|
useExport: true,
|
|
16553
|
+
platform: "node",
|
|
16550
16554
|
logger
|
|
16551
16555
|
}));
|
|
16552
16556
|
}
|
|
@@ -17022,6 +17026,7 @@ var Miqro = class _Miqro {
|
|
|
17022
17026
|
services: this.options.services,
|
|
17023
17027
|
serverInterface: this.serverInterface,
|
|
17024
17028
|
//dbManager: this.dbManager,
|
|
17029
|
+
port: this.options.port,
|
|
17025
17030
|
inflateDir: options?.inflateDir,
|
|
17026
17031
|
inflateSea: options?.inflateSea ? true : false,
|
|
17027
17032
|
//inflateTests: options?.inflateTests ? true : false,
|
|
@@ -17099,15 +17104,8 @@ var Miqro = class _Miqro {
|
|
|
17099
17104
|
reloadInflatedRouter(this);
|
|
17100
17105
|
await notifiyServerConfig(this.logger, this.serverInterface, this.adminInterface, this.inflated.serverConfigMap, "load");
|
|
17101
17106
|
if (this.logger && (import_node_cluster3.default.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === "0")) {
|
|
17102
|
-
this.logger?.
|
|
17103
|
-
this.server.logPaths(
|
|
17104
|
-
debug: this.logger.debug.bind(this.logger),
|
|
17105
|
-
error: this.logger.error.bind(this.logger),
|
|
17106
|
-
info: this.logger.debug.bind(this.logger),
|
|
17107
|
-
log: this.logger.debug.bind(this.logger),
|
|
17108
|
-
trace: this.logger.trace.bind(this.logger),
|
|
17109
|
-
warn: this.logger.warn.bind(this.logger)
|
|
17110
|
-
});
|
|
17107
|
+
this.logger?.info(" ==http routes==");
|
|
17108
|
+
this.server.logPaths(this.logger);
|
|
17111
17109
|
}
|
|
17112
17110
|
this.logger?.trace("calling listen on [%s]", this.options.port);
|
|
17113
17111
|
await this.server.listen(this.options.port);
|
|
@@ -17218,15 +17216,8 @@ var Miqro = class _Miqro {
|
|
|
17218
17216
|
this.webSocketManager.replaceALLWSBuLOGSocket(this.inflated.wsConfigList);
|
|
17219
17217
|
await notifiyServerConfig(this.logger, this.serverInterface, this.adminInterface, this.inflated.serverConfigMap, "load");
|
|
17220
17218
|
if (this.logger && (import_node_cluster3.default.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === "0")) {
|
|
17221
|
-
this.logger?.
|
|
17222
|
-
this.server.logPaths(
|
|
17223
|
-
debug: this.logger.debug.bind(this.logger),
|
|
17224
|
-
error: this.logger.error.bind(this.logger),
|
|
17225
|
-
info: this.logger.debug.bind(this.logger),
|
|
17226
|
-
log: this.logger.debug.bind(this.logger),
|
|
17227
|
-
trace: this.logger.trace.bind(this.logger),
|
|
17228
|
-
warn: this.logger.warn.bind(this.logger)
|
|
17229
|
-
});
|
|
17219
|
+
this.logger?.info(" ==http routes==");
|
|
17220
|
+
this.server.logPaths(this.logger);
|
|
17230
17221
|
}
|
|
17231
17222
|
this.logger?.debug(" ==reload done==");
|
|
17232
17223
|
this.status = "started";
|
package/package.json
CHANGED
package/src/common/arguments.ts
CHANGED
|
@@ -187,13 +187,14 @@ export function parseArguments(): Arguments {
|
|
|
187
187
|
console.error(usage);
|
|
188
188
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
if (typeof cPath !== "string") {
|
|
190
|
+
if (typeof args[i + 1] !== "string") {
|
|
192
191
|
console.error("bad arguments. --config must be a string.");
|
|
193
192
|
console.error(usage);
|
|
194
193
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
194
|
+
} else {
|
|
195
|
+
const cPath = String(args[i + 1]) as any;
|
|
196
|
+
flags.miqroJSONPath = cPath;
|
|
195
197
|
}
|
|
196
|
-
flags.miqroJSONPath = cPath;
|
|
197
198
|
i++;
|
|
198
199
|
continue;
|
|
199
200
|
case "--install-tsconfig":
|
|
@@ -271,13 +272,14 @@ export function parseArguments(): Arguments {
|
|
|
271
272
|
console.error(usage);
|
|
272
273
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
273
274
|
}
|
|
274
|
-
|
|
275
|
-
if (typeof cPort !== "string") {
|
|
275
|
+
if (typeof args[i + 1] !== "string") {
|
|
276
276
|
console.error("bad arguments. --port must be a string.");
|
|
277
277
|
console.error(usage);
|
|
278
278
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
279
|
+
} else {
|
|
280
|
+
const cPort = String(args[i + 1]) as any;
|
|
281
|
+
flags.port = cPort;
|
|
279
282
|
}
|
|
280
|
-
flags.port = cPort;
|
|
281
283
|
i++;
|
|
282
284
|
continue;
|
|
283
285
|
case "--name":
|
|
@@ -286,13 +288,15 @@ export function parseArguments(): Arguments {
|
|
|
286
288
|
console.error(usage);
|
|
287
289
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
288
290
|
}
|
|
289
|
-
|
|
290
|
-
if (typeof cName !== "string") {
|
|
291
|
+
if (typeof args[i + 1] !== "string") {
|
|
291
292
|
console.error("bad arguments. --port must be a string.");
|
|
292
293
|
console.error(usage);
|
|
293
294
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
295
|
+
} else {
|
|
296
|
+
const cName = String(args[i + 1]).toUpperCase() as any;
|
|
297
|
+
flags.name = cName;
|
|
294
298
|
}
|
|
295
|
-
|
|
299
|
+
|
|
296
300
|
i++;
|
|
297
301
|
continue;
|
|
298
302
|
case "--log-file":
|
|
@@ -301,13 +305,15 @@ export function parseArguments(): Arguments {
|
|
|
301
305
|
console.error(usage);
|
|
302
306
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
303
307
|
}
|
|
304
|
-
|
|
305
|
-
if (typeof
|
|
308
|
+
|
|
309
|
+
if (typeof args[i + 1] !== "string") {
|
|
306
310
|
console.error("bad arguments. --port must be a string.");
|
|
307
311
|
console.error(usage);
|
|
308
312
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
313
|
+
} else {
|
|
314
|
+
const cLofFile = String(args[i + 1]) as any;
|
|
315
|
+
flags.logFile = cLofFile;
|
|
309
316
|
}
|
|
310
|
-
flags.logFile = cLofFile;
|
|
311
317
|
i++;
|
|
312
318
|
continue;
|
|
313
319
|
case "--browser":
|
|
@@ -316,13 +322,15 @@ export function parseArguments(): Arguments {
|
|
|
316
322
|
console.error(usage);
|
|
317
323
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
318
324
|
}
|
|
319
|
-
|
|
320
|
-
if (typeof
|
|
325
|
+
|
|
326
|
+
if (typeof args[i + 1] !== "string") {
|
|
321
327
|
console.error("bad arguments. --port must be a string.");
|
|
322
328
|
console.error(usage);
|
|
323
329
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
330
|
+
} else {
|
|
331
|
+
const cBrowser = String(args[i + 1]) as any;
|
|
332
|
+
flags.browser = cBrowser;
|
|
324
333
|
}
|
|
325
|
-
flags.browser = cBrowser;
|
|
326
334
|
i++;
|
|
327
335
|
continue;
|
|
328
336
|
case "--generate-doc":
|
|
@@ -37,24 +37,26 @@ export async function inflateSeaAssets(logger: Logger, inflateDir: string) {
|
|
|
37
37
|
writeFile(logger, resolve(inflateDir, "install-nodejs.sh"), Buffer.from(getAsset("install-nodejs.sh")));
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
export async function inflateAppForSea(logger: Logger, inflateDir: string, services: string[]) {
|
|
40
|
+
export async function inflateAppForSea(logger: Logger, inflateDir: string, services: string[], port: string) {
|
|
41
|
+
|
|
42
|
+
const PORT = port;
|
|
41
43
|
|
|
42
44
|
inflateSeaAssets(logger, inflateDir);
|
|
43
45
|
|
|
44
46
|
writeFile(logger, resolve(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
|
|
45
47
|
|
|
46
48
|
const WSLIST = services.filter(service => getWSConfigPath(resolve(cwd(), service))).map(service => {
|
|
47
|
-
return `(await import("../${service}/ws.
|
|
49
|
+
return `(await import("../${service}/ws.cjs")).default`;
|
|
48
50
|
}).join(",")
|
|
49
51
|
|
|
50
52
|
const SERVERCONFIGLIST = services.filter(service => getServerConfigPath(resolve(cwd(), service))).map(service => {
|
|
51
|
-
return `(await import("../${service}/server.
|
|
53
|
+
return `(await import("../${service}/server.cjs")).default`;
|
|
52
54
|
}).join(",\n");
|
|
53
55
|
|
|
54
56
|
const DBCONFIGLIST = services.filter(service => getDBConfigPath(resolve(cwd(), service))).map(service => {
|
|
55
57
|
return `new Promise(async (resolve, reject) => {
|
|
56
58
|
try {
|
|
57
|
-
const db = await dbManager.setupDB((await import("../${service}/db.
|
|
59
|
+
const db = await dbManager.setupDB((await import("../${service}/db.cjs")).default);
|
|
58
60
|
await (await import("./${service}/migration-up.js")).runMigrations(db);
|
|
59
61
|
resolve();
|
|
60
62
|
} catch(e) {
|
|
@@ -69,7 +71,7 @@ export async function inflateAppForSea(logger: Logger, inflateDir: string, servi
|
|
|
69
71
|
writeFile(logger, join(inflateDir, "sea", "app.cjs"), `const { createServerInterface, ServerRequestHandler, WebSocketManager, initGlobals, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
|
|
70
72
|
|
|
71
73
|
async function main() {
|
|
72
|
-
const PORT =
|
|
74
|
+
const PORT = "${PORT}";
|
|
73
75
|
const loggerProvider = new LogProvider();
|
|
74
76
|
const localCache = new LocalCache();
|
|
75
77
|
const cache = new ClusterCache();
|
|
@@ -100,6 +102,7 @@ async function main() {
|
|
|
100
102
|
|
|
101
103
|
await app.listen(PORT);
|
|
102
104
|
${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.start).map(config=>config.start(serverInterface)));` : ""}
|
|
105
|
+
loggerProvider.getLogger("server").info("listening on [%s]", PORT);
|
|
103
106
|
}
|
|
104
107
|
main().catch(e=>console.error(e));
|
|
105
108
|
`
|
|
@@ -114,16 +117,16 @@ export async function inflateServiceForSea(logger: Logger, inflateDir: string, s
|
|
|
114
117
|
export async function setupRouter() {
|
|
115
118
|
const router = new Router();
|
|
116
119
|
${getErrorConfigPath(servicePath) ? `
|
|
117
|
-
const errorConfig = (await import("../../${service}/catch.
|
|
120
|
+
const errorConfig = (await import("../../${service}/catch.cjs")).default.default;
|
|
118
121
|
if(errorConfig && errorConfig.catch) {
|
|
119
122
|
for(const m of errorConfig.catch) {
|
|
120
123
|
router.catch(m);
|
|
121
124
|
}
|
|
122
125
|
}` : ""}
|
|
123
|
-
${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.
|
|
124
|
-
${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.
|
|
126
|
+
${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.cjs")).default.default));` : ""}
|
|
127
|
+
${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.cjs")).default.default));` : ""}
|
|
125
128
|
${getMiddlewareConfigPath(servicePath) ? `
|
|
126
|
-
const middlewareConfig = (await import("../../${service}/middleware.
|
|
129
|
+
const middlewareConfig = (await import("../../${service}/middleware.cjs")).default.default;
|
|
127
130
|
if(middlewareConfig && middlewareConfig.middleware) {
|
|
128
131
|
for(const m of middlewareConfig.middleware) {
|
|
129
132
|
router.use(m);
|
|
@@ -136,8 +139,8 @@ ${Object.keys(serviceRouteFileMap)
|
|
|
136
139
|
const rPath = join(relative(cwd(), dirname(data.filePath)), basename(data.filePath));
|
|
137
140
|
if (rPath) {
|
|
138
141
|
const rPathExt = extname(rPath);
|
|
139
|
-
const apiInflatedPath = join("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".
|
|
140
|
-
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default);`;
|
|
142
|
+
const apiInflatedPath = join("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
|
|
143
|
+
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default.default);`;
|
|
141
144
|
} else {
|
|
142
145
|
return "";
|
|
143
146
|
}
|
|
@@ -160,7 +163,7 @@ export async function runMigrations(db) {
|
|
|
160
163
|
await migration.init(db);
|
|
161
164
|
${serviceMigrations.map(file => {
|
|
162
165
|
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
163
|
-
return ` await migration.up.module(db, "${
|
|
166
|
+
return ` await migration.up.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
|
|
164
167
|
}).join("\n")}
|
|
165
168
|
}`);
|
|
166
169
|
|
|
@@ -169,7 +172,7 @@ export async function runMigrations(db) {
|
|
|
169
172
|
await migration.init(db);
|
|
170
173
|
${serviceMigrations.reverse().map(file => {
|
|
171
174
|
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
172
|
-
return ` await migration.down.module(db, "${
|
|
175
|
+
return ` await migration.down.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
|
|
173
176
|
}).join("\n")}
|
|
174
177
|
}`);
|
|
175
178
|
|
package/src/inflate/inflate.ts
CHANGED
|
@@ -20,10 +20,11 @@ export interface InflateAppOptions {
|
|
|
20
20
|
//editor: boolean;
|
|
21
21
|
//inflateTests: boolean;
|
|
22
22
|
hotreload?: boolean;
|
|
23
|
+
port: string;
|
|
23
24
|
serverInterface: ServerInterface;
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
export async function inflateApp({ serverInterface, logger, hotreload, services/*, dbManager*/, inflateDir, inflateSea/*, editor, inflateTests
|
|
27
|
+
export async function inflateApp({ serverInterface, logger, hotreload, services/*, dbManager*/, inflateDir, inflateSea/*, editor, inflateTests*/, port }: InflateAppOptions): Promise<[Router, InflateError[] | null, RouteFileMap, WSConfig[]/*, ServerConfigMap*/, LogConfigMap]> {
|
|
27
28
|
logger.trace("inflateApp");
|
|
28
29
|
const errors: InflateError[] = [];
|
|
29
30
|
//const migrations: string[] = [];
|
|
@@ -90,7 +91,7 @@ export async function inflateApp({ serverInterface, logger, hotreload, services/
|
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
if (inflateDir && inflateSea) {
|
|
93
|
-
await inflateAppForSea(logger, inflateDir, services);
|
|
94
|
+
await inflateAppForSea(logger, inflateDir, services, port);
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
router.use(assertGlobalTampered);
|
|
@@ -15,7 +15,7 @@ export async function setupAUTH(logger: Logger, servicePath: string, service: st
|
|
|
15
15
|
mainRouter.use(SessionHandler(authModule));
|
|
16
16
|
|
|
17
17
|
if (inflateDir && inflateSea) {
|
|
18
|
-
const inflatePath = resolve(inflateDir, service, "auth.
|
|
18
|
+
const inflatePath = resolve(inflateDir, service, "auth.cjs");
|
|
19
19
|
mkdirSync(dirname(inflatePath), {
|
|
20
20
|
recursive: true
|
|
21
21
|
});
|
|
@@ -24,6 +24,7 @@ export async function setupAUTH(logger: Logger, servicePath: string, service: st
|
|
|
24
24
|
embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
26
|
useExport: true,
|
|
27
|
+
platform: "node",
|
|
27
28
|
logger
|
|
28
29
|
}));
|
|
29
30
|
}
|
|
@@ -15,7 +15,7 @@ export async function setupCORS(logger: Logger, servicePath: string, service: st
|
|
|
15
15
|
mainRouter.use(CORS(corsOptions));
|
|
16
16
|
|
|
17
17
|
if (inflateDir && inflateSea) {
|
|
18
|
-
const inflatePath = resolve(inflateDir, service, "cors.
|
|
18
|
+
const inflatePath = resolve(inflateDir, service, "cors.cjs");
|
|
19
19
|
mkdirSync(dirname(inflatePath), {
|
|
20
20
|
recursive: true
|
|
21
21
|
});
|
|
@@ -24,6 +24,7 @@ export async function setupCORS(logger: Logger, servicePath: string, service: st
|
|
|
24
24
|
embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
26
|
useExport: true,
|
|
27
|
+
platform: "node",
|
|
27
28
|
logger
|
|
28
29
|
}));
|
|
29
30
|
}
|
package/src/inflate/setup-db.ts
CHANGED
|
@@ -30,7 +30,7 @@ export async function inflateDBConfig(logger: Logger, service: string, dbConfigL
|
|
|
30
30
|
|
|
31
31
|
if (config) {
|
|
32
32
|
if (inflateDir) {
|
|
33
|
-
const inflatePath = resolve(inflateDir, service, "db.
|
|
33
|
+
const inflatePath = resolve(inflateDir, service, "db.cjs");
|
|
34
34
|
mkdirSync(dirname(inflatePath), {
|
|
35
35
|
recursive: true
|
|
36
36
|
});
|
|
@@ -39,6 +39,7 @@ export async function inflateDBConfig(logger: Logger, service: string, dbConfigL
|
|
|
39
39
|
embemedJSX: false,
|
|
40
40
|
minify: false,
|
|
41
41
|
useExport: true,
|
|
42
|
+
platform: "node",
|
|
42
43
|
logger
|
|
43
44
|
}));
|
|
44
45
|
}
|
|
@@ -84,7 +85,7 @@ export async function inflateDBMigrations(logger: Logger, service: string, dbNam
|
|
|
84
85
|
});
|
|
85
86
|
|
|
86
87
|
if (inflateDir) {
|
|
87
|
-
const inflatePath = resolve(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - extname(migrationName).length) + ".
|
|
88
|
+
const inflatePath = resolve(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - extname(migrationName).length) + ".cjs");
|
|
88
89
|
mkdirSync(dirname(inflatePath), {
|
|
89
90
|
recursive: true
|
|
90
91
|
});
|
|
@@ -93,6 +94,7 @@ export async function inflateDBMigrations(logger: Logger, service: string, dbNam
|
|
|
93
94
|
embemedJSX: false,
|
|
94
95
|
minify: false,
|
|
95
96
|
useExport: true,
|
|
97
|
+
platform: "node",
|
|
96
98
|
logger
|
|
97
99
|
}));
|
|
98
100
|
}
|
|
@@ -18,7 +18,7 @@ export async function setupError(logger: Logger, servicePath: string, service: s
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
if (inflateDir && inflateSea) {
|
|
21
|
-
const inflatePath = resolve(inflateDir, service, "catch.
|
|
21
|
+
const inflatePath = resolve(inflateDir, service, "catch.cjs");
|
|
22
22
|
mkdirSync(dirname(inflatePath), {
|
|
23
23
|
recursive: true
|
|
24
24
|
});
|
|
@@ -27,6 +27,7 @@ export async function setupError(logger: Logger, servicePath: string, service: s
|
|
|
27
27
|
embemedJSX: false,
|
|
28
28
|
minify: false,
|
|
29
29
|
useExport: true,
|
|
30
|
+
platform: "node",
|
|
30
31
|
logger
|
|
31
32
|
}));
|
|
32
33
|
}
|
|
@@ -195,6 +195,7 @@ async function createRouterFromDirectory(server: ServerInterface, hotreload: boo
|
|
|
195
195
|
embemedJSX: false,
|
|
196
196
|
minify: false,
|
|
197
197
|
useExport: true,
|
|
198
|
+
platform: "node",
|
|
198
199
|
logger
|
|
199
200
|
}) : "";
|
|
200
201
|
|
|
@@ -212,7 +213,7 @@ async function createRouterFromDirectory(server: ServerInterface, hotreload: boo
|
|
|
212
213
|
|
|
213
214
|
if (inflateDir && r.defaultInflatePath && inflateSea) {
|
|
214
215
|
const rPath = r.defaultInflatePath;
|
|
215
|
-
const inflatePath = join(inflateDir, service, "http", rPath + ".api.
|
|
216
|
+
const inflatePath = join(inflateDir, service, "http", rPath + ".api.cjs");
|
|
216
217
|
mkdirSync(dirname(inflatePath), {
|
|
217
218
|
recursive: true
|
|
218
219
|
});
|