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
|
@@ -111,13 +111,15 @@ export function parseArguments() {
|
|
|
111
111
|
console.error(usage);
|
|
112
112
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
113
113
|
}
|
|
114
|
-
|
|
115
|
-
if (typeof cPath !== "string") {
|
|
114
|
+
if (typeof args[i + 1] !== "string") {
|
|
116
115
|
console.error("bad arguments. --config must be a string.");
|
|
117
116
|
console.error(usage);
|
|
118
117
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
119
118
|
}
|
|
120
|
-
|
|
119
|
+
else {
|
|
120
|
+
const cPath = String(args[i + 1]);
|
|
121
|
+
flags.miqroJSONPath = cPath;
|
|
122
|
+
}
|
|
121
123
|
i++;
|
|
122
124
|
continue;
|
|
123
125
|
case "--install-tsconfig":
|
|
@@ -195,13 +197,15 @@ export function parseArguments() {
|
|
|
195
197
|
console.error(usage);
|
|
196
198
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
197
199
|
}
|
|
198
|
-
|
|
199
|
-
if (typeof cPort !== "string") {
|
|
200
|
+
if (typeof args[i + 1] !== "string") {
|
|
200
201
|
console.error("bad arguments. --port must be a string.");
|
|
201
202
|
console.error(usage);
|
|
202
203
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
203
204
|
}
|
|
204
|
-
|
|
205
|
+
else {
|
|
206
|
+
const cPort = String(args[i + 1]);
|
|
207
|
+
flags.port = cPort;
|
|
208
|
+
}
|
|
205
209
|
i++;
|
|
206
210
|
continue;
|
|
207
211
|
case "--name":
|
|
@@ -210,13 +214,15 @@ export function parseArguments() {
|
|
|
210
214
|
console.error(usage);
|
|
211
215
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
212
216
|
}
|
|
213
|
-
|
|
214
|
-
if (typeof cName !== "string") {
|
|
217
|
+
if (typeof args[i + 1] !== "string") {
|
|
215
218
|
console.error("bad arguments. --port must be a string.");
|
|
216
219
|
console.error(usage);
|
|
217
220
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
218
221
|
}
|
|
219
|
-
|
|
222
|
+
else {
|
|
223
|
+
const cName = String(args[i + 1]).toUpperCase();
|
|
224
|
+
flags.name = cName;
|
|
225
|
+
}
|
|
220
226
|
i++;
|
|
221
227
|
continue;
|
|
222
228
|
case "--log-file":
|
|
@@ -225,13 +231,15 @@ export function parseArguments() {
|
|
|
225
231
|
console.error(usage);
|
|
226
232
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
227
233
|
}
|
|
228
|
-
|
|
229
|
-
if (typeof cLofFile !== "string") {
|
|
234
|
+
if (typeof args[i + 1] !== "string") {
|
|
230
235
|
console.error("bad arguments. --port must be a string.");
|
|
231
236
|
console.error(usage);
|
|
232
237
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
233
238
|
}
|
|
234
|
-
|
|
239
|
+
else {
|
|
240
|
+
const cLofFile = String(args[i + 1]);
|
|
241
|
+
flags.logFile = cLofFile;
|
|
242
|
+
}
|
|
235
243
|
i++;
|
|
236
244
|
continue;
|
|
237
245
|
case "--browser":
|
|
@@ -240,13 +248,15 @@ export function parseArguments() {
|
|
|
240
248
|
console.error(usage);
|
|
241
249
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
242
250
|
}
|
|
243
|
-
|
|
244
|
-
if (typeof cBrowser !== "string") {
|
|
251
|
+
if (typeof args[i + 1] !== "string") {
|
|
245
252
|
console.error("bad arguments. --port must be a string.");
|
|
246
253
|
console.error(usage);
|
|
247
254
|
process.exit(EXIT_CODES.BAD_ARGUMENTS);
|
|
248
255
|
}
|
|
249
|
-
|
|
256
|
+
else {
|
|
257
|
+
const cBrowser = String(args[i + 1]);
|
|
258
|
+
flags.browser = cBrowser;
|
|
259
|
+
}
|
|
250
260
|
i++;
|
|
251
261
|
continue;
|
|
252
262
|
case "--generate-doc":
|
|
@@ -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==");
|
|
@@ -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
|