miqro 6.2.1 → 6.2.3
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/jsx.d.ts +1 -0
- package/build/esm/src/common/jsx.js +10 -6
- 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/hot-reload.js +4 -1
- package/build/esm/src/services/migrations.js +4 -2
- package/build/esm/src/services/utils/websocketmanager.js +1 -1
- package/build/lib.cjs +56 -59
- package/package.json +1 -1
- package/src/common/jsx.ts +11 -6
- 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/hot-reload.ts +4 -1
- package/src/services/migrations.ts +4 -2
- package/src/services/utils/websocketmanager.ts +1 -1
|
@@ -49,7 +49,8 @@ export async function inflateJSX(inFile, options) {
|
|
|
49
49
|
const { outputFiles: [{ contents }] } = await esBuild({
|
|
50
50
|
...DEFAULT_ESOPTION,
|
|
51
51
|
entryPoints: [inFileTmp],
|
|
52
|
-
minify: options.minify
|
|
52
|
+
minify: options.minify,
|
|
53
|
+
platform: options.platform ? options.platform : DEFAULT_ESOPTION.platform
|
|
53
54
|
});
|
|
54
55
|
if (CLEAR_JSX_CACHE) {
|
|
55
56
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
@@ -69,7 +70,8 @@ export async function inflateJSX(inFile, options) {
|
|
|
69
70
|
const { outputFiles: [{ contents }] } = await esBuild({
|
|
70
71
|
...DEFAULT_ESOPTION,
|
|
71
72
|
entryPoints: [inFileTmp],
|
|
72
|
-
minify: options.minify
|
|
73
|
+
minify: options.minify,
|
|
74
|
+
platform: options.platform ? options.platform : DEFAULT_ESOPTION.platform
|
|
73
75
|
});
|
|
74
76
|
if (CLEAR_JSX_CACHE) {
|
|
75
77
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
@@ -397,10 +399,12 @@ export async function importJSXFile(inFile, logger) {
|
|
|
397
399
|
embemedJSX: false,
|
|
398
400
|
minify: false,
|
|
399
401
|
useExport: true,
|
|
402
|
+
platform: "node",
|
|
400
403
|
logger
|
|
401
404
|
});
|
|
402
405
|
const tmpBuildDir = resolve(JSX_TMP_DIR, String(process.pid), "import", Date.now() + "-" + randomUUID());
|
|
403
|
-
const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
406
|
+
//const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
|
|
407
|
+
const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".cjs");
|
|
404
408
|
//const logger = getLogger(`${SERVER_IDENTIFIER}_JSX`);
|
|
405
409
|
mkdirSync(tmpBuildDir, {
|
|
406
410
|
recursive: true
|
|
@@ -410,18 +414,18 @@ export async function importJSXFile(inFile, logger) {
|
|
|
410
414
|
assertGlobalTampered();
|
|
411
415
|
logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
|
|
412
416
|
logger?.debug("importing [%s]", relative(cwd(), inFile));
|
|
413
|
-
const module = await import(inFileTmp);
|
|
417
|
+
const module = await import(resolve(inFileTmp));
|
|
414
418
|
assertGlobalTampered();
|
|
415
419
|
if (CLEAR_JSX_CACHE) {
|
|
416
420
|
logger?.trace("clearing cache at [%s]. to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
417
421
|
unlinkSync(inFileTmp);
|
|
418
422
|
rmdirSync(tmpBuildDir);
|
|
419
423
|
}
|
|
420
|
-
return module;
|
|
424
|
+
return module.default;
|
|
421
425
|
}
|
|
422
426
|
catch (e) {
|
|
423
427
|
logger?.error(e);
|
|
424
|
-
logger?.error("error
|
|
428
|
+
logger?.error("error with2: " + inFile);
|
|
425
429
|
if (CLEAR_JSX_CACHE) {
|
|
426
430
|
logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
|
|
427
431
|
unlinkSync(inFileTmp);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from "@miqro/core";
|
|
2
2
|
import { RouteFileMap, StaticFileMap } from "./setup-http.js";
|
|
3
3
|
export declare function inflateSeaAssets(logger: Logger, inflateDir: string): Promise<void>;
|
|
4
|
-
export declare function inflateAppForSea(logger: Logger, inflateDir: string, services: string[]): Promise<void>;
|
|
4
|
+
export declare function inflateAppForSea(logger: Logger, inflateDir: string, services: string[], port: string): Promise<void>;
|
|
5
5
|
export declare function inflateServiceForSea(logger: Logger, inflateDir: string, service: string, servicePath: string, serviceRouteFileMap: RouteFileMap, serviceStaticFileMap: StaticFileMap): Promise<void>;
|
|
@@ -32,19 +32,20 @@ export async function inflateSeaAssets(logger, inflateDir) {
|
|
|
32
32
|
writeFile(logger, resolve(inflateDir, "sea", "sign-remove.sh"), Buffer.from(getAsset("sign-remove.sh")));
|
|
33
33
|
writeFile(logger, resolve(inflateDir, "install-nodejs.sh"), Buffer.from(getAsset("install-nodejs.sh")));
|
|
34
34
|
}
|
|
35
|
-
export async function inflateAppForSea(logger, inflateDir, services) {
|
|
35
|
+
export async function inflateAppForSea(logger, inflateDir, services, port) {
|
|
36
|
+
const PORT = port;
|
|
36
37
|
inflateSeaAssets(logger, inflateDir);
|
|
37
38
|
writeFile(logger, resolve(inflateDir, "sea", "lib.cjs"), Buffer.from(getAsset("lib.cjs")));
|
|
38
39
|
const WSLIST = services.filter(service => getWSConfigPath(resolve(cwd(), service))).map(service => {
|
|
39
|
-
return `(await import("../${service}/ws.
|
|
40
|
+
return `(await import("../${service}/ws.cjs")).default`;
|
|
40
41
|
}).join(",");
|
|
41
42
|
const SERVERCONFIGLIST = services.filter(service => getServerConfigPath(resolve(cwd(), service))).map(service => {
|
|
42
|
-
return `(await import("../${service}/server.
|
|
43
|
+
return `(await import("../${service}/server.cjs")).default`;
|
|
43
44
|
}).join(",\n");
|
|
44
45
|
const DBCONFIGLIST = services.filter(service => getDBConfigPath(resolve(cwd(), service))).map(service => {
|
|
45
46
|
return `new Promise(async (resolve, reject) => {
|
|
46
47
|
try {
|
|
47
|
-
const db = await dbManager.setupDB((await import("../${service}/db.
|
|
48
|
+
const db = await dbManager.setupDB((await import("../${service}/db.cjs")).default);
|
|
48
49
|
await (await import("./${service}/migration-up.js")).runMigrations(db);
|
|
49
50
|
resolve();
|
|
50
51
|
} catch(e) {
|
|
@@ -57,7 +58,7 @@ export async function inflateAppForSea(logger, inflateDir, services) {
|
|
|
57
58
|
writeFile(logger, join(inflateDir, "sea", "app.cjs"), `const { createServerInterface, ServerRequestHandler, WebSocketManager, initGlobals, DBManager, App, LoggerHandler, LogProvider, LocalCache, ClusterCache } = require("./lib.cjs");
|
|
58
59
|
|
|
59
60
|
async function main() {
|
|
60
|
-
const PORT =
|
|
61
|
+
const PORT = "${PORT}";
|
|
61
62
|
const loggerProvider = new LogProvider();
|
|
62
63
|
const localCache = new LocalCache();
|
|
63
64
|
const cache = new ClusterCache();
|
|
@@ -88,6 +89,7 @@ async function main() {
|
|
|
88
89
|
|
|
89
90
|
await app.listen(PORT);
|
|
90
91
|
${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.start).map(config=>config.start(serverInterface)));` : ""}
|
|
92
|
+
loggerProvider.getLogger("server").info("listening on [%s]", PORT);
|
|
91
93
|
}
|
|
92
94
|
main().catch(e=>console.error(e));
|
|
93
95
|
`);
|
|
@@ -99,16 +101,16 @@ export async function inflateServiceForSea(logger, inflateDir, service, serviceP
|
|
|
99
101
|
export async function setupRouter() {
|
|
100
102
|
const router = new Router();
|
|
101
103
|
${getErrorConfigPath(servicePath) ? `
|
|
102
|
-
const errorConfig = (await import("../../${service}/catch.
|
|
104
|
+
const errorConfig = (await import("../../${service}/catch.cjs")).default.default;
|
|
103
105
|
if(errorConfig && errorConfig.catch) {
|
|
104
106
|
for(const m of errorConfig.catch) {
|
|
105
107
|
router.catch(m);
|
|
106
108
|
}
|
|
107
109
|
}` : ""}
|
|
108
|
-
${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.
|
|
109
|
-
${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.
|
|
110
|
+
${getCORSConfigPath(servicePath) ? ` router.use(server.middleware.cors((await import("../../${service}/cors.cjs")).default.default));` : ""}
|
|
111
|
+
${getAuthConfigPath(servicePath) ? ` router.use(server.middleware.session((await import("../../${service}/auth.cjs")).default.default));` : ""}
|
|
110
112
|
${getMiddlewareConfigPath(servicePath) ? `
|
|
111
|
-
const middlewareConfig = (await import("../../${service}/middleware.
|
|
113
|
+
const middlewareConfig = (await import("../../${service}/middleware.cjs")).default.default;
|
|
112
114
|
if(middlewareConfig && middlewareConfig.middleware) {
|
|
113
115
|
for(const m of middlewareConfig.middleware) {
|
|
114
116
|
router.use(m);
|
|
@@ -121,8 +123,8 @@ ${Object.keys(serviceRouteFileMap)
|
|
|
121
123
|
const rPath = join(relative(cwd(), dirname(data.filePath)), basename(data.filePath));
|
|
122
124
|
if (rPath) {
|
|
123
125
|
const rPathExt = extname(rPath);
|
|
124
|
-
const apiInflatedPath = join("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".
|
|
125
|
-
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default);`;
|
|
126
|
+
const apiInflatedPath = join("..", "..", rPath.substring(0, rPath.length - rPathExt.length) + ".cjs");
|
|
127
|
+
return ` await appendAPIModule(router, "../../${service}/http", "./${apiInflatedPath}", (await import("./${apiInflatedPath}")).default.default);`;
|
|
126
128
|
}
|
|
127
129
|
else {
|
|
128
130
|
return "";
|
|
@@ -145,7 +147,7 @@ export async function runMigrations(db) {
|
|
|
145
147
|
await migration.init(db);
|
|
146
148
|
${serviceMigrations.map(file => {
|
|
147
149
|
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
148
|
-
return ` await migration.up.module(db, "${
|
|
150
|
+
return ` await migration.up.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
|
|
149
151
|
}).join("\n")}
|
|
150
152
|
}`);
|
|
151
153
|
writeFile(logger, join(inflateDir, "sea", service, "migration-down.js"), `import { migration } from "./../lib.cjs";\n
|
|
@@ -153,7 +155,7 @@ export async function runMigrations(db) {
|
|
|
153
155
|
await migration.init(db);
|
|
154
156
|
${serviceMigrations.reverse().map(file => {
|
|
155
157
|
const name = `${file.substring(0, file.length - extname(file).length)}`;
|
|
156
|
-
return ` await migration.down.module(db, "${
|
|
158
|
+
return ` await migration.down.module(db, "${file}", (await import("../../${service}/migration/${name}.cjs")).default.default)`;
|
|
157
159
|
}).join("\n")}
|
|
158
160
|
}`);
|
|
159
161
|
const staticFiles = Object.keys(serviceStaticFileMap);
|
|
@@ -9,6 +9,7 @@ export interface InflateAppOptions {
|
|
|
9
9
|
inflateDir: string | undefined | false;
|
|
10
10
|
inflateSea: boolean;
|
|
11
11
|
hotreload?: boolean;
|
|
12
|
+
port: string;
|
|
12
13
|
serverInterface: ServerInterface;
|
|
13
14
|
}
|
|
14
|
-
export declare function inflateApp({ serverInterface, logger, hotreload, services, inflateDir, inflateSea }: InflateAppOptions): Promise<[Router, InflateError[] | null, RouteFileMap, WSConfig[], LogConfigMap]>;
|
|
15
|
+
export declare function inflateApp({ serverInterface, logger, hotreload, services, inflateDir, inflateSea, port }: InflateAppOptions): Promise<[Router, InflateError[] | null, RouteFileMap, WSConfig[], LogConfigMap]>;
|
|
@@ -8,7 +8,7 @@ import { inflateWSConfig } from "./setup-ws.js";
|
|
|
8
8
|
import { inflateAppForSea, inflateServiceForSea } from "./inflate-sea.js";
|
|
9
9
|
import { setupLogConfig } from "./setup-log.js";
|
|
10
10
|
import { setupDoc } from "./setup.doc.js";
|
|
11
|
-
export async function inflateApp({ serverInterface, logger, hotreload, services /*, dbManager*/, inflateDir, inflateSea /*, editor, inflateTests
|
|
11
|
+
export async function inflateApp({ serverInterface, logger, hotreload, services /*, dbManager*/, inflateDir, inflateSea /*, editor, inflateTests*/, port }) {
|
|
12
12
|
logger.trace("inflateApp");
|
|
13
13
|
const errors = [];
|
|
14
14
|
//const migrations: string[] = [];
|
|
@@ -59,7 +59,7 @@ export async function inflateApp({ serverInterface, logger, hotreload, services
|
|
|
59
59
|
}*/
|
|
60
60
|
}
|
|
61
61
|
if (inflateDir && inflateSea) {
|
|
62
|
-
await inflateAppForSea(logger, inflateDir, services);
|
|
62
|
+
await inflateAppForSea(logger, inflateDir, services, port);
|
|
63
63
|
}
|
|
64
64
|
router.use(assertGlobalTampered);
|
|
65
65
|
return errors.length === 0 ? [router, null, routeFileMap /*, migrations*/, wsConfigList /*, serverConfigMap*/, logConfigMap] : [router, errors, routeFileMap /*, migrations*/, wsConfigList /*, serverConfigMap*/, logConfigMap];
|
|
@@ -12,7 +12,7 @@ export async function setupAUTH(logger, servicePath, service, mainRouter, inflat
|
|
|
12
12
|
logger.debug("setting up authentication from [%s]", join(service, basename(authPath)));
|
|
13
13
|
mainRouter.use(SessionHandler(authModule));
|
|
14
14
|
if (inflateDir && inflateSea) {
|
|
15
|
-
const inflatePath = resolve(inflateDir, service, "auth.
|
|
15
|
+
const inflatePath = resolve(inflateDir, service, "auth.cjs");
|
|
16
16
|
mkdirSync(dirname(inflatePath), {
|
|
17
17
|
recursive: true
|
|
18
18
|
});
|
|
@@ -21,6 +21,7 @@ export async function setupAUTH(logger, servicePath, service, mainRouter, inflat
|
|
|
21
21
|
embemedJSX: false,
|
|
22
22
|
minify: false,
|
|
23
23
|
useExport: true,
|
|
24
|
+
platform: "node",
|
|
24
25
|
logger
|
|
25
26
|
}));
|
|
26
27
|
}
|
|
@@ -12,7 +12,7 @@ export async function setupCORS(logger, servicePath, service, mainRouter, inflat
|
|
|
12
12
|
logger.debug("setting up cors from [%s]", join(service, basename(corsPath)));
|
|
13
13
|
mainRouter.use(CORS(corsOptions));
|
|
14
14
|
if (inflateDir && inflateSea) {
|
|
15
|
-
const inflatePath = resolve(inflateDir, service, "cors.
|
|
15
|
+
const inflatePath = resolve(inflateDir, service, "cors.cjs");
|
|
16
16
|
mkdirSync(dirname(inflatePath), {
|
|
17
17
|
recursive: true
|
|
18
18
|
});
|
|
@@ -21,6 +21,7 @@ export async function setupCORS(logger, servicePath, service, mainRouter, inflat
|
|
|
21
21
|
embemedJSX: false,
|
|
22
22
|
minify: false,
|
|
23
23
|
useExport: true,
|
|
24
|
+
platform: "node",
|
|
24
25
|
logger
|
|
25
26
|
}));
|
|
26
27
|
}
|
|
@@ -22,7 +22,7 @@ export async function inflateDBConfig(logger, service, dbConfigList, inflateDir,
|
|
|
22
22
|
}
|
|
23
23
|
if (config) {
|
|
24
24
|
if (inflateDir) {
|
|
25
|
-
const inflatePath = resolve(inflateDir, service, "db.
|
|
25
|
+
const inflatePath = resolve(inflateDir, service, "db.cjs");
|
|
26
26
|
mkdirSync(dirname(inflatePath), {
|
|
27
27
|
recursive: true
|
|
28
28
|
});
|
|
@@ -31,6 +31,7 @@ export async function inflateDBConfig(logger, service, dbConfigList, inflateDir,
|
|
|
31
31
|
embemedJSX: false,
|
|
32
32
|
minify: false,
|
|
33
33
|
useExport: true,
|
|
34
|
+
platform: "node",
|
|
34
35
|
logger
|
|
35
36
|
}));
|
|
36
37
|
}
|
|
@@ -69,7 +70,7 @@ export async function inflateDBMigrations(logger, service, dbName, inflateDir, e
|
|
|
69
70
|
...migrationModule
|
|
70
71
|
});
|
|
71
72
|
if (inflateDir) {
|
|
72
|
-
const inflatePath = resolve(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - extname(migrationName).length) + ".
|
|
73
|
+
const inflatePath = resolve(inflateDir, service, "migration", migrationName.substring(0, migrationName.length - extname(migrationName).length) + ".cjs");
|
|
73
74
|
mkdirSync(dirname(inflatePath), {
|
|
74
75
|
recursive: true
|
|
75
76
|
});
|
|
@@ -78,6 +79,7 @@ export async function inflateDBMigrations(logger, service, dbName, inflateDir, e
|
|
|
78
79
|
embemedJSX: false,
|
|
79
80
|
minify: false,
|
|
80
81
|
useExport: true,
|
|
82
|
+
platform: "node",
|
|
81
83
|
logger
|
|
82
84
|
}));
|
|
83
85
|
}
|
|
@@ -15,7 +15,7 @@ export async function setupError(logger, servicePath, service, mainRouter, infla
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
if (inflateDir && inflateSea) {
|
|
18
|
-
const inflatePath = resolve(inflateDir, service, "catch.
|
|
18
|
+
const inflatePath = resolve(inflateDir, service, "catch.cjs");
|
|
19
19
|
mkdirSync(dirname(inflatePath), {
|
|
20
20
|
recursive: true
|
|
21
21
|
});
|
|
@@ -24,6 +24,7 @@ export async function setupError(logger, servicePath, service, mainRouter, infla
|
|
|
24
24
|
embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
26
|
useExport: true,
|
|
27
|
+
platform: "node",
|
|
27
28
|
logger
|
|
28
29
|
}));
|
|
29
30
|
}
|
|
@@ -145,6 +145,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
145
145
|
embemedJSX: false,
|
|
146
146
|
minify: false,
|
|
147
147
|
useExport: true,
|
|
148
|
+
platform: "node",
|
|
148
149
|
logger
|
|
149
150
|
}) : "";
|
|
150
151
|
for (const r of routes) {
|
|
@@ -159,7 +160,7 @@ async function createRouterFromDirectory(server, hotreload, service, logger, dir
|
|
|
159
160
|
}*/
|
|
160
161
|
if (inflateDir && r.defaultInflatePath && inflateSea) {
|
|
161
162
|
const rPath = r.defaultInflatePath;
|
|
162
|
-
const inflatePath = join(inflateDir, service, "http", rPath + ".api.
|
|
163
|
+
const inflatePath = join(inflateDir, service, "http", rPath + ".api.cjs");
|
|
163
164
|
mkdirSync(dirname(inflatePath), {
|
|
164
165
|
recursive: true
|
|
165
166
|
});
|
|
@@ -11,7 +11,7 @@ export async function setupLogConfig(logger, servicePath, service, logConfigMap,
|
|
|
11
11
|
const logConfig = await importLogConfigModule(logPath, logger);
|
|
12
12
|
logConfigMap[service] = logConfig;
|
|
13
13
|
if (inflateDir) {
|
|
14
|
-
const inflatePath = resolve(inflateDir, service, "log.
|
|
14
|
+
const inflatePath = resolve(inflateDir, service, "log.cjs");
|
|
15
15
|
mkdirSync(dirname(inflatePath), {
|
|
16
16
|
recursive: true
|
|
17
17
|
});
|
|
@@ -20,6 +20,7 @@ export async function setupLogConfig(logger, servicePath, service, logConfigMap,
|
|
|
20
20
|
embemedJSX: false,
|
|
21
21
|
minify: false,
|
|
22
22
|
useExport: true,
|
|
23
|
+
platform: "node",
|
|
23
24
|
logger
|
|
24
25
|
}));
|
|
25
26
|
}
|
|
@@ -15,7 +15,7 @@ export async function setupMiddleware(logger, servicePath, service, mainRouter,
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
if (inflateDir && inflateSea) {
|
|
18
|
-
const inflatePath = resolve(inflateDir, service, "middleware.
|
|
18
|
+
const inflatePath = resolve(inflateDir, service, "middleware.cjs");
|
|
19
19
|
mkdirSync(dirname(inflatePath), {
|
|
20
20
|
recursive: true
|
|
21
21
|
});
|
|
@@ -23,6 +23,7 @@ export async function setupMiddleware(logger, servicePath, service, mainRouter,
|
|
|
23
23
|
writeFileSync(inflatePath, await inflateJSX(middlewarePath, {
|
|
24
24
|
embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
|
+
platform: "node",
|
|
26
27
|
useExport: true,
|
|
27
28
|
logger
|
|
28
29
|
}));
|
|
@@ -11,7 +11,7 @@ export async function setupServerConfig(logger, servicePath, service, serverConf
|
|
|
11
11
|
const serverConfig = await importServerConfigModule(serverPath, logger);
|
|
12
12
|
serverConfigMap[service] = serverConfig;
|
|
13
13
|
if (inflateDir) {
|
|
14
|
-
const inflatePath = resolve(inflateDir, service, "server.
|
|
14
|
+
const inflatePath = resolve(inflateDir, service, "server.cjs");
|
|
15
15
|
mkdirSync(dirname(inflatePath), {
|
|
16
16
|
recursive: true
|
|
17
17
|
});
|
|
@@ -19,6 +19,7 @@ export async function setupServerConfig(logger, servicePath, service, serverConf
|
|
|
19
19
|
writeFileSync(inflatePath, await inflateJSX(serverPath, {
|
|
20
20
|
embemedJSX: false,
|
|
21
21
|
minify: false,
|
|
22
|
+
platform: "node",
|
|
22
23
|
useExport: true,
|
|
23
24
|
logger
|
|
24
25
|
}));
|
|
@@ -18,7 +18,7 @@ export async function inflateWSConfig(logger, servicePath, service, wsConfigList
|
|
|
18
18
|
//wsMap[wsConfig.path] = { name: service, options: wsConfig };
|
|
19
19
|
}
|
|
20
20
|
if (inflateDir) {
|
|
21
|
-
const inflatePath = resolve(inflateDir, service, "ws.
|
|
21
|
+
const inflatePath = resolve(inflateDir, service, "ws.cjs");
|
|
22
22
|
mkdirSync(dirname(inflatePath), {
|
|
23
23
|
recursive: true
|
|
24
24
|
});
|
|
@@ -26,6 +26,7 @@ export async function inflateWSConfig(logger, servicePath, service, wsConfigList
|
|
|
26
26
|
writeFileSync(inflatePath, await inflateJSX(wsPath, {
|
|
27
27
|
embemedJSX: false,
|
|
28
28
|
minify: false,
|
|
29
|
+
platform: "node",
|
|
29
30
|
useExport: true,
|
|
30
31
|
logger
|
|
31
32
|
}));
|
|
@@ -286,6 +286,7 @@ export class Miqro {
|
|
|
286
286
|
services: this.options.services,
|
|
287
287
|
serverInterface: this.serverInterface,
|
|
288
288
|
//dbManager: this.dbManager,
|
|
289
|
+
port: this.options.port,
|
|
289
290
|
inflateDir: options?.inflateDir,
|
|
290
291
|
inflateSea: options?.inflateSea ? true : false,
|
|
291
292
|
//inflateTests: options?.inflateTests ? true : false,
|
|
@@ -367,15 +368,17 @@ export class Miqro {
|
|
|
367
368
|
reloadInflatedRouter(this);
|
|
368
369
|
await notifiyServerConfig(this.logger, this.serverInterface, this.adminInterface, this.inflated.serverConfigMap, "load");
|
|
369
370
|
if (this.logger && (cluster.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === "0")) {
|
|
370
|
-
this.logger?.debug("\t\t==http routes==");
|
|
371
|
+
/*this.logger?.debug("\t\t==http routes==");
|
|
371
372
|
this.server.logPaths({
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
})
|
|
373
|
+
debug: this.logger.debug.bind(this.logger),
|
|
374
|
+
error: this.logger.error.bind(this.logger),
|
|
375
|
+
info: this.logger.debug.bind(this.logger),
|
|
376
|
+
log: this.logger.debug.bind(this.logger),
|
|
377
|
+
trace: this.logger.trace.bind(this.logger),
|
|
378
|
+
warn: this.logger.warn.bind(this.logger)
|
|
379
|
+
});*/
|
|
380
|
+
this.logger?.info("\t\t==http routes==");
|
|
381
|
+
this.server.logPaths(this.logger);
|
|
379
382
|
}
|
|
380
383
|
this.logger?.trace("calling listen on [%s]", this.options.port);
|
|
381
384
|
await this.server.listen(this.options.port);
|
|
@@ -496,15 +499,16 @@ export class Miqro {
|
|
|
496
499
|
this.webSocketManager.replaceALLWSBuLOGSocket(this.inflated.wsConfigList);
|
|
497
500
|
await notifiyServerConfig(this.logger, this.serverInterface, this.adminInterface, this.inflated.serverConfigMap, "load");
|
|
498
501
|
if (this.logger && (cluster.isPrimary || process.env["CLUSTER_NODE_NUMBER"] === "0")) {
|
|
499
|
-
this.logger?.
|
|
500
|
-
this.server.logPaths(
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
502
|
+
this.logger?.info("\t\t==http routes==");
|
|
503
|
+
this.server.logPaths(this.logger);
|
|
504
|
+
/*this.server.logPaths({
|
|
505
|
+
debug: this.logger.debug.bind(this.logger),
|
|
506
|
+
error: this.logger.error.bind(this.logger),
|
|
507
|
+
info: this.logger.debug.bind(this.logger),
|
|
508
|
+
log: this.logger.debug.bind(this.logger),
|
|
509
|
+
trace: this.logger.trace.bind(this.logger),
|
|
510
|
+
warn: this.logger.warn.bind(this.logger)
|
|
511
|
+
});*/
|
|
508
512
|
}
|
|
509
513
|
//this.logger?.log("=====================");
|
|
510
514
|
this.logger?.debug("\t\t==reload done==");
|
|
@@ -17,7 +17,10 @@ function tryConnection() {
|
|
|
17
17
|
const newSocket = getSocket();
|
|
18
18
|
newSocket.addEventListener("open", (event) => {
|
|
19
19
|
console.log("reloading");
|
|
20
|
-
|
|
20
|
+
setTimeout(()=>{
|
|
21
|
+
window.location.reload();
|
|
22
|
+
}, 500);
|
|
23
|
+
|
|
21
24
|
});
|
|
22
25
|
newSocket.addEventListener("error", (err) => {
|
|
23
26
|
console.error(err);
|
|
@@ -15,7 +15,7 @@ export async function runMigrations(logger, db, servicePath, service, inflateDir
|
|
|
15
15
|
migrations.push(...serviceMigrations);
|
|
16
16
|
if (inflateDir) {
|
|
17
17
|
for (const migration of serviceMigrations) {
|
|
18
|
-
const inflatePath = resolve(inflateDir, service, "migration", migration.substring(0, migration.length - extname(migration).length) + ".
|
|
18
|
+
const inflatePath = resolve(inflateDir, service, "migration", migration.substring(0, migration.length - extname(migration).length) + ".cjs");
|
|
19
19
|
mkdirSync(dirname(inflatePath), {
|
|
20
20
|
recursive: true
|
|
21
21
|
});
|
|
@@ -24,6 +24,7 @@ export async function runMigrations(logger, db, servicePath, service, inflateDir
|
|
|
24
24
|
embemedJSX: false,
|
|
25
25
|
minify: false,
|
|
26
26
|
useExport: true,
|
|
27
|
+
platform: "node",
|
|
27
28
|
logger
|
|
28
29
|
}));
|
|
29
30
|
}
|
|
@@ -42,13 +43,14 @@ export async function runMigrationsDown(logger, db, servicePath, service, inflat
|
|
|
42
43
|
migrations.push(...serviceMigrations);
|
|
43
44
|
if (inflateDir) {
|
|
44
45
|
for (const migration of serviceMigrations) {
|
|
45
|
-
const inflatePath = resolve(inflateDir, service, "migration", migration.substring(0, migration.length - extname(migration).length) + ".
|
|
46
|
+
const inflatePath = resolve(inflateDir, service, "migration", migration.substring(0, migration.length - extname(migration).length) + ".cjs");
|
|
46
47
|
mkdirSync(dirname(inflatePath), {
|
|
47
48
|
recursive: true
|
|
48
49
|
});
|
|
49
50
|
logger?.log("writing [%s]", relative(cwd(), inflatePath));
|
|
50
51
|
writeFileSync(inflatePath, await inflateJSX(resolve(migrationsFolderPath, migration), {
|
|
51
52
|
embemedJSX: false,
|
|
53
|
+
platform: "node",
|
|
52
54
|
minify: false,
|
|
53
55
|
useExport: true,
|
|
54
56
|
logger
|
|
@@ -10,7 +10,7 @@ export class WebSocketManager {
|
|
|
10
10
|
this.onUpgrade = this.onUpgrade.bind(this);
|
|
11
11
|
this.logger = options && options.logger ? options.logger : null;
|
|
12
12
|
this.name = options && options.name ? options.name : "WebSocketManager";
|
|
13
|
-
this.loggerProvider = options.loggerProvider;
|
|
13
|
+
this.loggerProvider = options && options.loggerProvider;
|
|
14
14
|
this.avoidLogSocket = options && options.avoidLogSocket ? options.avoidLogSocket : false;
|
|
15
15
|
}
|
|
16
16
|
deleteWS(path) {
|