very-express 0.2.2 → 0.2.4

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 CHANGED
@@ -24,7 +24,9 @@ if (fs_1.default.existsSync("vex.config.json")) {
24
24
  }
25
25
  }
26
26
  config.commitBeforeGenerate = (_a = config.commitBeforeGenerate) !== null && _a !== void 0 ? _a : false;
27
- config.jsonSchemaDir = args.j || args.jsonSchemaDir || config.jsonSchemaDir || "./jsonSchema";
27
+ config.enableSwagger = config.enableSwagger || true,
28
+ config.useUserSchema = config.useUserSchema || true,
29
+ config.jsonSchemaDir = args.j || args.jsonSchemaDir || config.jsonSchemaDir || "./jsonSchema";
28
30
  config.rootDir = args.o || args.rootDir || config.rootDir || ".";
29
31
  config.srcDir = config.srcDir || config.rootDir + "/src";
30
32
  config.openapiDir = config.openapiDir || config.rootDir + "./openapi";
@@ -34,13 +36,13 @@ config.useOauth = config.useOauth || {
34
36
  apple: false,
35
37
  github: false
36
38
  };
37
- logger_1.default.writing("vex.config.json");
39
+ logger_1.default.process("vex.config.json");
38
40
  fs_1.default.writeFileSync("vex.config.json", JSON.stringify(config, null, 4));
39
41
  if (String(args._[0]).toLowerCase() === "h" || args["h"]) {
40
42
  console.log(`Very Express CLI Usage :
41
43
  vex [flag]
42
- -h | help : Help
43
- -i | init : Create generator config etc.
44
+ -h : Help
45
+ -i : Create generator config etc.
44
46
  to generate app :
45
47
  vex [jsonSchemaDir] [rootDir]
46
48
  -j : jsonSchemaDir (configured: ${config.jsonSchemaDir})
@@ -1,4 +1,2 @@
1
1
  import * as types from "../../types/types";
2
- export declare function compile(options: {
3
- compilerOptions: types.compilerOptions;
4
- }): string;
2
+ export declare function compile(compilerOptions: types.compilerOptions): string;
@@ -12,9 +12,9 @@ function loginHtml(providers) {
12
12
  });
13
13
  return `\`${html}\``;
14
14
  }
15
- function compile(options) {
16
- const providers = common_1.default.isUseOAuth(options.compilerOptions);
17
- return `${options.compilerOptions.headerComment}
15
+ function compile(compilerOptions) {
16
+ const providers = common_1.default.isUseOAuth(compilerOptions);
17
+ return `${compilerOptions.headerComment}
18
18
  import { Router } from 'express';
19
19
  import util from 'util';
20
20
 
@@ -0,0 +1,2 @@
1
+ import * as types from "../../types/types";
2
+ export declare function compile(compilerOptions: types.compilerOptions): string;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compile = void 0;
4
+ function compile(compilerOptions) {
5
+ return `${compilerOptions.headerComment}
6
+ import { Router } from "express";
7
+ import swaggerUi, { JsonObject } from "swagger-ui-express";
8
+ import { loadYaml } from "../utils/common.gen";
9
+
10
+ export default class SwaggerRouter{
11
+
12
+ public router: Router = Router();
13
+
14
+ constructor() {}
15
+
16
+ public initRoutes() {
17
+ this.router.use("/api", swaggerUi.serve, swaggerUi.setup(loadYaml("${compilerOptions.openapiDir}") as JsonObject));
18
+ }
19
+ }`;
20
+ }
21
+ exports.compile = compile;
@@ -30,6 +30,7 @@ exports.compile = void 0;
30
30
  const fs_1 = __importDefault(require("fs"));
31
31
  const routes_template_1 = __importDefault(require("./routes.template"));
32
32
  const routesOAuthGen = __importStar(require("./routes/oauth.generator"));
33
+ const routesSwaggerGen = __importStar(require("./routes/swagger.generator"));
33
34
  const utils = __importStar(require("../utils/common"));
34
35
  const logger_1 = __importDefault(require("../utils/logger"));
35
36
  function compile(options) {
@@ -43,12 +44,10 @@ function compile(options) {
43
44
  compilerOptions: options.compilerOptions,
44
45
  }));
45
46
  if (utils.isUseOAuth(options.compilerOptions).length > 0) {
46
- fs_1.default.writeFileSync(routesOAuthOutPath, routesOAuthGen.compile({
47
- compilerOptions: options.compilerOptions || utils.defaultCompilerOptions
48
- }));
47
+ fs_1.default.writeFileSync(routesOAuthOutPath, routesOAuthGen.compile(options.compilerOptions));
49
48
  }
50
49
  if (options.compilerOptions.enableSwagger) {
51
- fs_1.default.copyFileSync(`${__dirname}/../templates/routes/swagger.gen.ts`, routesSwaggerOutPath);
50
+ fs_1.default.writeFileSync(routesSwaggerOutPath, routesSwaggerGen.compile(options.compilerOptions));
52
51
  }
53
52
  }
54
53
  exports.compile = compile;
@@ -13,7 +13,6 @@ function routesTemplate(templateOptions) {
13
13
  const headerComment = ((_a = templateOptions.compilerOptions) === null || _a === void 0 ? void 0 : _a.headerComment) || "// generated files by very-express";
14
14
  let template = templateOptions.template || `{{headerComment}}
15
15
  import { Router } from 'express';
16
- import { loadYaml } from '../utils/common.gen';
17
16
 
18
17
  {{importRoutes}}
19
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "very-express",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
5
5
  "author": "justin26l",
6
6
  "license": "MIT",