very-express 0.4.9 → 0.4.11

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 (53) hide show
  1. package/README.md +8 -0
  2. package/dist/index.js +1144 -734
  3. package/dist/templates/_controller/_ControllerFactory.ts +7 -0
  4. package/dist/templates/_controllers/_ControllerFactory.ts +9 -0
  5. package/dist/templates/_plugins/PassportGoogle.ts +3 -6
  6. package/dist/templates/_services/VexDbConnector.ts +3 -3
  7. package/dist/templates/_utils/index.ts +2 -0
  8. package/dist/templates/_utils/logger.ts +8 -3
  9. package/dist/templates/_utils/validator.ts +7 -0
  10. package/dist/templates/root/README.md +33 -0
  11. package/docs/developmentNote.md +11 -4
  12. package/docs/vexJsonSchema.md +30 -16
  13. package/package.json +9 -15
  14. package/scripts/build.js +14 -0
  15. package/scripts/copyTsTemplates.js +24 -0
  16. package/dist/_plugins/PassportGoogle.ts +0 -87
  17. package/dist/_plugins/oauthVerify.ts +0 -39
  18. package/dist/_roles/_RoleFactory.ts +0 -22
  19. package/dist/_services/VexDbConnector.ts +0 -70
  20. package/dist/_types/responseMsg.ts +0 -20
  21. package/dist/_utils/common.ts +0 -53
  22. package/dist/_utils/index.ts +0 -11
  23. package/dist/_utils/logger.ts +0 -50
  24. package/dist/_utils/response.ts +0 -27
  25. package/dist/cli.d.ts +0 -1
  26. package/dist/generators/app/openapi.generator.d.ts +0 -3
  27. package/dist/generators/app/server.generator.d.ts +0 -2
  28. package/dist/generators/app/server.template.d.ts +0 -5
  29. package/dist/generators/controller/controller.template.d.ts +0 -14
  30. package/dist/generators/controller/controllers.generator.d.ts +0 -7
  31. package/dist/generators/index.d.ts +0 -9
  32. package/dist/generators/middlewares/RBACmiddleware.generator.d.ts +0 -6
  33. package/dist/generators/middlewares/RBACmiddlewares.template.d.ts +0 -6
  34. package/dist/generators/project/packageJson.generator.d.ts +0 -6
  35. package/dist/generators/project/userSchema.generator.d.ts +0 -4
  36. package/dist/generators/role/role.generator.d.ts +0 -8
  37. package/dist/generators/role/role.template.d.ts +0 -8
  38. package/dist/generators/routes/oauth.generator.d.ts +0 -2
  39. package/dist/generators/routes/routes.generator.d.ts +0 -11
  40. package/dist/generators/routes/routes.template.d.ts +0 -11
  41. package/dist/generators/routes/swagger.generator.d.ts +0 -2
  42. package/dist/index.d.ts +0 -2
  43. package/dist/preprocess/jsonschemaFormat.d.ts +0 -2
  44. package/dist/preprocess/roleSetupFile.d.ts +0 -9
  45. package/dist/templates/_roles/_RoleFactory.d.ts +0 -10
  46. package/dist/types/openapi.d.ts +0 -108
  47. package/dist/types/types.d.ts +0 -75
  48. package/dist/utils/common.d.ts +0 -13
  49. package/dist/utils/configChecker.d.ts +0 -6
  50. package/dist/utils/generator.d.ts +0 -12
  51. package/dist/utils/index.d.ts +0 -30
  52. package/dist/utils/jsonSchema.d.ts +0 -14
  53. package/dist/utils/logger.d.ts +0 -13
@@ -1,50 +0,0 @@
1
- export function processing(msg: any, ...optionalParams: any[]): void {
2
- console.log("\x1b[34m%s\x1b[0m", "[PROCESSING]", msg, optionalParams.length > 0 ? optionalParams : "");
3
- }
4
-
5
- export function ok(msg: any, ...optionalParams: any[]): void {
6
- console.log("\x1b[32m%s\x1b[0m", "[OK]", msg, optionalParams.length > 0 ? optionalParams : "");
7
- }
8
-
9
- export function info(msg: any, ...optionalParams: any[]): void {
10
- console.log("\x1b[36m%s\x1b[0m", "[INFO]", msg, optionalParams.length > 0 ? optionalParams : "");
11
- }
12
-
13
- export function warn(msg: any, ...optionalParams: any[]): void {
14
- console.log("\x1b[33m%s\x1b[0m", "[WARN]", msg, optionalParams.length > 0 ? optionalParams : "");
15
- }
16
-
17
- export function error(msg: any, ...optionalParams: any[]): never {
18
- console.log("\x1b[41m%s\x1b[0m", "[ERROR]", msg, optionalParams.length > 0 ? optionalParams : "");
19
- process.exit(1);
20
- }
21
-
22
- // wrapper
23
- export function infoMongo(msg: any, ...optionalParams: any[]): void {
24
- info("[MONGO]", msg, optionalParams);
25
- }
26
-
27
- export function errorMongo(msg: any, ...optionalParams: any[]): never {
28
- error("[MONGO]", msg, optionalParams);
29
- }
30
-
31
- export function infoSql(msg: any, ...optionalParams: any[]): void {
32
- info("[SQL]", msg, optionalParams);
33
- }
34
-
35
- export function errorSql(msg: any, ...optionalParams: any[]): never {
36
- error("[SQL]", msg, optionalParams);
37
- }
38
-
39
- export default {
40
- process : processing,
41
- ok,
42
- info,
43
- warn,
44
- error,
45
-
46
- infoMongo,
47
- errorMongo,
48
- infoSql,
49
- errorSql,
50
- };
@@ -1,27 +0,0 @@
1
- import { Response } from "express";
2
- // import { responseObject } from "./../_types/responseMsg.gen";
3
-
4
- /**
5
- * @param res express response object
6
- * @param code http status
7
- * @param message response data message
8
- * @param result response data result
9
- * @returns express response object
10
- */
11
- export function send<T = undefined>(
12
- res: Response,
13
- code: number = 200,
14
- message: string = "OK",
15
- result?: T,
16
- ): Response<any, Record<string, any>> {
17
- return res.status(code).json({
18
- ret_code: code,
19
- ret_msg: message,
20
- ret_time: new Date().getTime(),
21
- result: result,
22
- });
23
- }
24
-
25
- export default {
26
- send
27
- };
package/dist/cli.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import * as types from "./../../types/types";
2
- export declare function compile(openapiOutFileName: string, compilerOptions: types.compilerOptions): Promise<void>;
3
- export default compile;
@@ -1,2 +0,0 @@
1
- import * as types from "../../types/types";
2
- export declare function compile(compilerOptions: types.compilerOptions): Promise<void>;
@@ -1,5 +0,0 @@
1
- import * as types from "../../types/types";
2
- export default function serverTemplate(options: {
3
- compilerOptions: types.compilerOptions;
4
- template?: string;
5
- }): string;
@@ -1,14 +0,0 @@
1
- import * as types from "../../types/types";
2
- import { Schema } from "express-validator";
3
- export default function controllerTemplate(templateOptions: {
4
- template?: string;
5
- endpoint: string;
6
- modelPath: string;
7
- documentName: string;
8
- validators: {
9
- [key: string]: {
10
- [key: string]: Schema;
11
- };
12
- };
13
- compilerOptions: types.compilerOptions;
14
- }): string;
@@ -1,7 +0,0 @@
1
- import * as types from "./../../types/types";
2
- export declare function compile(options: {
3
- openapiFile: string;
4
- controllerOutDir: string;
5
- modelDir: string;
6
- compilerOptions: types.compilerOptions;
7
- }): Promise<void>;
@@ -1,9 +0,0 @@
1
- import controllerTemplate from "./controller/controller.template";
2
- import routesTemplate from "./routes/routes.template";
3
- import serverTemplate from "./app/server.template";
4
- declare const _default: {
5
- controllerTemplate: typeof controllerTemplate;
6
- routesTemplate: typeof routesTemplate;
7
- serverTemplate: typeof serverTemplate;
8
- };
9
- export default _default;
@@ -1,6 +0,0 @@
1
- import * as types from "../../types/types";
2
- export declare function compile(options: {
3
- middlewareDir: string;
4
- roleTypes: string;
5
- compilerOptions: types.compilerOptions;
6
- }): Promise<void>;
@@ -1,6 +0,0 @@
1
- import * as types from "../../types/types";
2
- export default function RBACmiddlewareTemplate(options: {
3
- template?: string;
4
- roleTypes: string;
5
- compilerOptions: types.compilerOptions;
6
- }): string;
@@ -1,6 +0,0 @@
1
- import * as types from "./../../types/types";
2
- export declare function compile(packageOutPath: string, compilerOptions: types.compilerOptions): Promise<void>;
3
- declare const _default: {
4
- compile: typeof compile;
5
- };
6
- export default _default;
@@ -1,4 +0,0 @@
1
- import * as types from "./../../types/types";
2
- export declare function compile(options: {
3
- compilerOptions: types.compilerOptions;
4
- }): Promise<void>;
@@ -1,8 +0,0 @@
1
- import * as types from "../../types/types";
2
- export declare function compile(options: {
3
- collectionList: string[];
4
- roleSourceDir: string;
5
- roleOutDir: string;
6
- middlewareDir: string;
7
- compilerOptions: types.compilerOptions;
8
- }): Promise<void>;
@@ -1,8 +0,0 @@
1
- import * as types from "../../types/types";
2
- export default function RBACmiddlewareTemplate(options: {
3
- template?: string;
4
- role: string;
5
- roleContent: any;
6
- RoleAccessActionString: string[];
7
- compilerOptions: types.compilerOptions;
8
- }): string;
@@ -1,2 +0,0 @@
1
- import * as types from "../../types/types";
2
- export declare function compile(compilerOptions: types.compilerOptions): string;
@@ -1,11 +0,0 @@
1
- import * as types from "./../../types/types";
2
- export declare function compile(options: {
3
- routesArr: {
4
- route: string;
5
- documentName: string;
6
- controllerPath: string;
7
- }[];
8
- routesDir: string;
9
- openapiFile: string;
10
- compilerOptions: types.compilerOptions;
11
- }): Promise<void>;
@@ -1,11 +0,0 @@
1
- import * as types from "../../types/types";
2
- export default function routesTemplate(options: {
3
- template?: string;
4
- openapiFile?: string;
5
- routes: {
6
- route: string;
7
- documentName: string;
8
- controllerPath: string;
9
- }[];
10
- compilerOptions: types.compilerOptions;
11
- }): string;
@@ -1,2 +0,0 @@
1
- import * as types from "../../types/types";
2
- export declare function compile(compilerOptions: types.compilerOptions): string;
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import * as types from "./types/types";
2
- export declare function generate(options: types.compilerOptions): Promise<void>;
@@ -1,2 +0,0 @@
1
- import * as types from "./../types/types";
2
- export declare function formatJsonSchema(jsonSchemaPath: string, compilerOptions: types.compilerOptions): types.jsonSchema;
@@ -1,9 +0,0 @@
1
- import * as types from "./../types/types";
2
- export declare function roleSetupFile(options: {
3
- collectionList: string[];
4
- roleSetupDir: string;
5
- compilerOptions: types.compilerOptions;
6
- }): void;
7
- export declare function roleSchemaFormat(options: {
8
- compilerOptions: types.compilerOptions;
9
- }): void;
@@ -1,10 +0,0 @@
1
- export type accessAction = "create" | "read" | "update" | "delete" | "search";
2
- export declare const accessActionArr: accessAction[];
3
- export interface accessControl<T = accessAction> {
4
- [key: string]: T[];
5
- }
6
- export declare class _RoleFactory<T = accessAction> {
7
- private accessControl;
8
- constructor(accessControl: accessControl<T>);
9
- checkAccess(document: string, access: string): boolean;
10
- }
@@ -1,108 +0,0 @@
1
- export interface openapi {
2
- openapi: string;
3
- info: {
4
- title: string;
5
- description: string;
6
- version: string;
7
- };
8
- paths: paths;
9
- components: components;
10
- }
11
- export interface paths {
12
- [key: string]: {
13
- "x-collection"?: string;
14
- "x-documentName"?: 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
- };
25
- }
26
- export interface method {
27
- summary?: string;
28
- operationId: string;
29
- tags: string[];
30
- parameters: parameter[];
31
- requestBody?: requestBody;
32
- responses: responses;
33
- }
34
- export interface parameter {
35
- name: string;
36
- in: "query" | "header" | "path" | "cookie";
37
- description?: string;
38
- required?: boolean;
39
- deprecated?: boolean;
40
- allowEmptyValue?: boolean;
41
- style?: string;
42
- explode?: boolean;
43
- allowReserved?: boolean;
44
- schema: {
45
- type: string;
46
- format?: string;
47
- "x-format"?: string;
48
- required?: string[];
49
- minLength?: number;
50
- maxLength?: number;
51
- minimum?: number;
52
- maximum?: number;
53
- enum?: string[];
54
- };
55
- example?: any;
56
- examples?: any;
57
- }
58
- export interface requestBody {
59
- description: string;
60
- required: boolean;
61
- content?: {
62
- "application/json": {
63
- schema: {
64
- $ref: string;
65
- };
66
- };
67
- };
68
- }
69
- export interface responses {
70
- [key: number]: responseItem;
71
- }
72
- export interface responseItem {
73
- description: string;
74
- content?: {
75
- "application/json"?: {
76
- schema: {
77
- $ref?: string;
78
- [key: string]: any;
79
- };
80
- };
81
- };
82
- }
83
- export interface components {
84
- schemas: {
85
- [key: string]: componentsSchemaValue;
86
- };
87
- }
88
- export interface componentsSchemaValue {
89
- type: string;
90
- items?: any;
91
- required?: string[];
92
- properties?: {
93
- [key: string]: fieldsItem;
94
- };
95
- }
96
- export interface fieldsItem {
97
- type: string;
98
- format?: string;
99
- minimum?: number;
100
- maximum?: number;
101
- minLength?: number;
102
- maxLength?: number;
103
- maxItems?: number;
104
- maxProperties?: number;
105
- uniqueItems?: boolean;
106
- enum?: string[];
107
- [key: string]: any;
108
- }
@@ -1,75 +0,0 @@
1
- export interface compilerOptions {
2
- commitBeforeGenerate: boolean;
3
- headerComment: string;
4
- jsonSchemaDir: string;
5
- openapiDir: string;
6
- rootDir: string;
7
- srcDir: string;
8
- sysDir: string;
9
- writtedDir: string[];
10
- app: {
11
- enableSwagger: boolean;
12
- useUserSchema: boolean;
13
- useObjectID: boolean;
14
- allowApiCreateUpdate_id: boolean;
15
- };
16
- useRBAC?: {
17
- roles: string[];
18
- default: string;
19
- schemaIncluded: string[];
20
- };
21
- useOauth?: {
22
- google?: boolean;
23
- microsoft?: boolean;
24
- apple?: boolean;
25
- github?: boolean;
26
- [key: string]: boolean | undefined;
27
- };
28
- }
29
- export interface roleJson {
30
- [key: string]: string[];
31
- }
32
- export interface jsonSchema {
33
- type: string;
34
- "x-documentConfig": documentConfig;
35
- properties: {
36
- [key: string]: jsonSchemaPropsItem;
37
- };
38
- required?: string[];
39
- index?: string[];
40
- [key: string]: any;
41
- }
42
- export interface jsonSchemaPropsItem {
43
- type: string;
44
- description?: string;
45
- format?: string;
46
- properties?: {
47
- [key: string]: jsonSchemaPropsItem;
48
- };
49
- items?: jsonSchemaPropsItem;
50
- enum?: any[];
51
- required?: boolean | string[];
52
- index?: boolean;
53
- example?: any;
54
- minLength?: number;
55
- maxLength?: number;
56
- minimum?: number;
57
- maximum?: number;
58
- "x-format"?: string;
59
- "x-vexData"?: string;
60
- [key: string]: string | boolean | number | string[] | jsonSchemaPropsItem | {
61
- [key: string]: jsonSchemaPropsItem;
62
- } | any[] | undefined;
63
- }
64
- export interface documentConfig {
65
- documentName: string;
66
- keyPrefix?: string;
67
- methods: schemaMethod[];
68
- }
69
- export interface additionalKeyObj {
70
- [key: string]: string;
71
- }
72
- export type schemaMethod = "get" | "getList" | "post" | "put" | "patch" | "delete" | "options" | "head" | "trace";
73
- export declare const schemaMethodArr: schemaMethod[];
74
- export type httpMethod = "get" | "post" | "put" | "patch" | "delete" | "options" | "head" | "trace";
75
- export declare const httpMethodArr: httpMethod[];
@@ -1,13 +0,0 @@
1
- import * as types from "../types/types";
2
- export declare const writtedFiles: string[];
3
- export declare const relativePath: (fromPath: string, toPath: string) => string;
4
- export declare function loadJson<T = any>(filePath: string, fileNotExistHandler?: () => T): T;
5
- export declare function writeFile(title: string, destination: string, newContent: string): boolean;
6
- export declare function copyDir(source: string, destination: string, compilerOptions: types.compilerOptions, overwrite?: boolean): void;
7
- declare const _default: {
8
- relativePath: (fromPath: string, toPath: string) => string;
9
- copyDir: typeof copyDir;
10
- loadJson: typeof loadJson;
11
- writeFile: typeof writeFile;
12
- };
13
- export default _default;
@@ -1,6 +0,0 @@
1
- import * as types from "~/types/types";
2
- export declare function checkConfigValid(options: types.compilerOptions): void;
3
- declare const _default: {
4
- checkConfigValid: typeof checkConfigValid;
5
- };
6
- export default _default;
@@ -1,12 +0,0 @@
1
- import * as types from "../types/types";
2
- export declare function getGenaratorHeaderComment(): string;
3
- export declare function getSimpleHeaderComment(): string;
4
- export declare function isUseOAuth(compilerOptions: types.compilerOptions): string[];
5
- export declare const defaultCompilerOptions: types.compilerOptions;
6
- declare const _default: {
7
- defaultCompilerOptions: types.compilerOptions;
8
- getGenaratorHeaderComment: typeof getGenaratorHeaderComment;
9
- getSimpleHeaderComment: typeof getSimpleHeaderComment;
10
- isUseOAuth: typeof isUseOAuth;
11
- };
12
- export default _default;
@@ -1,30 +0,0 @@
1
- declare const _default: {
2
- common: {
3
- relativePath: (fromPath: string, toPath: string) => string;
4
- copyDir: typeof import("./common").copyDir;
5
- loadJson: typeof import("./common").loadJson;
6
- writeFile: typeof import("./common").writeFile;
7
- };
8
- generator: {
9
- defaultCompilerOptions: import("../types/types").compilerOptions;
10
- getGenaratorHeaderComment: typeof import("./generator").getGenaratorHeaderComment;
11
- getSimpleHeaderComment: typeof import("./generator").getSimpleHeaderComment;
12
- isUseOAuth: typeof import("./generator").isUseOAuth;
13
- };
14
- jsonSchema: {
15
- cleanXcustomValue: typeof import("./jsonSchema").cleanXcustomValue;
16
- httpMethod: typeof import("./jsonSchema").httpMethod;
17
- loadJsonSchema: typeof import("./jsonSchema").loadJsonSchema;
18
- };
19
- logger: {
20
- process: typeof import("./logger").processing;
21
- writing: typeof import("./logger").writing;
22
- info: typeof import("./logger").info;
23
- warn: typeof import("./logger").warn;
24
- error: typeof import("./logger").error;
25
- };
26
- configChecker: {
27
- checkConfigValid: typeof import("./configChecker").checkConfigValid;
28
- };
29
- };
30
- export default _default;
@@ -1,14 +0,0 @@
1
- import * as types from "../types/types";
2
- export declare function loadJsonSchema(jsonSchemaPath: string): types.jsonSchema | never;
3
- export declare function cleanXcustomValue(schemaObj: {
4
- [key: string]: any;
5
- }, additionalKeyArr?: string[] | types.additionalKeyObj): {
6
- [key: string]: any;
7
- };
8
- export declare function httpMethod(jsonSchemaMethod: string, documentName: string): types.httpMethod;
9
- declare const _default: {
10
- cleanXcustomValue: typeof cleanXcustomValue;
11
- httpMethod: typeof httpMethod;
12
- loadJsonSchema: typeof loadJsonSchema;
13
- };
14
- export default _default;
@@ -1,13 +0,0 @@
1
- export declare function processing(msg: any, ...optionalParams: any[]): void;
2
- export declare function writing(msg: any, ...optionalParams: any[]): void;
3
- export declare function info(msg: any, ...optionalParams: any[]): void;
4
- export declare function warn(msg: any, ...optionalParams: any[]): void;
5
- export declare function error(msg: any, ...optionalParams: any[]): never;
6
- declare const _default: {
7
- process: typeof processing;
8
- writing: typeof writing;
9
- info: typeof info;
10
- warn: typeof warn;
11
- error: typeof error;
12
- };
13
- export default _default;