miqro 6.2.12 → 6.3.0

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.
@@ -10,6 +10,7 @@ interface MiqroJSON {
10
10
  https?: boolean;
11
11
  serverOptions?: ServerOptions;
12
12
  httpsRedirect?: number;
13
+ inflateParallel?: number;
13
14
  }
14
15
  export declare function importMiqroJSON(inFile: string): MiqroJSON;
15
16
  export declare function getPORT(): string;
@@ -37,9 +38,11 @@ export interface Arguments {
37
38
  services: string[];
38
39
  editor: boolean;
39
40
  hotreload: boolean;
41
+ watch: boolean;
40
42
  https: boolean;
41
43
  serverOptions: ServerOptions;
42
44
  httpsRedirect?: number;
45
+ inflateParallel?: number;
43
46
  }
44
47
  /**
45
48
  * parse process.argv arguments
@@ -24,7 +24,8 @@ const MiqroJSONSchema = {
24
24
  editor: "boolean?",
25
25
  https: "boolean?",
26
26
  serverOptions: "any?",
27
- httpsRedirect: "number?"
27
+ httpsRedirect: "number?",
28
+ inflateParallel: "number?"
28
29
  }
29
30
  };
30
31
  export function importMiqroJSON(inFile) {
@@ -47,6 +48,7 @@ export function parseArguments() {
47
48
  //env["LOG_FILE"] = env["LOG_FILE"] ? env["LOG_FILE"] : "./server.log";
48
49
  const args = cluster.isPrimary ? process.argv.slice(2, process.argv.length) : process.argv.slice(3, process.argv.length);
49
50
  const flags = {
51
+ inflateParallel: null,
50
52
  httpsRedirect: null,
51
53
  https: null,
52
54
  serverOptions: {},
@@ -54,6 +56,7 @@ export function parseArguments() {
54
56
  browser: null,
55
57
  logFile: null,
56
58
  hotreload: null,
59
+ watch: null,
57
60
  miqroJSONPath: null,
58
61
  installMiqroJSON: null,
59
62
  disableMiqroJSON: null,
@@ -131,6 +134,14 @@ export function parseArguments() {
131
134
  flags.installTSConfig = true;
132
135
  continue;
133
136
  case "--watch":
137
+ if (flags.watch !== null) {
138
+ console.error("bad arguments.");
139
+ console.error(usage);
140
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
141
+ }
142
+ flags.watch = true;
143
+ continue;
144
+ case "--hot-reload":
134
145
  if (flags.hotreload !== null) {
135
146
  console.error("bad arguments.");
136
147
  console.error(usage);
@@ -392,6 +403,28 @@ export function parseArguments() {
392
403
  services.push(args[i + 1]);
393
404
  i++;
394
405
  continue;
406
+ case "--inflate-parallel":
407
+ if (args[i + 1] === undefined) {
408
+ console.error("bad arguments. service directory not provided.");
409
+ console.error(usage);
410
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
411
+ }
412
+ if (typeof args[i + 1] !== "string") {
413
+ console.error("bad arguments. --inflate-parallel must be a number.");
414
+ console.error(usage);
415
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
416
+ }
417
+ else {
418
+ const cParallel = parseInt(String(args[i + 1]), 10);
419
+ if (isNaN(cParallel)) {
420
+ console.error("bad arguments. --inflate-parallel must be a number.");
421
+ console.error(usage);
422
+ process.exit(EXIT_CODES.BAD_ARGUMENTS);
423
+ }
424
+ flags.inflateParallel = cParallel;
425
+ }
426
+ i++;
427
+ continue;
395
428
  case "--inflate-dir":
396
429
  if (flags.inflateDir !== null && flags.compile === null) {
397
430
  console.error("bad arguments. --inflate-dir already set.");
@@ -491,6 +524,11 @@ export function parseArguments() {
491
524
  flags.editor = miqroRC.editor;
492
525
  }
493
526
  }
527
+ if (flags.inflateParallel === null) {
528
+ if (miqroRC.inflateParallel !== undefined) {
529
+ flags.inflateParallel = miqroRC.inflateParallel;
530
+ }
531
+ }
494
532
  }
495
533
  flags.editor = flags.editor ? flags.editor : false;
496
534
  if (services.length === 0 && (!flags.installTSConfig && !flags.installTypes && !flags.installMiqroJSON)) {
@@ -535,19 +573,19 @@ export function parseArguments() {
535
573
  console.error("bad arguments. cannot use --editor with--install-types, --install-tsconfig or --install-miqrojson");
536
574
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
537
575
  }
538
- if (flags.test && (flags.hotreload || flags.editor || flags.compile || flags.inflate)) {
576
+ if (flags.test && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.inflate)) {
539
577
  console.error("bad arguments. cannot use --editor with --test");
540
578
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
541
579
  }
542
- if (flags.migrateUp && (flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateDown || flags.inflate)) {
580
+ if (flags.migrateUp && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateDown || flags.inflate)) {
543
581
  console.error("bad arguments. cannot use with --migrate-up");
544
582
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
545
583
  }
546
- if (flags.migrateDown && (flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate)) {
584
+ if (flags.migrateDown && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate)) {
547
585
  console.error("bad arguments. cannot use with --migrate-down");
548
586
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
549
587
  }
550
- if (flags.generateDoc && (flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate || flags.migrateDown)) {
588
+ if (flags.generateDoc && (flags.watch || flags.hotreload || flags.editor || flags.compile || flags.test || flags.migrateUp || flags.inflate || flags.migrateDown)) {
551
589
  console.error("bad arguments. cannot use with --generate-doc");
552
590
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
553
591
  }
@@ -569,11 +607,13 @@ export function parseArguments() {
569
607
  process.exit(EXIT_CODES.BAD_ARGUMENTS);
570
608
  }
571
609
  return {
610
+ inflateParallel: flags.inflateParallel ? flags.inflateParallel : undefined,
572
611
  name: flags.name ? flags.name : undefined,
573
612
  browser: flags.browser !== null ? flags.browser : undefined,
574
613
  logFile: flags.logFile !== null ? flags.logFile : undefined,
575
614
  generateDocAll: flags.generateDocAll ? true : false,
576
615
  hotreload: flags.hotreload ? true : false,
616
+ watch: flags.watch ? true : false,
577
617
  disableMiqroJSON: flags.disableMiqroJSON !== null ? flags.disableMiqroJSON : false,
578
618
  miqroJSONPath: miqroJSONPath ? miqroJSONPath : false,
579
619
  installTypes: flags.installTypes ? true : false,
@@ -6,3 +6,9 @@ export declare function describeFilePath(filePath: string): {
6
6
  subName: string;
7
7
  filePath: string;
8
8
  };
9
+ export declare function mkdirASync(path: string, options?: Partial<{
10
+ recursive: true;
11
+ }>): Promise<void>;
12
+ export declare function writeFileASync(path: string, body?: any): Promise<void>;
13
+ export declare function rmdirASync(path: string): Promise<void>;
14
+ export declare function unlinkASync(path: string): Promise<void>;
@@ -1,3 +1,4 @@
1
+ import { mkdir, rmdir, unlink, writeFile } from "node:fs";
1
2
  import { basename, extname } from "node:path";
2
3
  export function describeFilePath(filePath) {
3
4
  const ext = extname(filePath);
@@ -14,3 +15,71 @@ export function describeFilePath(filePath) {
14
15
  filePath
15
16
  };
16
17
  }
18
+ export async function mkdirASync(path, options) {
19
+ return new Promise((resolve, reject) => {
20
+ try {
21
+ mkdir(path, options, (err) => {
22
+ if (err) {
23
+ reject(err);
24
+ }
25
+ else {
26
+ resolve();
27
+ }
28
+ });
29
+ }
30
+ catch (e) {
31
+ reject(e);
32
+ }
33
+ });
34
+ }
35
+ export async function writeFileASync(path, body) {
36
+ return new Promise((resolve, reject) => {
37
+ try {
38
+ writeFile(path, body, (err) => {
39
+ if (err) {
40
+ reject(err);
41
+ }
42
+ else {
43
+ resolve();
44
+ }
45
+ });
46
+ }
47
+ catch (e) {
48
+ reject(e);
49
+ }
50
+ });
51
+ }
52
+ export async function rmdirASync(path) {
53
+ return new Promise((resolve, reject) => {
54
+ try {
55
+ rmdir(path, (err) => {
56
+ if (err) {
57
+ reject(err);
58
+ }
59
+ else {
60
+ resolve();
61
+ }
62
+ });
63
+ }
64
+ catch (e) {
65
+ reject(e);
66
+ }
67
+ });
68
+ }
69
+ export async function unlinkASync(path) {
70
+ return new Promise((resolve, reject) => {
71
+ try {
72
+ unlink(path, (err) => {
73
+ if (err) {
74
+ reject(err);
75
+ }
76
+ else {
77
+ resolve();
78
+ }
79
+ });
80
+ }
81
+ catch (e) {
82
+ reject(e);
83
+ }
84
+ });
85
+ }
@@ -1,3 +1,3 @@
1
1
  export declare const BIN_NAME = "miqro";
2
2
  export declare const usage = "usage: miqro [...FLAGS] --service app/\n\n==examples==\n\nmiqro --watch --service front/\nPORT=8181 miqro --service api/ --service front/\nmiqro --test --service front/\nmiqro --inflate --service front/\nmiqro --generate-doc --generate-doc-out API.md --service front/\nCLUSTER_COUNT=10 miqro-cluster --service api/";
3
- export declare const help = "\n==flags==\n\n-v, --version\n\toutputs the version number\n-h, --help\n\toutputs this page.\n--watch\n\tuse to enable the hot-reload functionality.\n--test\n\trun the tests for a service.\n--migrate-up\n\tmigrations up.\n--migrate-down\n\tmigrations down.\n--inflate\n\tinflates the application.\n--inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.\n--editor\n\truns the application with a built-in editor.\n--generate-doc\n\tgenerates a documentation for the api endpoints of the service.\n--generate-doc-out\n\tthe output file for the generated documentation. default value is API.md.\n--generate-doc-type\n\tthe format of the generated documentation. it can be JSON or MD. default value is MD.\n--generate-doc-all\n\toutputs all the server routes in the documentation output.\n--compile\n\tinflates the application and tries to create a NODE SEA binary.\n--inflate-sea\n\tinflates the application with sea compilation scripts.\n--install-tsconfig\n\tcreates a tsconfig.json configured to use with --install-types.\n--install-types\n\tcreates and updates the .types/ folder use together with --install-tsconfig.\n--install-miqrojson\n\tcreates a default miqro.json file.\n--disable-miqrojson\n\tdisables the load of miqro.json file.\n--log-file\n\toverrides the default log file from LOG_FILE.\n--browser\n\toverrides the default browser from BROWSER.\n--config\n\toverrides the default miqro.json path.\n--port\n\toverrides the default port from PORT.\n--name\n\toverrides the default name of the server.\n--https\n\tserves the server in https instead of http\n--https-key\n\tpoint to a server.key file for https.\n--https-cert\n\tpoint to a server.cert file for https.\n--https-redirect\n\tserves an aditional http server that redirects to https. it needs a port number.\n\n==environment variables==\n\nPORT\n\toverride the default 8080 port.\nBROWSER\n\toverride the default browser. change to none to disable.\".\nLOG_FILE\n\toverride the default ./server.log file\nDB\n\tenable the server.db features\nDB_STORAGE\n\toverride the default local db location ./db.sqlite3\nDB_DIALECT\n\toverride the default node:sqlite\nDB_CONNECTION\n\toverride the default connection url\nCLEAR_JSX_CACHE\n\tset to 1 or 0 to enable or disable the clearing of the esbuild cache defaults to 1.\nJSX_TMP\n\tset custom location of esbuild builds defaults to /tmp/jsx_tmp.\n";
3
+ export declare const help = "\n==flags==\n\n-v, --version\n\toutputs the version number\n-h, --help\n\toutputs this page.\n--watch\n\tuse to auto reload the server when files change.\n--hot-reload\n\tenables the hot-reload functionality use with --watch.\n--test\n\trun the tests for a service.\n--migrate-up\n\tmigrations up.\n--migrate-down\n\tmigrations down.\n--inflate\n\tinflates the application.\n--inflate-dir\n\tto set the output directory of the --inflate command. default value is inflated/.\n--editor\n\truns the application with a built-in editor.\n--generate-doc\n\tgenerates a documentation for the api endpoints of the service.\n--generate-doc-out\n\tthe output file for the generated documentation. default value is API.md.\n--generate-doc-type\n\tthe format of the generated documentation. it can be JSON or MD. default value is MD.\n--generate-doc-all\n\toutputs all the server routes in the documentation output.\n--compile\n\tinflates the application and tries to create a NODE SEA binary.\n--inflate-sea\n\tinflates the application with sea compilation scripts.\n--install-tsconfig\n\tcreates a tsconfig.json configured to use with --install-types.\n--install-types\n\tcreates and updates the .types/ folder use together with --install-tsconfig.\n--install-miqrojson\n\tcreates a default miqro.json file.\n--disable-miqrojson\n\tdisables the load of miqro.json file.\n--log-file\n\toverrides the default log file from LOG_FILE.\n--browser\n\toverrides the default browser from BROWSER.\n--config\n\toverrides the default miqro.json path.\n--port\n\toverrides the default port from PORT.\n--name\n\toverrides the default name of the server.\n--https\n\tserves the server in https instead of http\n--https-key\n\tpoint to a server.key file for https.\n--https-cert\n\tpoint to a server.cert file for https.\n--https-redirect\n\tserves an aditional http server that redirects to https. it needs a port number.\n--inflate-parallel\n\tsets the max parallel esbuild instances. defaults to 1.\n\n==environment variables==\n\nPORT\n\toverride the default 8080 port.\nBROWSER\n\toverride the default browser. change to none to disable.\".\nLOG_FILE\n\toverride the default ./server.log file\nDB\n\tenable the server.db features\nDB_STORAGE\n\toverride the default local db location ./db.sqlite3\nDB_DIALECT\n\toverride the default node:sqlite\nDB_CONNECTION\n\toverride the default connection url\nCLEAR_JSX_CACHE\n\tset to 1 or 0 to enable or disable the clearing of the esbuild cache defaults to 1.\nJSX_TMP\n\tset custom location of esbuild builds defaults to /tmp/jsx_tmp.\n";
@@ -15,7 +15,8 @@ export const help = `
15
15
 
16
16
  -v, --version\n\toutputs the version number
17
17
  -h, --help\n\toutputs this page.
18
- --watch\n\tuse to enable the hot-reload functionality.
18
+ --watch\n\tuse to auto reload the server when files change.
19
+ --hot-reload\n\tenables the hot-reload functionality use with --watch.
19
20
  --test\n\trun the tests for a service.
20
21
  --migrate-up\n\tmigrations up.
21
22
  --migrate-down\n\tmigrations down.
@@ -41,6 +42,7 @@ export const help = `
41
42
  --https-key\n\tpoint to a server.key file for https.
42
43
  --https-cert\n\tpoint to a server.cert file for https.
43
44
  --https-redirect\n\tserves an aditional http server that redirects to https. it needs a port number.
45
+ --inflate-parallel\n\tsets the max parallel esbuild instances. defaults to 1.
44
46
 
45
47
  ==environment variables==
46
48
 
@@ -1,7 +1,6 @@
1
1
  import { createNodeRuntime } from "@miqro/jsx-node";
2
2
  import { basename, dirname, extname, relative, resolve } from "node:path";
3
3
  import { randomUUID } from "node:crypto";
4
- import { mkdirSync, rmdirSync, unlinkSync, writeFileSync } from "node:fs";
5
4
  import { Parser } from "@miqro/parser";
6
5
  import { APIRouteSchema, SessionHandlerOptionsSchema } from "@miqro/core";
7
6
  import { cwd } from "node:process";
@@ -12,6 +11,7 @@ import { CLEAR_JSX_CACHE } from "./constants.js";
12
11
  import { getAsset, initAsset, validateAsset } from "./assets.js";
13
12
  import { calculateChecksumFromBuffer } from "./checksum.js";
14
13
  import { HandlerWithOptionsSchema, RouteOptionsSchema } from "@miqro/core/build/types.js";
14
+ import { mkdirASync, rmdirASync, unlinkASync, writeFileASync } from "./fs.js";
15
15
  let jsxJSBuffer = null; // Buffer.from(getAsset("jsx.dom.js"));
16
16
  let jsxJSBufferChecksumPromise = null; // calculateChecksumFromBuffer(jsxJSBuffer);
17
17
  export async function initJSXJS(logger) {
@@ -40,11 +40,11 @@ export async function inflateJSX(inFile, options) {
40
40
  const logger = options.logger; //getLogger(`${SERVER_IDENTIFIER}_JSX`);
41
41
  try {
42
42
  if (!options.embemedJSX) {
43
- mkdirSync(tmpBuildDir, {
43
+ await mkdirASync(tmpBuildDir, {
44
44
  recursive: true
45
45
  });
46
- writeFileSync(inFileTmp, browserJSXGlobals(inFile, false, options.useExport));
47
- //writeFileSync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), false));
46
+ await writeFileASync(inFileTmp, browserJSXGlobals(inFile, false, options.useExport));
47
+ //await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), false));
48
48
  logger?.trace("inflating [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
49
49
  const { outputFiles: [{ contents }] } = await esBuild({
50
50
  ...DEFAULT_ESOPTION,
@@ -54,18 +54,18 @@ export async function inflateJSX(inFile, options) {
54
54
  });
55
55
  if (CLEAR_JSX_CACHE) {
56
56
  logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
57
- unlinkSync(inFileTmp);
58
- rmdirSync(tmpBuildDir);
57
+ await unlinkASync(inFileTmp);
58
+ await rmdirASync(tmpBuildDir);
59
59
  }
60
60
  return contents;
61
61
  }
62
62
  else {
63
- mkdirSync(tmpBuildDir, {
63
+ await mkdirASync(tmpBuildDir, {
64
64
  recursive: true
65
65
  });
66
- //writeFileSync(jsxJSPath, Buffer.from(getAsset("jsx-dom-bundle")));
67
- writeFileSync(inFileTmp, browserJSXGlobals(inFile, jsxJSPath));
68
- //writeFileSync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), relative(tmpBuildDir, jsxJSPath)));
66
+ //await writeFileASync(jsxJSPath, Buffer.from(getAsset("jsx-dom-bundle")));
67
+ await writeFileASync(inFileTmp, browserJSXGlobals(inFile, jsxJSPath));
68
+ //await writeFileASync(inFileTmp, browserJSXGlobals(relative(tmpBuildDir, inFile), relative(tmpBuildDir, jsxJSPath)));
69
69
  logger?.trace("inflating [%s] from [%s] with jsx.js embedded. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
70
70
  const { outputFiles: [{ contents }] } = await esBuild({
71
71
  ...DEFAULT_ESOPTION,
@@ -75,9 +75,9 @@ export async function inflateJSX(inFile, options) {
75
75
  });
76
76
  if (CLEAR_JSX_CACHE) {
77
77
  logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
78
- unlinkSync(inFileTmp);
79
- //unlinkSync(jsxJSPath);
80
- rmdirSync(tmpBuildDir);
78
+ await unlinkASync(inFileTmp);
79
+ //await unlinkASync(jsxJSPath);
80
+ await rmdirASync(tmpBuildDir);
81
81
  }
82
82
  return contents;
83
83
  }
@@ -88,9 +88,9 @@ export async function inflateJSX(inFile, options) {
88
88
  if (options.embemedJSX) {
89
89
  if (CLEAR_JSX_CACHE) {
90
90
  logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
91
- unlinkSync(inFileTmp);
92
- //unlinkSync(jsxJSPath);
93
- rmdirSync(tmpBuildDir);
91
+ await unlinkASync(inFileTmp);
92
+ //await unlinkASync(jsxJSPath);
93
+ await rmdirASync(tmpBuildDir);
94
94
  }
95
95
  else {
96
96
  //console.error("errors on: " + tmpBuildDir);
@@ -427,11 +427,11 @@ export async function importJSXFile(inFile, logger) {
427
427
  //const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".mjs");
428
428
  const inFileTmp = resolve(tmpBuildDir, basename(inFile) + ".cjs");
429
429
  //const logger = getLogger(`${SERVER_IDENTIFIER}_JSX`);
430
- mkdirSync(tmpBuildDir, {
430
+ await mkdirASync(tmpBuildDir, {
431
431
  recursive: true
432
432
  });
433
433
  try {
434
- writeFileSync(inFileTmp, inflatedCode);
434
+ await writeFileASync(inFileTmp, inflatedCode);
435
435
  assertGlobalTampered();
436
436
  logger?.trace("importing [%s] from [%s]. to change the import folder set JSX_TMP", relative(cwd(), inFile), dirname(relative(JSX_TMP_DIR, inFileTmp)));
437
437
  logger?.debug("importing [%s]", relative(cwd(), inFile));
@@ -439,8 +439,8 @@ export async function importJSXFile(inFile, logger) {
439
439
  assertGlobalTampered();
440
440
  if (CLEAR_JSX_CACHE) {
441
441
  logger?.trace("clearing cache at [%s]. to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
442
- unlinkSync(inFileTmp);
443
- rmdirSync(tmpBuildDir);
442
+ await unlinkASync(inFileTmp);
443
+ await rmdirASync(tmpBuildDir);
444
444
  }
445
445
  return module.default;
446
446
  }
@@ -449,8 +449,8 @@ export async function importJSXFile(inFile, logger) {
449
449
  logger?.error("error with2: " + inFile);
450
450
  if (CLEAR_JSX_CACHE) {
451
451
  logger?.trace("clearing cache at [%s] to change this behaivor set CLEAR_JSX_CACHE to 0", tmpBuildDir);
452
- unlinkSync(inFileTmp);
453
- rmdirSync(tmpBuildDir);
452
+ await unlinkASync(inFileTmp);
453
+ await rmdirASync(tmpBuildDir);
454
454
  }
455
455
  else {
456
456
  //console.error("errors on: " + tmpBuildDir);
@@ -43,6 +43,7 @@ export async function watchAndServer(app) {
43
43
  }, 2000);
44
44
  }
45
45
  function watchDir(toWatch) {
46
+ clearTimeout(timeout);
46
47
  const files = existsSync(toWatch) ? readdirSync(toWatch) : [];
47
48
  for (const file of files) {
48
49
  const filePath = resolve(toWatch, file);
@@ -56,6 +57,7 @@ export async function watchAndServer(app) {
56
57
  }
57
58
  }
58
59
  function stopWatch() {
60
+ clearTimeout(timeout);
59
61
  const toClose = watchers.splice(0, watchers.length);
60
62
  for (const watcher of toClose) {
61
63
  watcher.close();
@@ -63,6 +65,7 @@ export async function watchAndServer(app) {
63
65
  }
64
66
  function reWatch() {
65
67
  stopWatch();
68
+ clearTimeout(timeout);
66
69
  for (const service of app.options.services) {
67
70
  const toWatch = resolve(process.cwd(), service);
68
71
  watchDir(toWatch);
@@ -1,7 +1,7 @@
1
- import { chmodSync, constants, mkdirSync, writeFileSync } from "node:fs";
1
+ import { chmodSync, constants, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { basename, dirname, extname, join, relative, resolve } from "node:path";
3
3
  import { cwd, platform } from "node:process";
4
- import { getAuthConfigPath, getCORSConfigPath, getDBConfigPath, getErrorConfigPath, getMiddlewareConfigPath, getMigrationsPath, getServerConfigPath, getWSConfigPath } from "../common/paths.js";
4
+ import { getAuthConfigPath, getCORSConfigPath, getDBConfigPath, getErrorConfigPath, getMiddlewareConfigPath, getMigrationsPath, getMiqroJSONPath, getServerConfigPath, getWSConfigPath } from "../common/paths.js";
5
5
  import { getAsset } from "../common/assets.js";
6
6
  import { migration } from "@miqro/query";
7
7
  import { esBuild } from "../common/esbuild.js";
@@ -104,6 +104,10 @@ main().catch(e=>console.error(e));
104
104
  platform: "node",
105
105
  outfile: join(inflateDir, "sea", "app.bundle.cjs")
106
106
  });
107
+ const miqroRCPath = getMiqroJSONPath();
108
+ if (miqroRCPath) {
109
+ writeFile(logger, join(inflateDir, "miqro.json"), readFileSync(miqroRCPath));
110
+ }
107
111
  }
108
112
  export async function inflateServiceForSea(logger, inflateDir, service, servicePath /*, serviceMigrations: string[]*/, serviceRouteFileMap, serviceStaticFileMap) {
109
113
  const migrationsFolderPath = getMigrationsPath(servicePath);
@@ -11,5 +11,6 @@ export interface InflateAppOptions {
11
11
  hotreload?: boolean;
12
12
  port: string;
13
13
  serverInterface: ServerInterface;
14
+ inflateParallel?: number;
14
15
  }
15
- export declare function inflateApp({ serverInterface, logger, hotreload, services, inflateDir, inflateSea, port }: InflateAppOptions): Promise<[Router, InflateError[] | null, RouteFileMap, WSConfig[], LogConfigMap]>;
16
+ export declare function inflateApp({ inflateParallel, 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*/, port }) {
11
+ export async function inflateApp({ inflateParallel, serverInterface, logger, hotreload, services /*, dbManager*/, inflateDir, inflateSea /*, editor, inflateTests*/, port }) {
12
12
  logger.trace("inflateApp");
13
13
  const errors = [];
14
14
  //const migrations: string[] = [];
@@ -43,7 +43,7 @@ export async function inflateApp({ serverInterface, logger, hotreload, services
43
43
  }*/
44
44
  //await setupDB(logger, service, dbConfigList, inflateDir);
45
45
  await setupLogConfig(logger, servicePath, service, logConfigMap, inflateSea ? inflateDir : false, errors);
46
- router.use(await setupHTTPRouter(serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors));
46
+ router.use(await setupHTTPRouter(serverInterface, logger, hotreload ? hotreload : false, servicePath, service, serviceRouteFileMap, serviceStaticFileMap, inflateDir, inflateSea, errors, inflateParallel));
47
47
  routeFileMap = {
48
48
  ...routeFileMap,
49
49
  ...serviceRouteFileMap
@@ -25,7 +25,7 @@ export interface StaticFileMap {
25
25
  body: Buffer;
26
26
  };
27
27
  }
28
- export declare function setupHTTPRouter(server: ServerInterface, logger: Logger, hotreload: boolean, servicePath: string, service: string, routeFileMap: RouteFileMap, staticFileMap: StaticFileMap | null, inflateDir: string | undefined | false, inflateSea: boolean, errors: InflateError[]): Promise<Router>;
28
+ export declare function setupHTTPRouter(server: ServerInterface, logger: Logger, hotreload: boolean, servicePath: string, service: string, routeFileMap: RouteFileMap, staticFileMap: StaticFileMap | null, inflateDir: string | undefined | false, inflateSea: boolean, errors: InflateError[], inflateParallel?: number): Promise<Router>;
29
29
  interface ScannedFile {
30
30
  filePath: string;
31
31
  ext: string;