miqro 2.0.2 → 3.0.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.
Files changed (71) hide show
  1. package/README.md +18 -36
  2. package/build/cli.js +6 -0
  3. package/build/cmd-map.d.ts +79 -0
  4. package/{dist/cli.js → build/cmd-map.js} +22 -49
  5. package/{dist → build}/cmds/doc-json.d.ts +1 -1
  6. package/{dist → build}/cmds/doc-json.js +3 -3
  7. package/build/cmds/doc-md.d.ts +2 -0
  8. package/build/cmds/doc-md.js +17 -0
  9. package/{dist → build}/cmds/handler-main-new.js +21 -15
  10. package/build/cmds/help.d.ts +1 -0
  11. package/build/cmds/help.js +9 -0
  12. package/{dist → build}/cmds/new-test.js +13 -2
  13. package/{dist → build}/cmds/new.js +20 -15
  14. package/{dist → build}/cmds/serve.d.ts +1 -1
  15. package/{dist → build}/cmds/serve.js +12 -7
  16. package/build/utils/doc/json.d.ts +6 -0
  17. package/{dist/utils/doc/index.js → build/utils/doc/json.js} +2 -3
  18. package/build/utils/doc/md.d.ts +18 -0
  19. package/build/utils/doc/md.js +129 -0
  20. package/{dist → build}/utils/index.d.ts +7 -4
  21. package/{dist → build}/utils/index.js +20 -14
  22. package/package.json +13 -14
  23. package/dist/cmds/db-console.d.ts +0 -2
  24. package/dist/cmds/db-console.js +0 -38
  25. package/dist/cmds/db-createmodel.d.ts +0 -2
  26. package/dist/cmds/db-createmodel.js +0 -37
  27. package/dist/cmds/db-dump-data.d.ts +0 -2
  28. package/dist/cmds/db-dump-data.js +0 -43
  29. package/dist/cmds/db-init.d.ts +0 -2
  30. package/dist/cmds/db-init.js +0 -38
  31. package/dist/cmds/db-makemigrations.d.ts +0 -2
  32. package/dist/cmds/db-makemigrations.js +0 -14
  33. package/dist/cmds/db-migrate.d.ts +0 -2
  34. package/dist/cmds/db-migrate.js +0 -12
  35. package/dist/cmds/db-push-data.d.ts +0 -2
  36. package/dist/cmds/db-push-data.js +0 -79
  37. package/dist/cmds/db-sync-makemigrations.d.ts +0 -2
  38. package/dist/cmds/db-sync-makemigrations.js +0 -14
  39. package/dist/cmds/test.d.ts +0 -2
  40. package/dist/cmds/test.js +0 -15
  41. package/dist/utils/db/automigrations/index.d.ts +0 -2
  42. package/dist/utils/db/automigrations/index.js +0 -121
  43. package/dist/utils/db/automigrations/migrate.d.ts +0 -45
  44. package/dist/utils/db/automigrations/migrate.js +0 -750
  45. package/dist/utils/db/index.d.ts +0 -20
  46. package/dist/utils/db/index.js +0 -127
  47. package/dist/utils/doc/index.d.ts +0 -7
  48. /package/{dist → build}/cli.d.ts +0 -0
  49. /package/{dist → build}/cmds/config-bash.d.ts +0 -0
  50. /package/{dist → build}/cmds/config-bash.js +0 -0
  51. /package/{dist → build}/cmds/config-env.d.ts +0 -0
  52. /package/{dist → build}/cmds/config-env.js +0 -0
  53. /package/{dist → build}/cmds/config-init.d.ts +0 -0
  54. /package/{dist → build}/cmds/config-init.js +0 -0
  55. /package/{dist → build}/cmds/config.d.ts +0 -0
  56. /package/{dist → build}/cmds/config.js +0 -0
  57. /package/{dist → build}/cmds/handler-apiroute-new.d.ts +0 -0
  58. /package/{dist → build}/cmds/handler-apiroute-new.js +0 -0
  59. /package/{dist → build}/cmds/handler-main-new.d.ts +0 -0
  60. /package/{dist → build}/cmds/new-test.d.ts +0 -0
  61. /package/{dist → build}/cmds/new.d.ts +0 -0
  62. /package/{dist → build}/cmds/start.d.ts +0 -0
  63. /package/{dist → build}/cmds/start.js +0 -0
  64. /package/{dist → build}/cmds/watch.d.ts +0 -0
  65. /package/{dist → build}/cmds/watch.js +0 -0
  66. /package/{dist → build}/cmds/wc-new.d.ts +0 -0
  67. /package/{dist → build}/cmds/wc-new.js +0 -0
  68. /package/{dist → build}/index.d.ts +0 -0
  69. /package/{dist → build}/index.js +0 -0
  70. /package/{dist → build}/utils/templates.d.ts +0 -0
  71. /package/{dist → build}/utils/templates.js +0 -0
package/README.md CHANGED
@@ -7,43 +7,25 @@ npm install miqro --save-dev
7
7
  to see available cmds
8
8
 
9
9
  ```
10
- npx miqro
10
+ npx miqro help
11
11
  ```
12
12
 
13
13
  ```
14
- Available commands:
15
-
16
-
17
- ==api development==
18
-
19
- new:api create a new project.
20
- new:api:main creates a new main file.
21
- new:api:route creates a new route.
22
- config print config as a json.
23
- config:bash print config as a bash script.
24
- config:env print config as a env file.
25
- config:init inits your config folder.
26
- doc api folder auto doc as a json.
27
-
28
- ==start helpers==
29
-
30
- start start script in cluster mode.
31
- watch watch folder for changes.
32
- serve serve static files.
33
-
34
- ==testing==
35
-
36
- test run test files.
37
- new:test create new test.js file.
38
-
39
- ==sequelize helpers==
40
-
41
- db:console a query console for sequelize.
42
- db:dump:data dump the data of the database.
43
- db:push:data push a dump to the database.
44
- db:make:migration generate migrations from model changes.
45
- db:migration:forceclean force 'local' model state.
46
- db:migrate loads config and run migrations.
47
- db:init init sequelize configuration.
48
- db:create:model creates an example model.
14
+ npx miqro <command> [args]Available commands:
15
+
16
+ new:api create a new project.
17
+ new:api:main creates a new main file.
18
+ new:api:route creates a new route.
19
+ new:api:route:test create new test.js file for an apirouter.
20
+ config print config as a json.
21
+ config:bash print config as a bash script.
22
+ config:env print config as a env file.
23
+ config:init inits your config folder.
24
+ doc api folder auto doc as a json.
25
+ doc:md api folder auto doc as a markdown.
26
+ start start script in cluster mode.
27
+ cluster alias for start command.
28
+ watch watch folder for changes.
29
+ serve serve static files.
30
+ help prints this page
49
31
  ```
package/build/cli.js ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ const cmd_map_1 = require("./cmd-map");
5
+ const utils_1 = require("./utils");
6
+ (0, utils_1.mainCMD)(cmd_map_1.CMDS, cmd_map_1.usage, console);
@@ -0,0 +1,79 @@
1
+ import { main as help } from "./cmds/help";
2
+ export declare const usage = "npx miqro <command> [args]";
3
+ export declare const CMDS: {
4
+ "new:api": {
5
+ cb: () => void;
6
+ tabs: number;
7
+ description: string;
8
+ };
9
+ "new:api:main": {
10
+ cb: () => void;
11
+ tabs: number;
12
+ description: string;
13
+ };
14
+ "new:api:route": {
15
+ cb: () => void;
16
+ tabs: number;
17
+ description: string;
18
+ };
19
+ "new:api:route:test": {
20
+ cb: () => void;
21
+ tabs: number;
22
+ description: string;
23
+ };
24
+ config: {
25
+ cb: () => void;
26
+ tabs: number;
27
+ description: string;
28
+ };
29
+ "config:bash": {
30
+ cb: () => void;
31
+ tabs: number;
32
+ description: string;
33
+ };
34
+ "config:env": {
35
+ cb: () => void;
36
+ tabs: number;
37
+ description: string;
38
+ };
39
+ "config:init": {
40
+ cb: () => void;
41
+ tabs: number;
42
+ description: string;
43
+ };
44
+ doc: {
45
+ tabs: number;
46
+ cb: () => Promise<void>;
47
+ description: string;
48
+ };
49
+ "doc:md": {
50
+ cb: () => Promise<void>;
51
+ tabs: number;
52
+ description: string;
53
+ };
54
+ start: {
55
+ tabs: number;
56
+ cb: () => void;
57
+ description: string;
58
+ };
59
+ cluster: {
60
+ tabs: number;
61
+ cb: () => void;
62
+ description: string;
63
+ };
64
+ watch: {
65
+ cb: () => void;
66
+ tabs: number;
67
+ description: string;
68
+ };
69
+ serve: {
70
+ tabs: number;
71
+ cb: () => Promise<void>;
72
+ description: string;
73
+ };
74
+ help: {
75
+ cb: typeof help;
76
+ tabs: number;
77
+ description: string;
78
+ };
79
+ };
@@ -1,13 +1,11 @@
1
- #!/usr/bin/env node
2
1
  "use strict";
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
- const utils_1 = require("./utils");
3
+ exports.CMDS = exports.usage = void 0;
5
4
  const start_1 = require("./cmds/start");
6
- const test_1 = require("./cmds/test");
7
5
  const watch_1 = require("./cmds/watch");
8
6
  const new_1 = require("./cmds/new");
9
7
  const doc_json_1 = require("./cmds/doc-json");
10
- //import {main as apiDocMD} from "./cmds/doc-md.ts.disable";
8
+ const doc_md_1 = require("./cmds/doc-md");
11
9
  const config_init_1 = require("./cmds/config-init");
12
10
  const config_1 = require("./cmds/config");
13
11
  const config_bash_1 = require("./cmds/config-bash");
@@ -15,18 +13,14 @@ const config_env_1 = require("./cmds/config-env");
15
13
  const handler_apiroute_new_1 = require("./cmds/handler-apiroute-new");
16
14
  const new_test_1 = require("./cmds/new-test");
17
15
  const serve_1 = require("./cmds/serve");
16
+ const help_1 = require("./cmds/help");
18
17
  const handler_main_new_1 = require("./cmds/handler-main-new");
19
- const db_init_1 = require("./cmds/db-init");
20
- const db_makemigrations_1 = require("./cmds/db-makemigrations");
21
- const db_sync_makemigrations_1 = require("./cmds/db-sync-makemigrations");
22
- const db_console_1 = require("./cmds/db-console");
23
- const db_createmodel_1 = require("./cmds/db-createmodel");
24
- const db_push_data_1 = require("./cmds/db-push-data");
25
- const db_dump_data_1 = require("./cmds/db-dump-data");
26
- const db_migrate_1 = require("./cmds/db-migrate");
27
- // noinspection SpellCheckingInspection
28
- (0, utils_1.mainCMD)({
29
- ["new:api"]: { section: "api development", cb: new_1.mainTS, tabs: 4, description: `create a new project.` },
18
+ exports.usage = "npx miqro <command> [args]";
19
+ exports.CMDS = {
20
+ ["new:api"]: {
21
+ //section: "api development",
22
+ cb: new_1.mainTS, tabs: 4, description: `create a new project.`
23
+ },
30
24
  //["new:typescript"]: {cb: newTS, tabs: 4, description: `create a new typescript project.`},
31
25
  ["new:api:main"]: {
32
26
  //section: "http scafolding",
@@ -35,6 +29,7 @@ const db_migrate_1 = require("./cmds/db-migrate");
35
29
  description: `creates a new main file.`
36
30
  },
37
31
  ["new:api:route"]: { cb: handler_apiroute_new_1.main, tabs: 3, description: `creates a new route.` },
32
+ ["new:api:route:test"]: { cb: new_test_1.main, tabs: 2, description: `create new test.js file for an apirouter.` },
38
33
  ["config"]: {
39
34
  //section: "config managment",
40
35
  cb: config_1.main,
@@ -58,11 +53,11 @@ const db_migrate_1 = require("./cmds/db-migrate");
58
53
  cb: doc_json_1.main,
59
54
  description: `api folder auto doc as a json.`
60
55
  },
61
- /*["doc:md"]: {
62
- cb: apiDocMD,
63
- tabs: 4,
64
- description: `api folder auto doc as a markdown.`
65
- },*/
56
+ ["doc:md"]: {
57
+ cb: doc_md_1.main,
58
+ tabs: 4,
59
+ description: `api folder auto doc as a markdown.`
60
+ },
66
61
  /*["new:front"]: {
67
62
  section: "front end development",
68
63
  cb: newTSFront,
@@ -70,7 +65,7 @@ const db_migrate_1 = require("./cmds/db-migrate");
70
65
  description: `create a new web-components project.`
71
66
  },*/
72
67
  ["start"]: {
73
- section: "start helpers",
68
+ //section: "start helpers",
74
69
  tabs: 4,
75
70
  cb: start_1.main,
76
71
  description: `start script in cluster mode.`
@@ -91,31 +86,9 @@ const db_migrate_1 = require("./cmds/db-migrate");
91
86
  tabs: 4,
92
87
  cb: serve_1.main, description: `serve static files.`
93
88
  },
94
- ["test"]: { section: "testing", cb: test_1.main, tabs: 4, description: `run test files.` },
95
- ["new:test"]: { cb: new_test_1.main, tabs: 3, description: `create new test.js file.` },
96
- ["db:console"]: {
97
- section: "sequelize helpers",
98
- cb: db_console_1.main,
99
- tabs: 3,
100
- description: `a query console for sequelize.`
101
- },
102
- ["db:dump:data"]: {
103
- cb: db_dump_data_1.main,
104
- tabs: 3,
105
- description: `dump the data of the database.`
106
- },
107
- ["db:push:data"]: { cb: db_push_data_1.main, tabs: 3, description: `push a dump to the database.` },
108
- ["db:make:migration"]: {
109
- cb: db_makemigrations_1.main,
110
- tabs: 2,
111
- description: `generate migrations from model changes.`
112
- },
113
- ["db:migration:forceclean"]: {
114
- cb: db_sync_makemigrations_1.main,
115
- tabs: 2,
116
- description: `force 'local' model state.`
117
- },
118
- ["db:migrate"]: { cb: db_migrate_1.main, tabs: 3, description: `loads config and run migrations.` },
119
- ["db:init"]: { cb: db_init_1.main, tabs: 4, description: `init sequelize configuration.` },
120
- ["db:create:model"]: { cb: db_createmodel_1.main, tabs: 3, description: `creates an example model.` }
121
- }, "npx miqro <command> [args]", console);
89
+ ["help"]: {
90
+ //section: "help",
91
+ cb: help_1.main,
92
+ tabs: 4, description: "prints this page"
93
+ }
94
+ };
@@ -1,2 +1,2 @@
1
1
  export declare const usage = "usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath> [apiName]";
2
- export declare const main: () => void;
2
+ export declare const main: () => Promise<void>;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.main = exports.usage = void 0;
4
4
  const core_1 = require("@miqro/core");
5
- const doc_1 = require("../utils/doc");
5
+ const json_1 = require("../utils/doc/json");
6
6
  exports.usage = `usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath> [apiName]`;
7
- const main = () => {
7
+ const main = async () => {
8
8
  if (process.argv.length < 5 || process.argv.length > 6) {
9
9
  throw new Error(exports.usage);
10
10
  }
@@ -12,6 +12,6 @@ const main = () => {
12
12
  const subPath = process.argv[4];
13
13
  const apiName = process.argv[5];
14
14
  (0, core_1.loadConfig)();
15
- console.log(JSON.stringify((0, doc_1.getDOCJSON)({ dirname, subPath, apiName }, (0, core_1.getLogger)("miqro")), undefined, 2));
15
+ console.log(JSON.stringify(await (0, json_1.getDOCJSON)({ dirname, subPath, apiName }), undefined, 2));
16
16
  };
17
17
  exports.main = main;
@@ -0,0 +1,2 @@
1
+ export declare const usage = "usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath> [apiName]";
2
+ export declare const main: () => Promise<void>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.main = exports.usage = void 0;
4
+ const core_1 = require("@miqro/core");
5
+ const md_1 = require("../utils/doc/md");
6
+ exports.usage = `usage: [NODE_ENV=development] npx miqro doc <api_folder> <subPath> [apiName]`;
7
+ const main = async () => {
8
+ if (process.argv.length < 5 || process.argv.length > 6) {
9
+ throw new Error(exports.usage);
10
+ }
11
+ const dirname = process.argv[3];
12
+ const subPath = process.argv[4];
13
+ const apiName = process.argv[5];
14
+ (0, core_1.loadConfig)();
15
+ console.log(await (0, md_1.getMDDoc)({ dirname, subPath, apiName }));
16
+ };
17
+ exports.main = main;
@@ -5,7 +5,7 @@ const core_1 = require("@miqro/core");
5
5
  const fs_1 = require("fs");
6
6
  const path_1 = require("path");
7
7
  const mainTemplates = {
8
- ts: () => `import { APIRouter, App, checkEnvVariables, getLogger, middleware } from "@miqro/core";
8
+ ts: () => `import { APIRouter, Server, checkEnvVariables, getLogger, middleware } from "@miqro/core";
9
9
  import { resolve } from "path";
10
10
 
11
11
  /*
@@ -17,14 +17,17 @@ const [PORT] = checkEnvVariables(["PORT"], ["8080"]);
17
17
 
18
18
  const logger = getLogger("server");
19
19
 
20
- const app = new App();
21
- app.use(middleware());
22
- app.use(APIRouter({
23
- dirname: resolve(__dirname, "api")
24
- }, logger));
25
- app.listen(PORT, () => {
20
+ async function main() {
21
+ const app = new Server();
22
+ app.use(middleware());
23
+ app.use(await APIRouter({
24
+ dirname: resolve("./build/api")
25
+ }, logger));
26
+ await app.listen();
26
27
  logger.info("listening on " + PORT);
27
- });
28
+ }
29
+
30
+ main().catch(e => logger.error(e));
28
31
  `,
29
32
  js: () => `const { APIRouter, App, checkEnvVariables, getLogger, middleware } = require("@miqro/core");
30
33
  const { resolve } = require("path");
@@ -38,14 +41,17 @@ const [PORT] = checkEnvVariables(["PORT"], ["8080"]);
38
41
 
39
42
  const logger = getLogger("server");
40
43
 
41
- const app = new App();
42
- app.use(middleware());
43
- app.use(APIRouter({
44
- dirname: resolve(__dirname, "api")
45
- }, logger));
46
- app.listen(PORT, () => {
44
+ async function main() {
45
+ const app = new App();
46
+ app.use(middleware());
47
+ app.use(await APIRouter({
48
+ dirname: resolve(__dirname, "api")
49
+ }, logger));
50
+ await app.listen();
47
51
  logger.info("listening on " + PORT);
48
- });
52
+ }
53
+
54
+ main().catch(e => logger.error(e));
49
55
  `
50
56
  };
51
57
  exports.usage = `usage: [NODE_ENV=development] npx miqro new:api:main <identifier ex: NEW_APP>`;
@@ -0,0 +1 @@
1
+ export declare function main(): void;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.main = void 0;
4
+ const cmd_map_1 = require("../cmd-map");
5
+ const utils_1 = require("../utils");
6
+ function main() {
7
+ console.log((0, utils_1.getUsage)(cmd_map_1.CMDS, cmd_map_1.usage));
8
+ }
9
+ exports.main = main;
@@ -6,9 +6,20 @@ const fs_1 = require("fs");
6
6
  const path_1 = require("path");
7
7
  exports.usage = `usage: [NODE_ENV=development] npx miqro new:test <identifier ex: TEST_SOMEFILE>`;
8
8
  const testTemplates = {
9
- js: (category) => `it("happy path", async () => {
9
+ js: (category) => `import { it } from "node:test";
10
+ import { TestHelper } from "@miqro/test-http";
11
+ import { Server, APIRouter } from "@miqro/core";
12
+ import { resolve } from "path";
13
+ import { strictEqual } from "assert";
10
14
 
11
- })
15
+ it("happy path health", async () => {
16
+ const response = await TestHelper(new Server().use(await APIRouter({
17
+ dirname: resolve("./build/api")
18
+ })), {
19
+ url: "/api/health"
20
+ });
21
+ strictEqual(response.status, 200);
22
+ });
12
23
  `
13
24
  };
14
25
  const main = () => {
@@ -13,41 +13,43 @@ dist/
13
13
  const packageTemplate = {
14
14
  ts: (name) => `{
15
15
  "name": "${name}",
16
+ "type": "module",
16
17
  "version": "1.0.0",
17
18
  "description": "",
18
19
  "private": true,
19
- "main": "dist/main.js",
20
20
  "scripts": {
21
- "prebuild": "rm -Rf dist/;",
21
+ "prebuild": "rm -Rf build/;",
22
22
  "build": "tsc",
23
23
  "prestart": "npm run build",
24
- "start": "node dist/main.js",
24
+ "start": "node --enable-source-maps build/main.js",
25
+ "cluster": "NODE_OPTIONS=--enable-source-maps miqro cluster build/main.js",
25
26
  "pretest": "npm run build",
26
- "test": "miqro-test -r test/ -n"
27
+ "test": "node --enable-source-maps --test test/",
28
+ "coverage": "node --enable-source-maps --experimental-test-coverage --test test/"
27
29
  },
28
30
  "devDependencies": {
29
31
  },
30
32
  "dependencies": {
31
33
  },
32
- "author": "",
33
- "license": "ISC"
34
+ "author": ""
34
35
  }`,
35
36
  js: (name) => `{
36
37
  "name": "${name}",
38
+ "type": "module",
37
39
  "version": "1.0.0",
38
40
  "description": "",
39
41
  "private": true,
40
- "main": "src/main.js",
41
42
  "scripts": {
42
43
  "start": "node src/main.js",
43
- "test": "miqro-test -r test/ -n"
44
+ "cluster": "miqro cluster src/main.js",
45
+ "test": "node --test test/",
46
+ "coverage": "node --experimental-test-coverage --test test/"
44
47
  },
45
48
  "devDependencies": {
46
49
  },
47
50
  "dependencies": {
48
51
  },
49
- "author": "",
50
- "license": "ISC"
52
+ "author": ""
51
53
  }`
52
54
  };
53
55
  exports.usageTS = `usage: npx miqro new:api <identifier ex: NEW_APP>`;
@@ -75,11 +77,11 @@ const mainTS = () => {
75
77
  "compileOnSave": true,
76
78
  "compilerOptions": {
77
79
  "lib": ["es2021"],
78
- "module": "commonjs",
79
- "moduleResolution": "node",
80
+ "module": "es2022",
81
+ "moduleResolution": "Node16",
80
82
  "target": "es2021",
81
83
  "strict": false,
82
- "outDir": "./dist/",
84
+ "outDir": "./build/",
83
85
  "removeComments": true,
84
86
  "noImplicitAny": false,
85
87
  "preserveConstEnums": true,
@@ -102,7 +104,7 @@ const mainTS = () => {
102
104
  cwd: appFolder
103
105
  });
104
106
  (0, fs_1.writeFileSync)((0, path_1.resolve)(appFolder, ".gitignore"), gitignoreTemplate.ts());
105
- (0, utils_1.execSync)(`npm install @miqro/test --save-dev`, {
107
+ (0, utils_1.execSync)(`npm install @miqro/test-http --save-dev`, {
106
108
  cwd: appFolder
107
109
  });
108
110
  (0, utils_1.execSync)(`npx miqro new:api:main src_main`, {
@@ -114,11 +116,14 @@ const mainTS = () => {
114
116
  (0, fs_1.mkdirSync)((0, path_1.resolve)(appFolder, "test"), {
115
117
  recursive: true
116
118
  });
117
- (0, utils_1.execSync)(`npx miqro new:test test_api_health`, {
119
+ (0, utils_1.execSync)(`npx miqro new:api:route:test test_api_health`, {
118
120
  cwd: appFolder
119
121
  });
122
+ console.log("");
123
+ console.log("");
120
124
  console.log(`new project created on ${appFolder}`);
121
125
  console.log(`cd ${identifier}`);
122
126
  console.log(`npm run start`);
127
+ console.log("");
123
128
  };
124
129
  exports.mainTS = mainTS;
@@ -1,2 +1,2 @@
1
1
  export declare const usage = "usage: [NODE_ENV=development] npx miqro serve [directory=./] [path=/] [--index404 ./index.html] [--proxy-cert-ignore] [--port 8080] [--proxy /api=https://host/api]";
2
- export declare const main: () => void;
2
+ export declare const main: () => Promise<void>;
@@ -4,12 +4,14 @@ exports.main = exports.usage = void 0;
4
4
  const core_1 = require("@miqro/core");
5
5
  const utils_1 = require("../utils");
6
6
  const url_1 = require("url");
7
- const tokenize_match_1 = require("@miqro/core/dist/common/tokenize-match");
8
7
  const fs_1 = require("fs");
9
8
  exports.usage = `usage: [NODE_ENV=development] npx miqro serve [directory=./] [path=/] [--index404 ./index.html] [--proxy-cert-ignore] [--port 8080] [--proxy /api=https://host/api]`;
10
- const main = () => {
9
+ const main = async () => {
11
10
  const flags = (0, utils_1.extractFlags)(process.argv.slice(3), {
12
11
  flags: {
12
+ "help": {
13
+ description: "get help page", hasValue: false
14
+ },
13
15
  "index404Status": {
14
16
  description: "status to handle index404 status", hasValue: true
15
17
  },
@@ -24,6 +26,10 @@ const main = () => {
24
26
  }
25
27
  }
26
28
  });
29
+ if (flags.flags.help !== undefined) {
30
+ console.log(exports.usage);
31
+ process.exit(102);
32
+ }
27
33
  if (flags.files.length > 2) {
28
34
  throw new Error(`invalid arguments.\n${exports.usage}`);
29
35
  }
@@ -53,9 +59,9 @@ const main = () => {
53
59
  if (proxySplit.length !== 2) {
54
60
  throw new Error("proxy must be in the form. /path=proxy");
55
61
  }
56
- const proxyPath = (0, tokenize_match_1.normalizePath)(proxySplit[0]);
62
+ const proxyPath = (0, core_1.normalizePath)(proxySplit[0]);
57
63
  const proxyURL = new url_1.URL(proxySplit[1]);
58
- proxyURL.pathname = (0, tokenize_match_1.normalizePath)(proxyURL.pathname);
64
+ proxyURL.pathname = (0, core_1.normalizePath)(proxyURL.pathname);
59
65
  const proxyRouter = (0, core_1.Proxy)({
60
66
  url: proxyURL.toString(), rejectUnauthorized: flags.flags["proxy-cert-ignore"] ? true : false
61
67
  });
@@ -70,8 +76,7 @@ const main = () => {
70
76
  index404: flags.flags.index404 ? flags.flags.index404 : undefined,
71
77
  index404Status: flags.flags.index404Status ? parseInt(flags.flags.index404Status, 10) : undefined
72
78
  }), path);
73
- app.listen(PORT, () => {
74
- console.log("serving " + directory + " on http://localhost:%s%s", PORT, path);
75
- });
79
+ await app.listen(PORT);
80
+ console.log("serving " + directory + " on http://localhost:%s%s", PORT, path);
76
81
  };
77
82
  exports.main = main;
@@ -0,0 +1,6 @@
1
+ import { RouterJSONDoc, Logger } from "@miqro/core";
2
+ export declare const getDOCJSON: ({ dirname, subPath, apiName }: {
3
+ apiName?: string | undefined;
4
+ dirname: string;
5
+ subPath: string;
6
+ }, logger?: Logger) => Promise<RouterJSONDoc>;
@@ -3,10 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDOCJSON = void 0;
4
4
  const core_1 = require("@miqro/core");
5
5
  const path_1 = require("path");
6
- const getDOCJSON = ({ dirname, subPath, apiName }, logger) => {
6
+ const getDOCJSON = async ({ dirname, subPath, apiName }, logger) => {
7
7
  //const apiTraverse = traverseAPIRouteDir(basename(dirname).toUpperCase(), resolve(ConfigPathResolver.getBaseDirname(), dirname), subPath, undefined, logger);
8
- console.log(apiName);
9
- const router = (0, core_1.APIRouter)({
8
+ const router = await (0, core_1.APIRouter)({
10
9
  apiName,
11
10
  dirname: (0, path_1.resolve)(core_1.ConfigPathResolver.getBaseDirname(), dirname),
12
11
  path: subPath
@@ -0,0 +1,18 @@
1
+ import { Logger } from "@miqro/core";
2
+ import { ParserArgs, ParserMode } from "@miqro/parser";
3
+ export declare function getMDDoc(args: {
4
+ showFilePath?: boolean;
5
+ apiName?: string;
6
+ dirname: string;
7
+ subPath: string;
8
+ }, logger?: Logger): Promise<string>;
9
+ export declare function parserToString(parser: {
10
+ headers?: ParserArgs | ParserArgs[];
11
+ headersMode?: ParserMode;
12
+ query?: ParserArgs | boolean | ParserArgs[];
13
+ queryMode?: ParserMode;
14
+ params?: ParserArgs | boolean | ParserArgs[];
15
+ paramsMode?: ParserMode;
16
+ body?: ParserArgs | boolean | ParserArgs[];
17
+ bodyMode?: ParserMode;
18
+ }): string;