very-express 0.0.11 → 0.1.1
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/.env +2 -1
- package/.eslintrc.json +37 -0
- package/dist/cli.js +36 -33
- package/dist/generators/controller.template.d.ts +5 -4
- package/dist/generators/controller.template.js +191 -131
- package/dist/generators/controllers.generator.d.ts +6 -1
- package/dist/generators/controllers.generator.js +99 -77
- package/dist/generators/index.d.ts +3 -3
- package/dist/generators/openapi.generator.d.ts +5 -1
- package/dist/generators/openapi.generator.js +125 -121
- package/dist/generators/packageJson.generator.js +5 -12
- package/dist/generators/routes.generator.d.ts +10 -5
- package/dist/generators/routes.generator.js +6 -7
- package/dist/generators/routes.template.d.ts +4 -5
- package/dist/generators/routes.template.js +49 -27
- package/dist/generators/server.generator.d.ts +1 -1
- package/dist/generators/server.generator.js +9 -13
- package/dist/generators/server.template.d.ts +1 -2
- package/dist/generators/server.template.js +24 -25
- package/dist/index.d.ts +2 -2
- package/dist/index.js +45 -45
- package/dist/preprocess/jsonschemaFormat.d.ts +2 -0
- package/dist/preprocess/jsonschemaFormat.js +94 -0
- package/dist/templates/root/package.json +7 -4
- package/dist/templates/utils/common.gen.ts +42 -11
- package/dist/test.d.ts +1 -0
- package/dist/test.js +10 -0
- package/dist/types/controller.d.ts +0 -0
- package/dist/types/controller.js +1 -0
- package/dist/types/openapi.d.ts +21 -18
- package/dist/types/openapi.js +0 -24
- package/dist/types/types.d.ts +36 -21
- package/dist/types/types.js +3 -13
- package/dist/utils/common.d.ts +8 -6
- package/dist/utils/common.js +81 -35
- package/dist/utils/log.d.ts +1 -1
- package/dist/utils/log.js +5 -5
- package/package.json +60 -56
- package/vex.config.json +7 -0
package/dist/test.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const common_1 = __importDefault(require("./utils/common"));
|
|
7
|
+
const util_1 = __importDefault(require("util"));
|
|
8
|
+
const jsonSchema = common_1.default.loadJsonSchema("./output/jsonSchema/User.json");
|
|
9
|
+
const formattedSchema = common_1.default.cleanXcustomValue(jsonSchema.properties, { _id: "string", index: "boolean", unique: "boolean", required: "boolean" });
|
|
10
|
+
console.log(util_1.default.inspect(formattedSchema, { depth: null, colors: true }));
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/types/openapi.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as types from "./types";
|
|
2
1
|
export interface openapi {
|
|
3
2
|
openapi: string;
|
|
4
3
|
info: {
|
|
@@ -11,31 +10,30 @@ export interface openapi {
|
|
|
11
10
|
}
|
|
12
11
|
export interface paths {
|
|
13
12
|
[key: string]: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
"x-collection"?: string;
|
|
14
|
+
"x-interface"?: string;
|
|
15
|
+
summary?: string;
|
|
16
|
+
get?: method;
|
|
17
|
+
post?: method;
|
|
18
|
+
put?: method;
|
|
19
|
+
patch?: method;
|
|
20
|
+
delete?: method;
|
|
21
|
+
options?: method;
|
|
22
|
+
head?: method;
|
|
23
|
+
trace?: method;
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
export interface method {
|
|
27
|
-
summary
|
|
27
|
+
summary?: string;
|
|
28
28
|
operationId: string;
|
|
29
29
|
tags: string[];
|
|
30
30
|
parameters: parameter[];
|
|
31
31
|
requestBody?: requestBody;
|
|
32
|
-
responses:
|
|
33
|
-
[key: number]: responseItem;
|
|
34
|
-
};
|
|
32
|
+
responses: responses;
|
|
35
33
|
}
|
|
36
34
|
export interface parameter {
|
|
37
35
|
name: string;
|
|
38
|
-
in:
|
|
36
|
+
in: "query" | "header" | "path" | "cookie";
|
|
39
37
|
description?: string;
|
|
40
38
|
required?: boolean;
|
|
41
39
|
deprecated?: boolean;
|
|
@@ -46,6 +44,7 @@ export interface parameter {
|
|
|
46
44
|
schema: {
|
|
47
45
|
type: string;
|
|
48
46
|
format?: string;
|
|
47
|
+
"x-format"?: string;
|
|
49
48
|
required?: string[];
|
|
50
49
|
minLength?: number;
|
|
51
50
|
maxLength?: number;
|
|
@@ -60,17 +59,20 @@ export interface requestBody {
|
|
|
60
59
|
description: string;
|
|
61
60
|
required: boolean;
|
|
62
61
|
content?: {
|
|
63
|
-
|
|
62
|
+
"application/json": {
|
|
64
63
|
schema: {
|
|
65
64
|
$ref: string;
|
|
66
65
|
};
|
|
67
66
|
};
|
|
68
67
|
};
|
|
69
68
|
}
|
|
69
|
+
export interface responses {
|
|
70
|
+
[key: number]: responseItem;
|
|
71
|
+
}
|
|
70
72
|
export interface responseItem {
|
|
71
73
|
description: string;
|
|
72
74
|
content?: {
|
|
73
|
-
|
|
75
|
+
"application/json"?: {
|
|
74
76
|
schema: {
|
|
75
77
|
$ref?: string;
|
|
76
78
|
[key: string]: any;
|
|
@@ -86,6 +88,7 @@ export interface components {
|
|
|
86
88
|
export interface componentsSchemaValue {
|
|
87
89
|
type: string;
|
|
88
90
|
items?: any;
|
|
91
|
+
required?: string[];
|
|
89
92
|
properties?: {
|
|
90
93
|
[key: string]: fieldsItem;
|
|
91
94
|
};
|
package/dist/types/openapi.js
CHANGED
|
@@ -1,26 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const types = __importStar(require("./types"));
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,40 +1,55 @@
|
|
|
1
1
|
export interface compilerOptions {
|
|
2
|
+
jsonSchemaDir: string;
|
|
3
|
+
openapiDir: string;
|
|
4
|
+
rootDir: string;
|
|
5
|
+
srcDir: string;
|
|
2
6
|
headerComment?: string;
|
|
3
7
|
modelsTemplate?: string;
|
|
4
8
|
controllersTemplate?: string;
|
|
9
|
+
use_id?: boolean;
|
|
5
10
|
}
|
|
6
11
|
export interface jsonSchema {
|
|
7
12
|
type: string;
|
|
8
|
-
|
|
13
|
+
"x-documentConfig": documentConfig;
|
|
9
14
|
properties: {
|
|
10
|
-
[key: string]:
|
|
11
|
-
type: string;
|
|
12
|
-
format?: string;
|
|
13
|
-
index?: boolean;
|
|
14
|
-
required?: boolean;
|
|
15
|
-
description?: string;
|
|
16
|
-
example?: any;
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
};
|
|
15
|
+
[key: string]: jsonSchemaPropsItem;
|
|
19
16
|
};
|
|
20
17
|
required?: string[];
|
|
21
18
|
index?: string[];
|
|
22
19
|
[key: string]: any;
|
|
23
20
|
}
|
|
21
|
+
export interface jsonSchemaPropsItem {
|
|
22
|
+
type: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
format?: string;
|
|
25
|
+
properties?: {
|
|
26
|
+
[key: string]: jsonSchemaPropsItem;
|
|
27
|
+
};
|
|
28
|
+
items?: jsonSchemaPropsItem;
|
|
29
|
+
enum?: any[];
|
|
30
|
+
required?: boolean | string[];
|
|
31
|
+
index?: boolean;
|
|
32
|
+
example?: any;
|
|
33
|
+
"x-format"?: string;
|
|
34
|
+
minLength?: number;
|
|
35
|
+
maxLength?: number;
|
|
36
|
+
minimum?: number;
|
|
37
|
+
maximum?: number;
|
|
38
|
+
[key: string]: string | boolean | number | string[] | jsonSchemaPropsItem | {
|
|
39
|
+
[key: string]: jsonSchemaPropsItem;
|
|
40
|
+
} | any[] | undefined;
|
|
41
|
+
}
|
|
24
42
|
export interface documentConfig {
|
|
25
43
|
documentName: string;
|
|
26
|
-
documentType?:
|
|
44
|
+
documentType?: "primary" | "secondary";
|
|
27
45
|
interfaceName: string;
|
|
28
46
|
keyPrefix?: string;
|
|
29
|
-
methods:
|
|
47
|
+
methods: schemaMethod[];
|
|
30
48
|
}
|
|
31
|
-
export
|
|
32
|
-
|
|
33
|
-
post = "post",
|
|
34
|
-
put = "put",
|
|
35
|
-
patch = "patch",
|
|
36
|
-
delete = "delete",
|
|
37
|
-
options = "options",
|
|
38
|
-
head = "head",
|
|
39
|
-
trace = "trace"
|
|
49
|
+
export interface additionalKeyObj {
|
|
50
|
+
[key: string]: string;
|
|
40
51
|
}
|
|
52
|
+
export type schemaMethod = "get" | "getList" | "post" | "put" | "patch" | "delete" | "options" | "head" | "trace";
|
|
53
|
+
export declare const schemaMethodArr: schemaMethod[];
|
|
54
|
+
export type httpMethod = "get" | "post" | "put" | "patch" | "delete" | "options" | "head" | "trace";
|
|
55
|
+
export declare const httpMethodArr: httpMethod[];
|
package/dist/types/types.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
method["get"] = "get";
|
|
7
|
-
method["post"] = "post";
|
|
8
|
-
method["put"] = "put";
|
|
9
|
-
method["patch"] = "patch";
|
|
10
|
-
method["delete"] = "delete";
|
|
11
|
-
method["options"] = "options";
|
|
12
|
-
method["head"] = "head";
|
|
13
|
-
method["trace"] = "trace";
|
|
14
|
-
})(method || (exports.method = method = {}));
|
|
15
|
-
;
|
|
3
|
+
exports.httpMethodArr = exports.schemaMethodArr = void 0;
|
|
4
|
+
exports.schemaMethodArr = ["get", "getList", "post", "put", "patch", "delete", "options", "head", "trace"];
|
|
5
|
+
exports.httpMethodArr = ["get", "post", "put", "patch", "delete", "options", "head", "trace"];
|
package/dist/utils/common.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as types from "../types/types";
|
|
2
2
|
export declare const relativePath: (fromPath: string, toPath: string) => string;
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function loadJsonSchema(jsonSchemaPath: string): types.jsonSchema | never;
|
|
4
4
|
export declare function getGenaratorHeaderComment(comment?: string): string;
|
|
5
5
|
export declare function getSimpleHeaderComment(): string;
|
|
6
6
|
export declare function cleanXcustomValue(schemaObj: {
|
|
7
7
|
[key: string]: any;
|
|
8
|
-
}, additionalKeyArr?: string[]): {
|
|
8
|
+
}, additionalKeyArr?: string[] | types.additionalKeyObj): {
|
|
9
9
|
[key: string]: any;
|
|
10
10
|
};
|
|
11
|
+
export declare function httpMethod(jsonSchemaMethod: string, documentName: string): types.httpMethod;
|
|
11
12
|
export declare function copyDir(source: string, destination: string): void;
|
|
12
|
-
export declare const defaultCompilerOptions: compilerOptions;
|
|
13
|
+
export declare const defaultCompilerOptions: types.compilerOptions;
|
|
13
14
|
declare const _default: {
|
|
15
|
+
defaultCompilerOptions: types.compilerOptions;
|
|
14
16
|
getGenaratorHeaderComment: typeof getGenaratorHeaderComment;
|
|
15
17
|
getSimpleHeaderComment: typeof getSimpleHeaderComment;
|
|
16
|
-
defaultCompilerOptions: compilerOptions;
|
|
17
18
|
relativePath: (fromPath: string, toPath: string) => string;
|
|
18
19
|
cleanXcustomValue: typeof cleanXcustomValue;
|
|
19
|
-
|
|
20
|
+
httpMethod: typeof httpMethod;
|
|
21
|
+
loadJsonSchema: typeof loadJsonSchema;
|
|
20
22
|
copyDir: typeof copyDir;
|
|
21
23
|
};
|
|
22
24
|
export default _default;
|
package/dist/utils/common.js
CHANGED
|
@@ -1,110 +1,156 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.defaultCompilerOptions = exports.copyDir = exports.cleanXcustomValue = exports.getSimpleHeaderComment = exports.getGenaratorHeaderComment = exports.
|
|
29
|
+
exports.defaultCompilerOptions = exports.copyDir = exports.httpMethod = exports.cleanXcustomValue = exports.getSimpleHeaderComment = exports.getGenaratorHeaderComment = exports.loadJsonSchema = exports.relativePath = void 0;
|
|
7
30
|
const fs_1 = __importDefault(require("fs"));
|
|
8
31
|
const path_1 = __importDefault(require("path"));
|
|
9
32
|
const child_process_1 = __importDefault(require("child_process"));
|
|
10
|
-
const
|
|
33
|
+
const types = __importStar(require("../types/types"));
|
|
11
34
|
const log_1 = __importDefault(require("./log"));
|
|
12
35
|
function getPackageInfo() {
|
|
13
36
|
let globalPackages = {};
|
|
14
37
|
try {
|
|
15
|
-
globalPackages = JSON.parse(child_process_1.default.execSync(
|
|
38
|
+
globalPackages = JSON.parse(child_process_1.default.execSync("npm -g list --json").toString());
|
|
16
39
|
}
|
|
17
40
|
catch (error) {
|
|
18
|
-
log_1.default.error(
|
|
41
|
+
log_1.default.error("Failed to execute command: npm -g list --json", error);
|
|
19
42
|
}
|
|
20
43
|
return {
|
|
21
|
-
version: globalPackages.dependencies[
|
|
44
|
+
version: globalPackages.dependencies["very-express"].version || "[unknown version]",
|
|
22
45
|
author: globalPackages.author || "justin26l",
|
|
23
46
|
};
|
|
24
47
|
}
|
|
25
48
|
const relativePath = (fromPath, toPath) => {
|
|
26
|
-
return path_1.default.relative(fromPath, toPath).replace(/\\/g,
|
|
49
|
+
return path_1.default.relative(fromPath, toPath).replace(/\\/g, "/");
|
|
27
50
|
};
|
|
28
51
|
exports.relativePath = relativePath;
|
|
29
|
-
function
|
|
52
|
+
function loadJsonSchema(jsonSchemaPath) {
|
|
53
|
+
if (!fs_1.default.existsSync(jsonSchemaPath)) {
|
|
54
|
+
return log_1.default.error(`loadJsonSchema : File Not Found ${jsonSchemaPath}`);
|
|
55
|
+
}
|
|
30
56
|
try {
|
|
31
|
-
|
|
57
|
+
return JSON.parse(fs_1.default.readFileSync(jsonSchemaPath, "utf8"));
|
|
32
58
|
}
|
|
33
59
|
catch (e) {
|
|
34
|
-
log_1.default.error(
|
|
60
|
+
return log_1.default.error("Error Load JsonSchema File :\n", e.message || e, jsonSchemaPath);
|
|
35
61
|
}
|
|
36
62
|
}
|
|
37
|
-
exports.
|
|
38
|
-
;
|
|
63
|
+
exports.loadJsonSchema = loadJsonSchema;
|
|
39
64
|
function getGenaratorHeaderComment(comment) {
|
|
40
65
|
const packageInfo = getPackageInfo();
|
|
41
|
-
return `/* eslint-disable */
|
|
42
|
-
/**
|
|
43
|
-
* Generated by veryExpress@${packageInfo.version}
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* author: ${packageInfo.author}
|
|
48
|
-
* version: ${packageInfo.version}${comment ? `\n * comment: ${comment}` :
|
|
49
|
-
*/
|
|
66
|
+
return `/* eslint-disable */
|
|
67
|
+
/**
|
|
68
|
+
* Generated by veryExpress@${packageInfo.version}
|
|
69
|
+
* We recommend not to modified it manually because it will be overwrite.
|
|
70
|
+
* we suggest to modified the jsonSchema then regenerate the project .
|
|
71
|
+
*
|
|
72
|
+
* author: ${packageInfo.author}
|
|
73
|
+
* version: ${packageInfo.version}${comment ? `\n * comment: ${comment}` : ""}
|
|
74
|
+
*/
|
|
50
75
|
`;
|
|
51
76
|
}
|
|
52
77
|
exports.getGenaratorHeaderComment = getGenaratorHeaderComment;
|
|
53
|
-
;
|
|
54
78
|
function getSimpleHeaderComment() {
|
|
55
79
|
const packageInfo = getPackageInfo();
|
|
56
80
|
return `// Generated by veryExpress@${packageInfo.version}`;
|
|
57
81
|
}
|
|
58
82
|
exports.getSimpleHeaderComment = getSimpleHeaderComment;
|
|
59
|
-
;
|
|
60
83
|
function cleanXcustomValue(schemaObj, additionalKeyArr) {
|
|
61
|
-
|
|
84
|
+
const obj = JSON.parse(JSON.stringify(schemaObj));
|
|
85
|
+
const isAddiArrStr = Array.isArray(additionalKeyArr);
|
|
86
|
+
const addiArrStr = isAddiArrStr ? additionalKeyArr : [];
|
|
87
|
+
const addiArrObj = !isAddiArrStr ? additionalKeyArr : {};
|
|
62
88
|
for (const key in obj) {
|
|
63
89
|
if (key.startsWith("x-")) {
|
|
64
90
|
delete obj[key];
|
|
65
91
|
}
|
|
66
|
-
else if (
|
|
92
|
+
else if (isAddiArrStr && addiArrStr.includes(key)) {
|
|
93
|
+
delete obj[key];
|
|
94
|
+
}
|
|
95
|
+
else if (!isAddiArrStr && typeof addiArrObj[key] !== "undefined" && addiArrObj[key] == typeof obj[key]) {
|
|
67
96
|
delete obj[key];
|
|
68
97
|
}
|
|
69
98
|
else if (typeof obj[key] === "object") {
|
|
70
|
-
cleanXcustomValue(obj[key], additionalKeyArr);
|
|
99
|
+
obj[key] = cleanXcustomValue(obj[key], additionalKeyArr);
|
|
71
100
|
}
|
|
72
101
|
}
|
|
73
102
|
return obj;
|
|
74
103
|
}
|
|
75
104
|
exports.cleanXcustomValue = cleanXcustomValue;
|
|
76
|
-
|
|
105
|
+
function httpMethod(jsonSchemaMethod, documentName) {
|
|
106
|
+
if (jsonSchemaMethod == "getList") {
|
|
107
|
+
return "get";
|
|
108
|
+
}
|
|
109
|
+
else if (types.httpMethodArr.includes(jsonSchemaMethod)) {
|
|
110
|
+
return jsonSchemaMethod;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
log_1.default.error(`httpMethod : invalid method "${jsonSchemaMethod}" in "${documentName}".`);
|
|
114
|
+
process.exit(1);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.httpMethod = httpMethod;
|
|
77
118
|
function copyDir(source, destination) {
|
|
78
119
|
if (!fs_1.default.existsSync(destination)) {
|
|
79
120
|
fs_1.default.mkdirSync(destination);
|
|
80
121
|
}
|
|
81
122
|
const files = fs_1.default.readdirSync(source);
|
|
82
123
|
for (let i = 0; i < files.length; i++) {
|
|
83
|
-
const current = fs_1.default.lstatSync(source +
|
|
124
|
+
const current = fs_1.default.lstatSync(source + "/" + files[i]);
|
|
84
125
|
if (current.isDirectory()) {
|
|
85
|
-
copyDir(source +
|
|
126
|
+
copyDir(source + "/" + files[i], destination + "/" + files[i]);
|
|
86
127
|
}
|
|
87
128
|
else if (current.isSymbolicLink()) {
|
|
88
|
-
const symlink = fs_1.default.readlinkSync(source +
|
|
89
|
-
fs_1.default.symlinkSync(symlink, destination +
|
|
129
|
+
const symlink = fs_1.default.readlinkSync(source + "/" + files[i]);
|
|
130
|
+
fs_1.default.symlinkSync(symlink, destination + "/" + files[i]);
|
|
90
131
|
}
|
|
91
132
|
else {
|
|
92
|
-
const outPath = destination +
|
|
93
|
-
log_1.default.writing(
|
|
94
|
-
fs_1.default.copyFileSync(source +
|
|
133
|
+
const outPath = destination + "/" + files[i];
|
|
134
|
+
log_1.default.writing(outPath);
|
|
135
|
+
fs_1.default.copyFileSync(source + "/" + files[i], outPath);
|
|
95
136
|
}
|
|
96
137
|
}
|
|
97
138
|
}
|
|
98
139
|
exports.copyDir = copyDir;
|
|
99
140
|
exports.defaultCompilerOptions = {
|
|
100
141
|
headerComment: getGenaratorHeaderComment(),
|
|
142
|
+
rootDir: ".",
|
|
143
|
+
srcDir: "./src",
|
|
144
|
+
jsonSchemaDir: "./jsonSchema",
|
|
145
|
+
openapiDir: "./openapi",
|
|
101
146
|
};
|
|
102
147
|
exports.default = {
|
|
148
|
+
defaultCompilerOptions: exports.defaultCompilerOptions,
|
|
103
149
|
getGenaratorHeaderComment,
|
|
104
150
|
getSimpleHeaderComment,
|
|
105
|
-
defaultCompilerOptions: exports.defaultCompilerOptions,
|
|
106
151
|
relativePath: exports.relativePath,
|
|
107
152
|
cleanXcustomValue,
|
|
108
|
-
|
|
153
|
+
httpMethod,
|
|
154
|
+
loadJsonSchema,
|
|
109
155
|
copyDir,
|
|
110
156
|
};
|
package/dist/utils/log.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export declare function processing(msg: any, ...optionalParams: any[]): void;
|
|
|
2
2
|
export declare function writing(msg: any, ...optionalParams: any[]): void;
|
|
3
3
|
export declare function info(msg: any, ...optionalParams: any[]): void;
|
|
4
4
|
export declare function warn(msg: any, ...optionalParams: any[]): void;
|
|
5
|
-
export declare function error(msg: any, ...optionalParams: any[]):
|
|
5
|
+
export declare function error(msg: any, ...optionalParams: any[]): never;
|
|
6
6
|
declare const _default: {
|
|
7
7
|
process: typeof processing;
|
|
8
8
|
writing: typeof writing;
|
package/dist/utils/log.js
CHANGED
|
@@ -2,23 +2,23 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.error = exports.warn = exports.info = exports.writing = exports.processing = void 0;
|
|
4
4
|
function processing(msg, ...optionalParams) {
|
|
5
|
-
console.log(
|
|
5
|
+
console.log("\x1b[34m%s\x1b[0m", "[PROCESSING]", msg, optionalParams.length > 0 ? optionalParams : "");
|
|
6
6
|
}
|
|
7
7
|
exports.processing = processing;
|
|
8
8
|
function writing(msg, ...optionalParams) {
|
|
9
|
-
console.log(
|
|
9
|
+
console.log("\x1b[32m%s\x1b[0m", "[WRITING]", msg, optionalParams.length > 0 ? optionalParams : "");
|
|
10
10
|
}
|
|
11
11
|
exports.writing = writing;
|
|
12
12
|
function info(msg, ...optionalParams) {
|
|
13
|
-
console.log(
|
|
13
|
+
console.log("\x1b[36m%s\x1b[0m", "[INFO]", msg, optionalParams.length > 0 ? optionalParams : "");
|
|
14
14
|
}
|
|
15
15
|
exports.info = info;
|
|
16
16
|
function warn(msg, ...optionalParams) {
|
|
17
|
-
console.log(
|
|
17
|
+
console.log("\x1b[33m%s\x1b[0m", "[WARN]", msg, optionalParams.length > 0 ? optionalParams : "");
|
|
18
18
|
}
|
|
19
19
|
exports.warn = warn;
|
|
20
20
|
function error(msg, ...optionalParams) {
|
|
21
|
-
console.log(
|
|
21
|
+
console.log("\x1b[41m%s\x1b[0m", "[ERROR]", msg, optionalParams.length > 0 ? optionalParams : "");
|
|
22
22
|
process.exit(1);
|
|
23
23
|
}
|
|
24
24
|
exports.error = error;
|
package/package.json
CHANGED
|
@@ -1,58 +1,62 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
2
|
+
"name": "very-express",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
|
|
5
|
+
"author": "justin26l",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"vex": "./dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "npm run test && tsc -p . && node ./src/copyDir.js",
|
|
13
|
+
"dev": "ts-node ./src/cli.ts -j ./output/jsonSchema -a ./output/openapi -o ./output -s ./output/src",
|
|
14
|
+
"prod": "node ./dist/cli.js",
|
|
15
|
+
"test": "eslint ./src --ext .ts --fix",
|
|
16
|
+
"vexgen": "vex -j ./output/jsonSchema -a ./output/openapi -o ./output/src",
|
|
17
|
+
"start": "node ./dist/server.js"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"jsonSchema",
|
|
21
|
+
"express",
|
|
22
|
+
"RestApi",
|
|
23
|
+
"mongoDb",
|
|
24
|
+
"mongoose",
|
|
25
|
+
"json2mongoose"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/Justin26l/VeryExpress.git"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"express-session": "^1.17.3",
|
|
33
|
+
"js-yaml": "4.1.0",
|
|
34
|
+
"json-schema-to-openapi-schema": "^0.4.0",
|
|
35
|
+
"minimist": "^1.2.8"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/express": "^4.17.21",
|
|
39
|
+
"@types/express-session": "^1.17.10",
|
|
40
|
+
"@types/js-yaml": "^4.0.9",
|
|
41
|
+
"@types/minimist": "^1.2.5",
|
|
42
|
+
"@types/node": "^20.10.5",
|
|
43
|
+
"@types/passport": "^1.0.16",
|
|
44
|
+
"@types/passport-google-oauth20": "^2.0.14",
|
|
45
|
+
"@types/swagger-ui-express": "^4.1.6",
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
47
|
+
"@typescript-eslint/parser": "^6.18.1",
|
|
48
|
+
"dotenv": "^16.3.1",
|
|
49
|
+
"eslint": "^8.56.0",
|
|
50
|
+
"express": "^4.18.2",
|
|
51
|
+
"express-validator": "^7.0.1",
|
|
52
|
+
"helmet": "^7.1.0",
|
|
53
|
+
"js-yaml": "^4.1.0",
|
|
54
|
+
"json-schema-to-openapi-schema": "^0.4.0",
|
|
55
|
+
"json2mongoose": "^0.2.1",
|
|
56
|
+
"passport": "^0.7.0",
|
|
57
|
+
"passport-google-oauth20": "^2.0.0",
|
|
58
|
+
"swagger-ui-express": "^5.0.0",
|
|
59
|
+
"ts-node": "^10.9.2",
|
|
60
|
+
"typescript": "^5.3.3"
|
|
61
|
+
}
|
|
58
62
|
}
|