very-express 0.3.4 → 0.3.6

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.
@@ -59,15 +59,15 @@ function compile(options) {
59
59
  }
60
60
  });
61
61
  const RoleAccessActionString = Object.keys(RoleAccessAction).map((key) => `"${key}"`);
62
- RoleAccessActionString.push("roleFt.accessAction");
62
+ RoleAccessActionString.push("roleFactory.accessAction");
63
63
  const content = `${options.compilerOptions.headerComment}
64
- import * as role from "./_RoleFactory.gen";
64
+ import * as roleFactory from "./_RoleFactory.gen";
65
65
 
66
66
  export type accessAction${role} = ${RoleAccessActionString.join(" | ")};
67
67
 
68
- const ${role}AccessControl: roleFt.accessControl<accessAction${role}> = ${JSON.stringify(roleContent, null, 4)};
68
+ const ${role}AccessControl: roleFactory.accessControl<accessAction${role}> = ${JSON.stringify(roleContent, null, 4)};
69
69
 
70
- export default class Role${role} extends roleFt._RoleFactory<accessAction${role}> {
70
+ export default class Role${role} extends roleFactory._RoleFactory<accessAction${role}> {
71
71
  constructor() {
72
72
  super(${role}AccessControl);
73
73
  }
@@ -79,14 +79,14 @@ export default class Role${role} extends roleFt._RoleFactory<accessAction${role}
79
79
  from: roleOutFile,
80
80
  });
81
81
  });
82
- const indexFile = `${options.roleOutDir}/index.gen.ts`;
83
- const indexFileContent = indexFileData.map((data) => `export { default as ${data.name} } from "./${data.from.replace(".ts", "")}";`).join("\n");
82
+ const indexFile = `${options.roleOutDir}/index.ts`;
83
+ const indexFileContent = indexFileData.map((data) => `export { default as ${data.name} } from "./${data.name}.gen";`).join("\n");
84
84
  (0, utils_1.writeFile)("RBAC Index", indexFile, `${options.compilerOptions.headerComment}\n${indexFileContent}`);
85
- if (!fs_1.default.existsSync(`${options.compilerOptions.srcDir}/middleware`)) {
86
- fs_1.default.mkdirSync(`${options.compilerOptions.srcDir}/middleware`);
85
+ if (!fs_1.default.existsSync(`${options.compilerOptions.srcDir}/middlewares`)) {
86
+ fs_1.default.mkdirSync(`${options.compilerOptions.srcDir}/middlewares`);
87
87
  }
88
- const middlewareFile = `${options.compilerOptions.srcDir}/middleware/RoleBaseAccessControl.gen.ts`;
89
- const roleTypes = indexFileData.map((data) => `typeof ${data.name}`).join(" | ");
88
+ const middlewareFile = `${options.compilerOptions.srcDir}/middlewares/RoleBaseAccessControl.gen.ts`;
89
+ const roleTypes = indexFileData.map((data) => `typeof roles.${data.name}`).join(" | ");
90
90
  const middlewareContent = `${options.compilerOptions.headerComment}
91
91
  import { Request, Response, NextFunction } from "express";
92
92
  import * as roles from "../roles";
@@ -44,12 +44,12 @@ function roleSchemaFormat(options) {
44
44
  if (prop["x-vexData"] === "role") {
45
45
  prop.type = "array";
46
46
  prop.required = true;
47
+ prop.default = [(_a = options.compilerOptions.useRBAC) === null || _a === void 0 ? void 0 : _a.default];
47
48
  if (!prop.items) {
48
49
  prop.items = { type: "" };
49
50
  }
50
51
  prop.items.type = "string";
51
52
  prop.items.required = true;
52
- prop.items.default = (_a = options.compilerOptions.useRBAC) === null || _a === void 0 ? void 0 : _a.default;
53
53
  prop.items.enum = (_b = options.compilerOptions.useRBAC) === null || _b === void 0 ? void 0 : _b.roles;
54
54
  break;
55
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "very-express",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
5
5
  "author": "justin26l",
6
6
  "license": "MIT",