miqro 6.0.10 → 6.0.12

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/src/cluster.ts CHANGED
@@ -10,10 +10,14 @@ const __package_dirname = import.meta.url ? resolve(dirname(fileURLToPath(import
10
10
 
11
11
  //const usage = "CLUSTER_COUNT=os.cpus().length [CLUSTER_AUTO_BROADCAST=true|false] [CLUSTER_DISABLE_RESTART=true|false]";
12
12
 
13
- parseArguments();
13
+ const args = parseArguments();
14
14
 
15
- const CMD = `CLUSTER_AUTO_BROADCAST=true ${process.argv[0]} ${mainPath()} ${resolve(__package_dirname, "main.js")} ${process.argv.slice(2).join(" ")}`;
15
+ if (args.inflate || args.test || args.compile || args.installTSConfig || args.installTypes || args.migrateDown || args.migrateUp) {
16
+ await import("./main.js");
17
+ } else {
18
+ const CMD = `CLUSTER_AUTO_BROADCAST=true ${process.argv[0]} ${mainPath()} ${resolve(__package_dirname, "main.js")} ${process.argv.slice(2).join(" ")}`;
16
19
 
17
- console.log(CMD);
20
+ console.log(CMD);
18
21
 
19
- execSync(CMD, { stdio: 'inherit' });
22
+ execSync(CMD, { stdio: 'inherit' });
23
+ }
@@ -81,6 +81,7 @@ async function main() {
81
81
  localCache,
82
82
  logProvider,
83
83
  wsManager: webSocketManager,
84
+ logger: logProvider.getLogger("server"),
84
85
  dbManager,
85
86
  port: PORT
86
87
  });
@@ -91,7 +92,7 @@ async function main() {
91
92
  const app = new App({
92
93
  onUpgrade: webSocketManager.onUpgrade
93
94
  });
94
- ${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].map(config=>config.preload(serverInterface)));\n` : ""}
95
+ ${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.preload).map(config=>config.preload(serverInterface)));\n` : ""}
95
96
  app.use(ServerRequestHandler(serverInterface));
96
97
  app.use(LoggerHandler());
97
98
  ${services.map(service => {
@@ -105,11 +106,11 @@ async function main() {
105
106
  ${services.map(service => `
106
107
  app.use(await (await import("./${join(service, "api-router.js")}")).setupRouter());
107
108
  app.use(await (await import("./${join(service, "static-router.js")}")).setupRouter())`).join("\n")}
108
- ${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].map(config=>config.load(serverInterface)));\n` : ""}
109
+ ${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.load).map(config=>config.load(serverInterface)));\n` : ""}
109
110
 
110
111
 
111
112
  await app.listen(PORT);
112
- ${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].map(config=>config.start(serverInterface)));` : ""}
113
+ ${SERVERCONFIGLIST ? `\n await Promise.all([${SERVERCONFIGLIST}].filter(config=>config.start).map(config=>config.start(serverInterface)));` : ""}
113
114
  }
114
115
  main().catch(e=>console.error(e));
115
116
  `
@@ -103,7 +103,7 @@ export class ServerInterfaceImpl implements ServerInterface {
103
103
  constructor(options: ServerInterfaceImplOptions) {
104
104
  this.cache = options.cache;
105
105
  this.localCache = options.localCache;
106
- this.logger = options.logger;
106
+ this.logger = options.logger ? options.logger : options.loggerProvider ? options.loggerProvider.getLogger("server") : undefined;
107
107
  this.port = options.port;
108
108
 
109
109
  const dbManager = options.dbManager;
@@ -105,5 +105,5 @@ export interface ServerRequest extends Request {
105
105
  export interface ServerResponse extends Response {
106
106
  }
107
107
 
108
- export { App, LoggerHandler, Router } from "@miqro/core/lib.js";
109
- export { migration } from "@miqro/query/lib.js";
108
+ export { App, LoggerHandler, Router, APIRoute } from "@miqro/core/lib.js";
109
+ export { migration, Migration } from "@miqro/query/lib.js";
package/src/types.ts CHANGED
@@ -41,6 +41,9 @@ declare global {
41
41
  }
42
42
  }
43
43
 
44
+ export { APIRoute } from "@miqro/core";
45
+ export { Migration } from "@miqro/query";
46
+
44
47
  export interface ServerGlobal {
45
48
  encodeHTML: (str: string) => string;
46
49
  inflateMDtoHTML: (str: string) => string;