very-express 0.3.6 → 0.4.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 (82) hide show
  1. package/.gitattributes +2 -2
  2. package/dist/{templates/plugins → _plugins}/PassportGoogle.ts +2 -2
  3. package/dist/{templates/plugins → _plugins}/oauthVerify.ts +1 -1
  4. package/dist/{templates/services → _services}/mongoConn.ts +1 -1
  5. package/dist/_types/responseMsg.ts +13 -0
  6. package/dist/{templates/utils → _utils}/common.ts +6 -1
  7. package/dist/_utils/index.ts +11 -0
  8. package/dist/{templates/utils → _utils}/logger.ts +5 -2
  9. package/dist/_utils/response.ts +32 -0
  10. package/dist/cli.d.ts +0 -1
  11. package/dist/generators/app/openapi.generator.d.ts +3 -0
  12. package/dist/generators/{role.generator.d.ts → app/role.generator.d.ts} +2 -2
  13. package/dist/generators/app/server.generator.d.ts +2 -0
  14. package/dist/generators/{server.template.d.ts → app/server.template.d.ts} +1 -1
  15. package/dist/generators/{controller.template.d.ts → controller/controller.template.d.ts} +1 -1
  16. package/dist/generators/{controllers.generator.d.ts → controller/controllers.generator.d.ts} +2 -2
  17. package/dist/generators/index.d.ts +2 -2
  18. package/dist/generators/project/packageJson.generator.d.ts +6 -0
  19. package/dist/generators/{userSchema.generator.d.ts → project/userSchema.generator.d.ts} +2 -2
  20. package/dist/generators/routes/routes.generator.d.ts +2 -2
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +991 -121
  23. package/dist/preprocess/jsonschemaFormat.d.ts +1 -1
  24. package/dist/preprocess/roleSetupFile.d.ts +1 -1
  25. package/dist/templates/{plugins/PassportGoogle.gen.ts → _plugins/PassportGoogle.ts} +29 -8
  26. package/dist/templates/_plugins/oauthVerify.ts +39 -0
  27. package/dist/templates/_roles/_RoleFactory.ts +22 -0
  28. package/dist/templates/{services/mongoConn.gen.ts → _services/mongoConn.ts} +12 -1
  29. package/dist/templates/_types/responseMsg.ts +13 -0
  30. package/dist/templates/{utils/common.gen.ts → _utils/common.ts} +6 -1
  31. package/dist/templates/_utils/index.ts +11 -0
  32. package/dist/templates/{utils/logger.gen.ts → _utils/logger.ts} +5 -2
  33. package/dist/templates/_utils/response.ts +32 -0
  34. package/dist/templates/root/tsconfig.json +2 -1
  35. package/dist/types/types.d.ts +1 -0
  36. package/dist/utils/configChecker.d.ts +2 -0
  37. package/dist/utils/index.d.ts +1 -0
  38. package/package.json +12 -9
  39. package/tsconfig.json +8 -6
  40. package/vex.config.json +3 -2
  41. package/.env +0 -6
  42. package/dist/cli.js +0 -84
  43. package/dist/generators/controller.template.js +0 -204
  44. package/dist/generators/controllers.generator.js +0 -173
  45. package/dist/generators/index.js +0 -13
  46. package/dist/generators/openapi.generator.d.ts +0 -3
  47. package/dist/generators/openapi.generator.js +0 -227
  48. package/dist/generators/packageJson.generator.d.ts +0 -5
  49. package/dist/generators/packageJson.generator.js +0 -42
  50. package/dist/generators/role.generator.js +0 -112
  51. package/dist/generators/routes/oauth.generator.js +0 -66
  52. package/dist/generators/routes/routes.generator.js +0 -53
  53. package/dist/generators/routes/routes.template.js +0 -32
  54. package/dist/generators/routes/swagger.generator.js +0 -46
  55. package/dist/generators/routes.generator.d.ts +0 -11
  56. package/dist/generators/routes.generator.js +0 -53
  57. package/dist/generators/routes.template.d.ts +0 -11
  58. package/dist/generators/routes.template.js +0 -33
  59. package/dist/generators/server.generator.d.ts +0 -2
  60. package/dist/generators/server.generator.js +0 -30
  61. package/dist/generators/server.template.js +0 -149
  62. package/dist/generators/userSchema.generator.js +0 -30
  63. package/dist/preprocess/jsonschemaFormat.js +0 -107
  64. package/dist/preprocess/roleSetupFile.js +0 -60
  65. package/dist/templates/plugins/oauthVerify.gen.ts +0 -34
  66. package/dist/templates/roles/_RoleFactory.js +0 -17
  67. package/dist/templates/routes/swagger.gen.ts +0 -17
  68. package/dist/test.d.ts +0 -1
  69. package/dist/test.js +0 -10
  70. package/dist/types/controller.d.ts +0 -0
  71. package/dist/types/controller.js +0 -1
  72. package/dist/types/openapi.js +0 -2
  73. package/dist/types/types.js +0 -5
  74. package/dist/utils/common.js +0 -74
  75. package/dist/utils/generator.js +0 -74
  76. package/dist/utils/index.js +0 -20
  77. package/dist/utils/jsonSchema.js +0 -84
  78. package/dist/utils/log.d.ts +0 -13
  79. package/dist/utils/log.js +0 -31
  80. package/dist/utils/logger.js +0 -31
  81. /package/dist/{templates/roles → _roles}/_RoleFactory.ts +0 -0
  82. /package/dist/templates/{roles → _roles}/_RoleFactory.d.ts +0 -0
package/.gitattributes CHANGED
@@ -1,2 +1,2 @@
1
- # Auto detect text files and perform LF normalization
2
- * text=auto
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -3,8 +3,8 @@
3
3
  import { Router } from "express";
4
4
  import passport, { PassportStatic, Profile } from "passport";
5
5
  import { AuthenticateOptionsGoogle, Strategy as GoogleStrategy, StrategyOptions, VerifyCallback } from "passport-google-oauth20";
6
- import log from "../utils/logger.gen";
7
- import { UserModel } from "../models/UserModel.gen";
6
+ import log from "./../../system/_utils/logger.gen";
7
+ import { UserModel } from "./../_models/UserModel.gen";
8
8
 
9
9
  export type { Profile };
10
10
 
@@ -1,7 +1,7 @@
1
1
  // {{headerComment}}
2
2
 
3
3
  import { Profile } from "passport";
4
- import { UserModel } from "../models/UserModel.gen";
4
+ import { UserModel } from "./../models/UserModel.gen";
5
5
 
6
6
  interface IProfile extends Profile {
7
7
  [key: string]: any;
@@ -2,7 +2,7 @@
2
2
 
3
3
  import mongoose from "mongoose";
4
4
  import { Request, Response, NextFunction } from "express";
5
- import log from "../utils/logger.gen";
5
+ import log from "./../../system/_utils/logger.gen";
6
6
 
7
7
  export function connect(mongoUrl:string): mongoose.Connection {
8
8
  mongoose.connect(mongoUrl, {
@@ -0,0 +1,13 @@
1
+ enum responseMessage {
2
+ permissionDeny = "Permission Denied",
3
+ ok = "OK",
4
+ notFound = "Not Found",
5
+ queryError = "Query Error",
6
+ validateError = "Validation Error",
7
+ unexpectedError = "Unexpected Error",
8
+ createFail = "Create Fail",
9
+ updateFail = "Update Fail",
10
+ deleteFail = "Delete Fail",
11
+ }
12
+
13
+ export default responseMessage;
@@ -45,4 +45,9 @@ export function parseFieldsSelect(selectString: any) : { [key: string]: number }
45
45
  }, {} as Record<string, number>);
46
46
 
47
47
  return selectFields;
48
- }
48
+ }
49
+
50
+ export default {
51
+ loadYaml,
52
+ parseFieldsSelect
53
+ };
@@ -0,0 +1,11 @@
1
+ import logger from "./logger.gen";
2
+ import response from "./response.gen";
3
+ import responseMessage from "../../system/_types/responseMsg.gen";
4
+ import common from "./common.gen";
5
+
6
+ export default {
7
+ log : logger,
8
+ response,
9
+ responseMsg : responseMessage,
10
+ common
11
+ };
@@ -1,4 +1,6 @@
1
- // {{headerComment}}
1
+ export function processing(msg: any, ...optionalParams: any[]): void {
2
+ console.log("\x1b[34m%s\x1b[0m", "[PROCESSING]", msg, optionalParams.length > 0 ? optionalParams : "");
3
+ }
2
4
 
3
5
  export function ok(msg: any, ...optionalParams: any[]): void {
4
6
  console.log("\x1b[32m%s\x1b[0m", "[OK]", msg, optionalParams.length > 0 ? optionalParams : "");
@@ -12,12 +14,13 @@ export function warn(msg: any, ...optionalParams: any[]): void {
12
14
  console.log("\x1b[33m%s\x1b[0m", "[WARN]", msg, optionalParams.length > 0 ? optionalParams : "");
13
15
  }
14
16
 
15
- export function error(msg: any, ...optionalParams: any[]): void {
17
+ export function error(msg: any, ...optionalParams: any[]): never {
16
18
  console.log("\x1b[41m%s\x1b[0m", "[ERROR]", msg, optionalParams.length > 0 ? optionalParams : "");
17
19
  process.exit(1);
18
20
  }
19
21
 
20
22
  export default {
23
+ process : processing,
21
24
  ok,
22
25
  info,
23
26
  warn,
@@ -0,0 +1,32 @@
1
+ import { Response } from "express";
2
+
3
+ export interface responseObject<T>{
4
+ ret_code : number,
5
+ ret_msg : string,
6
+ ret_time?: number,
7
+ result: T,
8
+ }
9
+
10
+ /**
11
+ * @param res express response object
12
+ * @param code http status
13
+ * @param message response data message
14
+ * @param result response data result
15
+ */
16
+ export function send<T = undefined>(
17
+ res: Response,
18
+ code: number = 200,
19
+ message: string = "OK",
20
+ result?: T,
21
+ ): Response<any, Record<string, any>> {
22
+ return res.status(code).json({
23
+ ret_code: code,
24
+ ret_msg: message,
25
+ ret_time: new Date().getTime(),
26
+ result: result,
27
+ });
28
+ }
29
+
30
+ export default {
31
+ send
32
+ };
package/dist/cli.d.ts CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
1
  export {};
@@ -0,0 +1,3 @@
1
+ import * as types from "./../../types/types";
2
+ export declare function compile(openapiOutFileName: string, compilerOptions: types.compilerOptions): Promise<void>;
3
+ export default compile;
@@ -1,7 +1,7 @@
1
- import * as types from "../types/types";
1
+ import * as types from "../../types/types";
2
2
  export declare function compile(options: {
3
3
  collectionList: string[];
4
4
  roleSourceDir: string;
5
5
  roleOutDir: string;
6
6
  compilerOptions: types.compilerOptions;
7
- }): void;
7
+ }): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import * as types from "../../types/types";
2
+ export declare function compile(compilerOptions: types.compilerOptions): Promise<void>;
@@ -1,4 +1,4 @@
1
- import * as types from "../types/types";
1
+ import * as types from "../../types/types";
2
2
  export default function serverTemplate(options: {
3
3
  compilerOptions: types.compilerOptions;
4
4
  template?: string;
@@ -1,4 +1,4 @@
1
- import * as types from "../types/types";
1
+ import * as types from "../../types/types";
2
2
  import { Schema } from "express-validator";
3
3
  export default function controllerTemplate(templateOptions: {
4
4
  template?: string;
@@ -1,7 +1,7 @@
1
- import * as types from "../types/types";
1
+ import * as types from "./../../types/types";
2
2
  export declare function compile(options: {
3
3
  openapiFile: string;
4
4
  controllerOutDir: string;
5
5
  modelDir: string;
6
6
  compilerOptions: types.compilerOptions;
7
- }): void;
7
+ }): Promise<void>;
@@ -1,6 +1,6 @@
1
- import controllerTemplate from "./controller.template";
1
+ import controllerTemplate from "./controller/controller.template";
2
2
  import routesTemplate from "./routes/routes.template";
3
- import serverTemplate from "./server.template";
3
+ import serverTemplate from "./app/server.template";
4
4
  declare const _default: {
5
5
  controllerTemplate: typeof controllerTemplate;
6
6
  routesTemplate: typeof routesTemplate;
@@ -0,0 +1,6 @@
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 +1,4 @@
1
- import * as types from "../types/types";
1
+ import * as types from "./../../types/types";
2
2
  export declare function compile(options: {
3
3
  compilerOptions: types.compilerOptions;
4
- }): void;
4
+ }): Promise<void>;
@@ -1,4 +1,4 @@
1
- import * as types from "../../types/types";
1
+ import * as types from "./../../types/types";
2
2
  export declare function compile(options: {
3
3
  routesArr: {
4
4
  route: string;
@@ -8,4 +8,4 @@ export declare function compile(options: {
8
8
  routesDir: string;
9
9
  openapiFile: string;
10
10
  compilerOptions: types.compilerOptions;
11
- }): void;
11
+ }): Promise<void>;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  import * as types from "./types/types";
2
- export declare function generate(options: types.compilerOptions): void;
2
+ export declare function generate(options: types.compilerOptions): Promise<void>;