miqro 1.7.7 → 1.7.8
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/dist/cli.js +2 -0
- package/dist/cmds/doc-md.js +14 -15
- package/dist/cmds/serve.d.ts +1 -0
- package/dist/cmds/serve.js +26 -0
- package/dist/utils/db/index.js +3 -2
- package/dist/utils/doc/index.d.ts +6 -5
- package/dist/utils/doc/index.js +11 -2
- package/package.json +3 -2
package/dist/cli.js
CHANGED
|
@@ -14,6 +14,7 @@ const config_bash_1 = require("./cmds/config-bash");
|
|
|
14
14
|
const config_env_1 = require("./cmds/config-env");
|
|
15
15
|
const handler_apiroute_new_1 = require("./cmds/handler-apiroute-new");
|
|
16
16
|
const new_test_1 = require("./cmds/new-test");
|
|
17
|
+
const serve_1 = require("./cmds/serve");
|
|
17
18
|
const handler_main_new_1 = require("./cmds/handler-main-new");
|
|
18
19
|
//@miqro/database
|
|
19
20
|
const db_init_1 = require("./cmds/db-init");
|
|
@@ -37,6 +38,7 @@ const db_dump_data_1 = require("./cmds/db-dump-data");
|
|
|
37
38
|
["config:env"]: { cb: config_env_1.main, description: "\t\t\toutputs to stdout the config as a env file" },
|
|
38
39
|
["config:init"]: { cb: config_init_1.main, description: "\t\t\tinits your config folder" },
|
|
39
40
|
["start"]: { section: "cluster start", cb: start_1.main, description: "\t\t\t\tstart a nodejs script in cluster mode and restart if crash." },
|
|
41
|
+
["serve"]: { section: "serve static files", cb: serve_1.main, description: "\t\t\t\tserve static files." },
|
|
40
42
|
["doc"]: { section: "api documentation", cb: doc_json_1.main, description: "\t\t\t\toutputs to stdout an api folder auto doc as a json" },
|
|
41
43
|
["doc:md"]: { cb: doc_md_1.main, description: "\t\t\t\toutputs to a file an api folder auto doc as a markdown" },
|
|
42
44
|
["test:new"]: { section: "testing", cb: new_test_1.main, description: "\t\t\tcreate new test.js file." },
|
package/dist/cmds/doc-md.js
CHANGED
|
@@ -105,7 +105,7 @@ const main = () => {
|
|
|
105
105
|
return range;
|
|
106
106
|
};
|
|
107
107
|
const parseOptionTable = (options, subName = "", tableHeaders = 0) => {
|
|
108
|
-
if (options) {
|
|
108
|
+
if (typeof options !== "boolean" && options) {
|
|
109
109
|
let padding = "";
|
|
110
110
|
for (let i = 0; i < tableHeaders; i++) {
|
|
111
111
|
padding += "| ";
|
|
@@ -155,13 +155,12 @@ const main = () => {
|
|
|
155
155
|
const param = doc.params instanceof Array ? doc.params : [doc.params];
|
|
156
156
|
const paramsTable = [];
|
|
157
157
|
for (const q of param) {
|
|
158
|
-
let paramTable = parseOptionTable(q);
|
|
159
|
-
// let paramsTable = parseOptionTable(doc.params);
|
|
158
|
+
let paramTable = typeof q === "string" ? `${q}` : parseOptionTable(q);
|
|
160
159
|
if (paramTable.split("\n").length > 1) {
|
|
161
|
-
paramTable = `### params${q && q.description ? ` (${q.description})` : ""}\n\n${paramTable}`;
|
|
160
|
+
paramTable = `### params${typeof q !== "boolean" && typeof q !== "string" && q && q.description ? ` (${q.description})` : ""}\n\n${paramTable}`;
|
|
162
161
|
}
|
|
163
162
|
else {
|
|
164
|
-
paramTable = paramTable === "" ? "" : `### params${q && q.description ? ` (${q.description})` : ""}: ${paramTable}`;
|
|
163
|
+
paramTable = paramTable === "" ? "" : `### params${typeof q !== "boolean" && typeof q !== "string" && q && q.description ? ` (${q.description})` : ""}: ${paramTable}`;
|
|
165
164
|
}
|
|
166
165
|
if (paramTable !== "") {
|
|
167
166
|
paramsTable.push(paramTable);
|
|
@@ -170,13 +169,13 @@ const main = () => {
|
|
|
170
169
|
const query = doc.query instanceof Array ? doc.query : [doc.query];
|
|
171
170
|
const queryTables = [];
|
|
172
171
|
for (const q of query) {
|
|
173
|
-
let queryTable = parseOptionTable(q);
|
|
172
|
+
let queryTable = typeof q === "string" ? `${q}` : parseOptionTable(q);
|
|
174
173
|
// let paramsTable = parseOptionTable(doc.params);
|
|
175
174
|
if (queryTable.split("\n").length > 1) {
|
|
176
|
-
queryTable = `### query${q && q.description ? ` (${q.description})` : ""}\n\n${queryTable}`;
|
|
175
|
+
queryTable = `### query${typeof q !== "boolean" && typeof q !== "string" && q && q.description ? ` (${q.description})` : ""}\n\n${queryTable}`;
|
|
177
176
|
}
|
|
178
177
|
else {
|
|
179
|
-
queryTable = queryTable === "" ? "" : `### query${q && q.description ? ` (${q.description})` : ""}: ${queryTable}`;
|
|
178
|
+
queryTable = queryTable === "" ? "" : `### query${typeof q !== "boolean" && typeof q !== "string" && q && q.description ? ` (${q.description})` : ""}: ${queryTable}`;
|
|
180
179
|
}
|
|
181
180
|
if (queryTable !== "") {
|
|
182
181
|
queryTables.push(queryTable);
|
|
@@ -190,29 +189,29 @@ const main = () => {
|
|
|
190
189
|
const body = doc.body instanceof Array ? doc.body : [doc.body];
|
|
191
190
|
const bodyTables = [];
|
|
192
191
|
for (const b of body) {
|
|
193
|
-
let bodyTable = parseOptionTable(b);
|
|
192
|
+
let bodyTable = typeof b === "string" ? `${b}` : parseOptionTable(b);
|
|
194
193
|
if (bodyTable.split("\n").length > 1) {
|
|
195
|
-
bodyTable = `### body${b && b.description ? ` (${b.description})` : ""}\n\n${bodyTable}`;
|
|
194
|
+
bodyTable = `### body${typeof b !== "boolean" && typeof b !== "string" && b && b.description ? ` (${b.description})` : ""}\n\n${bodyTable}`;
|
|
196
195
|
}
|
|
197
196
|
else {
|
|
198
|
-
bodyTable = bodyTable === "" ? "" : `### body${b && b.description ? ` (${b.description})` : ""}: ${bodyTable}`;
|
|
197
|
+
bodyTable = bodyTable === "" ? "" : `### body${typeof b !== "boolean" && typeof b !== "string" && b && b.description ? ` (${b.description})` : ""}: ${bodyTable}`;
|
|
199
198
|
}
|
|
200
199
|
if (bodyTable !== "") {
|
|
201
200
|
bodyTables.push(bodyTable);
|
|
202
201
|
}
|
|
203
202
|
}
|
|
204
|
-
const results = doc.
|
|
203
|
+
const results = doc.response instanceof Array ? doc.response : [doc.response];
|
|
205
204
|
const resultTables = [];
|
|
206
205
|
for (const r of results) {
|
|
207
206
|
if (!r) {
|
|
208
207
|
continue;
|
|
209
208
|
}
|
|
210
|
-
let resultsTable =
|
|
209
|
+
let resultsTable = r && typeof r !== "string" && typeof r !== "boolean" ? parseOptionTable(r) : r;
|
|
211
210
|
if (resultsTable.split("\n").length > 1) {
|
|
212
|
-
resultsTable = `### response${r.description ? ` (${r.description})` : ""}\n\n${resultsTable}`;
|
|
211
|
+
resultsTable = `### response${typeof r !== "boolean" && typeof r !== "string" && r.description ? ` (${r.description})` : ""}\n\n${resultsTable}`;
|
|
213
212
|
}
|
|
214
213
|
else {
|
|
215
|
-
resultsTable = resultsTable === "" ? "" : `### response${r.description ? ` (${r.description})` : ""}: ${resultsTable}`;
|
|
214
|
+
resultsTable = resultsTable === "" ? "" : `### response${typeof r !== "boolean" && typeof r !== "string" && r.description ? ` (${r.description})` : ""}: ${resultsTable}`;
|
|
216
215
|
}
|
|
217
216
|
if (resultsTable !== "") {
|
|
218
217
|
resultTables.push(resultsTable);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const main: () => void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.main = void 0;
|
|
4
|
+
const core_1 = require("@miqro/core");
|
|
5
|
+
const main = () => {
|
|
6
|
+
if (process.argv.length <= 3 || process.argv.length > 5) {
|
|
7
|
+
throw new Error(`invalid number of args\nusage: [PORT=8080] npx miqro serve <directory> [path=/]`);
|
|
8
|
+
}
|
|
9
|
+
const directory = process.argv[3];
|
|
10
|
+
const path = process.argv[4] ? process.argv[4] : "/";
|
|
11
|
+
(0, core_1.loadConfig)();
|
|
12
|
+
const PORT = process.env.PORT ? process.env.PORT : 8080;
|
|
13
|
+
if (PORT === undefined) {
|
|
14
|
+
throw new Error("PORT env var not defined");
|
|
15
|
+
}
|
|
16
|
+
const app = new core_1.App();
|
|
17
|
+
app.use((0, core_1.LoggerHandler)());
|
|
18
|
+
app.use((0, core_1.Static)({
|
|
19
|
+
directory,
|
|
20
|
+
list: true
|
|
21
|
+
}), path);
|
|
22
|
+
app.listen(PORT, () => {
|
|
23
|
+
console.log("serving " + directory + " on " + path + " on port " + PORT);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
exports.main = main;
|
package/dist/utils/db/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const fs_1 = require("fs");
|
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const templates_1 = require("../../utils/templates");
|
|
8
8
|
const core_1 = require("@miqro/core");
|
|
9
|
+
const parser_1 = require("@miqro/parser");
|
|
9
10
|
const logger = console;
|
|
10
11
|
const loadSequelizeRC = (sequelizercPath = core_1.ConfigPathResolver.getSequelizeRCFilePath(), logger) => {
|
|
11
12
|
// noinspection SpellCheckingInspection
|
|
@@ -20,12 +21,12 @@ const loadSequelizeRC = (sequelizercPath = core_1.ConfigPathResolver.getSequeliz
|
|
|
20
21
|
// noinspection SpellCheckingInspection
|
|
21
22
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
22
23
|
const sequelizerc = require(sequelizercPath);
|
|
23
|
-
return (0,
|
|
24
|
+
return (0, parser_1.parse)(sequelizerc, [
|
|
24
25
|
{ name: "config", type: "string", required: true },
|
|
25
26
|
{ name: "migrations-path", type: "string", required: true },
|
|
26
27
|
{ name: "seeders-path", type: "string", required: true },
|
|
27
28
|
{ name: "models-path", type: "string", required: true }
|
|
28
|
-
], "no_extra");
|
|
29
|
+
], "no_extra", sequelizercPath);
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
exports.loadSequelizeRC = loadSequelizeRC;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GroupPolicy, Logger, Method, SessionHandlerOptions } from "@miqro/core";
|
|
2
|
+
import { ParseOptions } from "@miqro/parser";
|
|
2
3
|
export declare const getDOCJSON: ({ dirname, subPath }: {
|
|
3
4
|
dirname: string;
|
|
4
5
|
subPath: string;
|
|
@@ -9,9 +10,9 @@ export declare const getDOCJSON: ({ dirname, subPath }: {
|
|
|
9
10
|
policy?: GroupPolicy;
|
|
10
11
|
headers?: ParseOptions | ParseOptions[];
|
|
11
12
|
session?: false | true | SessionHandlerOptions;
|
|
12
|
-
params?:
|
|
13
|
-
query?:
|
|
14
|
-
body?:
|
|
15
|
-
|
|
13
|
+
params?: boolean | ParseOptions | ParseOptions[] | string;
|
|
14
|
+
query?: boolean | ParseOptions | ParseOptions[] | string;
|
|
15
|
+
body?: boolean | ParseOptions | ParseOptions[] | string;
|
|
16
|
+
response?: ParseOptions | ParseOptions[] | string;
|
|
16
17
|
featureName: string;
|
|
17
18
|
}[];
|
package/dist/utils/doc/index.js
CHANGED
|
@@ -8,8 +8,17 @@ const getDOCJSON = ({ dirname, subPath }, logger) => {
|
|
|
8
8
|
const apiTraverse = (0, api_router_utils_1.traverseAPIRouteDir)((0, path_1.basename)(dirname).toUpperCase(), (0, path_1.resolve)(core_1.ConfigPathResolver.getBaseDirname(), dirname), subPath, undefined, logger);
|
|
9
9
|
const docJSON = Object.keys(apiTraverse).map(featureName => {
|
|
10
10
|
const { path, method, options } = apiTraverse[featureName];
|
|
11
|
-
const { session, policy, description } = options ? options : {
|
|
12
|
-
|
|
11
|
+
const { session, policy, description } = options ? options : {
|
|
12
|
+
session: undefined,
|
|
13
|
+
policy: undefined,
|
|
14
|
+
description: undefined
|
|
15
|
+
};
|
|
16
|
+
const { params, query, body, headers } = options && options.request ? options.request : {
|
|
17
|
+
params: undefined,
|
|
18
|
+
query: undefined,
|
|
19
|
+
body: undefined,
|
|
20
|
+
headers: undefined
|
|
21
|
+
};
|
|
13
22
|
const result = options && options.response !== true ? options.response : undefined;
|
|
14
23
|
return {
|
|
15
24
|
path,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miqro",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"author": "claukers",
|
|
18
18
|
"license": "ISC",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@miqro/core": "^1.5.
|
|
20
|
+
"@miqro/core": "^1.5.4",
|
|
21
|
+
"@miqro/parser": "^0.0.2",
|
|
21
22
|
"@miqro/runner": "^1.2.4",
|
|
22
23
|
"@miqro/test": "^0.0.9",
|
|
23
24
|
"deep-diff": "1.0.2"
|