very-express 0.2.1 → 0.2.3

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.
@@ -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
 
@@ -9,7 +9,7 @@ const server_template_1 = __importDefault(require("./server.template"));
9
9
  const packageJson_generator_1 = __importDefault(require("./packageJson.generator"));
10
10
  const logger_1 = __importDefault(require("../utils/logger"));
11
11
  function compile(compilerOptions) {
12
- const serverOutPath = compilerOptions.srcDir + "/server.gen.ts";
12
+ const serverOutPath = compilerOptions.srcDir + "/server.ts";
13
13
  const packageOutPath = compilerOptions.rootDir + "/package.json";
14
14
  const envOutPath = compilerOptions.rootDir + "/.env";
15
15
  const tsconfigOutPath = compilerOptions.rootDir + "/tsconfig.json";
@@ -1,32 +1,42 @@
1
1
  {
2
2
  "main": "index.js",
3
3
  "scripts": {
4
- "vexgen": "vex",
5
4
  "build": "tsc -p .",
6
- "start": "node dist/server.gen.js",
7
- "dev": "nodemon --exec ts-node src/server.gen.ts"
5
+ "start": "node dist/server.js",
6
+ "dev": "nodemon --watch src --exec ts-node src/server.ts"
8
7
  },
9
8
  "dependencies": {
10
- "dotenv": "^16.3.1",
9
+ "binance": "^2.8.9",
10
+ "bybit-api": "^3.7.2",
11
+ "dotenv": "^16.4.4",
11
12
  "express": "^4.18.2",
13
+ "express-session": "^1.18.0",
12
14
  "express-validator": "^7.0.1",
13
15
  "helmet": "^7.1.0",
14
16
  "js-yaml": "^4.1.0",
15
- "mongoose": "^8.0.3",
16
- "mongo-ts-querystring": "^1.0.0",
17
- "nodemon": "^2.0.22",
17
+ "mongo-ts-querystring": "^1.0.4",
18
+ "mongodb": "^5.6.0",
19
+ "mongoose": "^7.4.0",
18
20
  "passport": "^0.7.0",
19
21
  "passport-google-oauth20": "^2.0.0",
20
22
  "swagger-ui-express": "^5.0.0"
21
23
  },
22
24
  "devDependencies": {
23
- "@types/express": "^4.17.21",
25
+ "@types/crypto-js": "^4.1.2",
26
+ "@types/dotenv": "^8.2.0",
27
+ "@types/express": "^4.17.17",
28
+ "@types/express-session": "^1.17.10",
29
+ "@types/express-validator": "^3.0.0",
24
30
  "@types/js-yaml": "^4.0.9",
25
- "@types/node": "^20.10.5",
31
+ "@types/mongodb": "^4.0.7",
32
+ "@types/node": "^20.4.2",
26
33
  "@types/passport": "^1.0.16",
27
34
  "@types/passport-google-oauth20": "^2.0.14",
35
+ "@types/sequelize": "^4.28.15",
28
36
  "@types/swagger-ui-express": "^4.1.6",
29
- "ts-node": "^10.9.2",
30
- "typescript": "^5.3.3"
37
+ "@types/ws": "^8.5.5",
38
+ "nodemon": "^2.0.22",
39
+ "ts-node": "^10.9.1",
40
+ "typescript": "^5.1.6"
31
41
  }
32
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "very-express",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
5
5
  "author": "justin26l",
6
6
  "license": "MIT",