very-express 0.4.3 → 0.4.5

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.
@@ -6,8 +6,6 @@
6
6
  "dev": "nodemon --watch src --exec ts-node src/server.ts"
7
7
  },
8
8
  "dependencies": {
9
- "binance": "^2.8.9",
10
- "bybit-api": "^3.7.2",
11
9
  "dotenv": "^16.4.4",
12
10
  "express": "^4.18.2",
13
11
  "express-session": "^1.18.0",
@@ -0,0 +1,42 @@
1
+ # Define Json Schema
2
+ ### x-documentConfig:
3
+
4
+ | Fields | Data Type | Options | Description |
5
+ | - | - | - | - |
6
+ | documentName | `string` | - | name of **collection** or **table**, also used at `Model`, camel case recomended. |
7
+ | interfaceName | `string` | - | use to name `endpoint`, `Class`, `Interface`, `File`. |
8
+ | methods | `array<string>` | `get`, `post`, `put`, `patch`, `delete` | available method of REST API. |
9
+
10
+
11
+ ### Properties Mandatory Value:
12
+
13
+ | Fields | Data Type | Required | Description |
14
+ | - | - | - | - |
15
+ | type | `string` | true | [JsonSchema's type field](https://json-schema.org/understanding-json-schema/reference/type) |
16
+ | required | `boolean` | false | api will check field must be defined. |
17
+ | x-foreignKey | `string` | false | `documentName` from other JsonSchema, plan to implemented on [v0.5.0](./RoadMap/v0-5-0.md) |
18
+ <!-- | format | `string` | false | veryExpress did not handle this field | -->
19
+
20
+ ```JSON
21
+ {
22
+ "x-documentConfig": {
23
+ "documentName": "user",
24
+ "interfaceName": "User",
25
+ "methods": [
26
+ "get",
27
+ "post",
28
+ "put",
29
+ "patch",
30
+ "delete"
31
+ ]
32
+ },
33
+ "properties": {
34
+ "invoiceId": {
35
+ "type": "string",
36
+ "format": "uuid",
37
+ "required": false,
38
+ "x-foreignKey": "invoice"
39
+ }
40
+ }
41
+ }
42
+ ```
@@ -0,0 +1,16 @@
1
+ # Development Note
2
+ - "Project" or "The Project" is refer to this package which named "VeryExpress", github repository "[Justin26l/VeryExpress](https://github.com/Justin26l/VeryExpress)", npm package "[very-express](https://www.npmjs.com/package/very-express)".
3
+
4
+ - "Package" is refer to one of the node module, npm package, third-party library.
5
+
6
+
7
+ 1. **TypeScript**
8
+ this project is based on [TypeScript](https://www.typescriptlang.org/).
9
+ we do not use ts-node in development due to file structure of the project,
10
+ you can refer to [package.json](./../package.json) "dev" script to know how to run the project in development.
11
+
12
+ 2. **@vercel/ncc**
13
+ we use this package to compile the project into single file.
14
+ the project must be compiled to run as expected.
15
+
16
+ due to the single file design, working directory of the project will always be at "dist/".
@@ -0,0 +1,30 @@
1
+ # Road Map
2
+
3
+ ## Compatibility
4
+
5
+ - [ ] Dockernize
6
+
7
+ - [x] Generate App
8
+ - [x] generate openapi based on json schema
9
+ - [x] generate controllers based on openapi
10
+ - [x] CRUD API
11
+ - [x] data validation (express-validator)
12
+
13
+ - [ ] Database
14
+ - [x] MongoDB
15
+ - SQL **(ON HOLD)**
16
+
17
+ - [ ] OAuth2
18
+ - [x] google
19
+ - [ ] microsoft
20
+ - [ ] github
21
+
22
+ ## Features
23
+
24
+ - [ ] Schema Definition
25
+ - [ ] App level foreign-key. `x-foreign-key`
26
+ - [ ] DB field encryption. `x-encrypt`
27
+
28
+ - [x] Role Base Access Control
29
+ - [x] API access control
30
+ - different controller data validation rule by role **(ON HOLD)**
@@ -0,0 +1,20 @@
1
+ # v0.5.0 Plan
2
+
3
+ ### App level foreign-key
4
+ - [ ] at JsonSchmea properties item, add attribute `x-foreignKey: "collectionName"`
5
+ use this column value to match with target collectionName's "_id" fields.
6
+ ```JSON
7
+ {
8
+ "invoiceId": {
9
+ "type" : "string",
10
+ "x-foreignKey" : "invoice"
11
+ },
12
+ "orderId": {
13
+ "type" : "string",
14
+ "x-foreignKey" : "order"
15
+ }
16
+ }
17
+ ```
18
+ - [ ] REST API, to request data with foreign-key collection:
19
+ add field name as stringified array into querystring "join"
20
+ example `/myDataApi?join=[invoiceId,orderId]`
@@ -0,0 +1,7 @@
1
+ # v0.6.0 Plan
2
+
3
+ ### dockernize
4
+ - [ ] dockernize
5
+ ### oauth2 support
6
+ - [ ] microsoft
7
+ - [ ] github
@@ -0,0 +1,4 @@
1
+ # v0.7.0 Plan
2
+
3
+ ## app level foreign-key.
4
+ - [ ] db fields encryption
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "very-express",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
5
5
  "author": "justin26l",
6
6
  "license": "MIT",
@@ -10,9 +10,8 @@
10
10
  },
11
11
  "scripts": {
12
12
  "start": "node ./dist/index.js",
13
- "dev": "ts-node ./src/cli.ts",
14
- "build": "npm run lint && npm run compile && npm run minify",
15
- "test": "npm run compile && npm run start",
13
+ "dev": "npm run compile && npm run start",
14
+ "build": "npm run lint && npm run compile",
16
15
  "lint": "eslint ./src --ext .ts --fix",
17
16
  "compile": "ncc build ./src/cli.ts -o dist && node ./src/copyTsTemplates.js",
18
17
  "minify": "uglifyjs ./dist/index.js -c -m -o ./dist/index.js"
@@ -1,38 +0,0 @@
1
- // {{headerComment}}
2
-
3
- import mongoose from "mongoose";
4
- import { Request, Response, NextFunction } from "express";
5
- import log from "./../../system/_utils/logger.gen";
6
-
7
- export function connect(mongoUrl:string): mongoose.Connection {
8
- mongoose.connect(mongoUrl, {
9
- autoCreate: true,
10
- });
11
-
12
- mongoose.connection.on("open", () => {
13
- log.ok("MongoDB Connection open : " + mongoUrl);
14
- });
15
-
16
- mongoose.connection.on("error", (err: any) => {
17
- log.error("MongoDB Connection error:", err.message, err);
18
- });
19
-
20
- return mongoose.connection;
21
- }
22
-
23
- export function middleware(req: Request, res: Response, next: NextFunction) {
24
- const db = mongoose.connection;
25
- if (db.readyState !== 1) {
26
- return res.status(503).json({ error: "Database connection issue" });
27
- }
28
- else {
29
- next();
30
- }
31
- }
32
-
33
- const mongo = {
34
- connect,
35
- middleware
36
- };
37
-
38
- export default mongo;
@@ -1,7 +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
- compilerOptions: types.compilerOptions;
7
- }): Promise<void>;
@@ -1,38 +0,0 @@
1
- // {{headerComment}}
2
-
3
- import mongoose from "mongoose";
4
- import { Request, Response, NextFunction } from "express";
5
- import log from "./../../system/_utils/logger.gen";
6
-
7
- export function connect(mongoUrl:string): mongoose.Connection {
8
- mongoose.connect(mongoUrl, {
9
- autoCreate: true,
10
- });
11
-
12
- mongoose.connection.on("open", () => {
13
- log.ok("MongoDB Connection open : " + mongoUrl);
14
- });
15
-
16
- mongoose.connection.on("error", (err: any) => {
17
- log.error("MongoDB Connection error:", err.message, err);
18
- });
19
-
20
- return mongoose.connection;
21
- }
22
-
23
- export function middleware(req: Request, res: Response, next: NextFunction) {
24
- const db = mongoose.connection;
25
- if (db.readyState !== 1) {
26
- return res.status(503).json({ error: "Database connection issue" });
27
- }
28
- else {
29
- next();
30
- }
31
- }
32
-
33
- const mongo = {
34
- connect,
35
- middleware
36
- };
37
-
38
- export default mongo;