very-express 0.5.1 → 0.5.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.
- package/.eslintrc.json +37 -37
- package/.gitattributes +2 -2
- package/.github/workflows/npm-start.yml +23 -23
- package/LICENSE +21 -21
- package/README.md +62 -61
- package/dist/index.js +416 -399
- package/dist/templates/_middlewares/Authentication.ts +22 -19
- package/dist/templates/_plugins/auth/JWTKeyStore.ts +46 -2
- package/dist/templates/_plugins/auth/jwt.ts +50 -22
- package/dist/templates/_plugins/auth/oauthVerify.ts +6 -2
- package/dist/templates/_plugins/auth/token.ts +8 -3
- package/dist/templates/_routes/oauth/OAuthRouteFactory.ts +39 -32
- package/dist/templates/_services/VexDbConnector.ts +2 -2
- package/dist/templates/_services/VexSystem.ts +37 -0
- package/dist/templates/_types/response/index.ts +1 -1
- package/dist/templates/_types/response/responseCode.ts +3 -1
- package/dist/templates/_types/response/responseMsg.ts +7 -2
- package/dist/templates/_types/response/responseStatusCodeMap.ts +70 -0
- package/dist/templates/_utils/index.ts +0 -6
- package/dist/templates/_utils/response.ts +40 -8
- package/dist/templates/jsonSchema/User.json +82 -82
- package/dist/templates/jsonSchema/session.json +32 -0
- package/dist/templates/root/.env +19 -13
- package/dist/templates/root/Dockerfile +19 -19
- package/dist/templates/root/README.md +38 -38
- package/dist/templates/root/package.json +48 -48
- package/dist/templates/root/public/css/style.css +8 -0
- package/dist/templates/root/public/js/logincallback.js +19 -0
- package/dist/templates/root/public/js/mytokens.js +11 -0
- package/dist/templates/root/public/js/refreshtokens.js +23 -0
- package/dist/templates/root/scripts/build.js +38 -38
- package/dist/templates/root/tsconfig.json +21 -21
- package/docs/ForeignKey.md +43 -40
- package/docs/appGenerated/auth.md +23 -0
- package/docs/developmentNote.md +22 -22
- package/docs/releaseNote/v0-5-0.md +17 -17
- package/docs/roadMap/released.md +49 -0
- package/docs/roadMap/v0-6-0.md +15 -15
- package/docs/roadMap/v0-7-0.md +5 -5
- package/docs/vexJsonSchema.md +55 -55
- package/package.json +50 -49
- package/scripts/build.js +13 -13
- package/scripts/copyTsTemplates.js +30 -30
- package/scripts/merge.js +125 -0
- package/tsconfig.json +121 -121
- package/vex.config.json +29 -29
- package/dist/templates/_types/response/responseStatusToCode.ts +0 -70
- package/docs/roadMap/RoadMap.md +0 -30
package/docs/ForeignKey.md
CHANGED
|
@@ -1,40 +1,43 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
|
26
|
-
|
|
27
|
-
**
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
1
|
+
# Foreign-key
|
|
2
|
+
- Avalilable from v0.5.x
|
|
3
|
+
- Api level collection joining
|
|
4
|
+
|
|
5
|
+
## Define Foreign-key
|
|
6
|
+
Add attribute at JsonSchmea's field props, `x-foreignKey: "targetCollectionName"`
|
|
7
|
+
|
|
8
|
+
Example:
|
|
9
|
+
- **User Collection's** field "contactId" as foreign-key of **Contact Collection**
|
|
10
|
+
```JSON
|
|
11
|
+
{
|
|
12
|
+
"username": {
|
|
13
|
+
"type" : "string",
|
|
14
|
+
...
|
|
15
|
+
},
|
|
16
|
+
"contactId": {
|
|
17
|
+
"type" : "string",
|
|
18
|
+
"x-foreignKey" : "contact"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
```
|
|
22
|
+
# REST API
|
|
23
|
+
## Parameters
|
|
24
|
+
### HTTP GET :
|
|
25
|
+
| Param | Type | Mandatory | Description |
|
|
26
|
+
| ----- | ---- | --------- | ----------- |
|
|
27
|
+
| _join | QueryString `array<String>` | false | join collection using **Current Resource's Field Name**. target joined collection decleare by `x-forignKey` |
|
|
28
|
+
| _select | QueryString `array<String>` | false | work with `_join`, select fields to join for target collection. empty = select all. |
|
|
29
|
+
|
|
30
|
+
## Example
|
|
31
|
+
`/user?_join=["contact"]&_select=["contactName","contactNumber"]`
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
**Output:**
|
|
35
|
+
```JSON
|
|
36
|
+
{
|
|
37
|
+
"username": "justin",
|
|
38
|
+
"contactId": {
|
|
39
|
+
"contactName": "justin's mobile",
|
|
40
|
+
"contactNumber": 1122333445566
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Auth
|
|
2
|
+
- Stateless JWT token
|
|
3
|
+
- **Rolling Keys**
|
|
4
|
+
define in `.env`,
|
|
5
|
+
named `JWT_KEY{increment}`
|
|
6
|
+
```bash
|
|
7
|
+
JWT_KEY1=aaaaa
|
|
8
|
+
JWT_KEY2=bbbbb
|
|
9
|
+
JWT_KEY3=ccccc
|
|
10
|
+
```
|
|
11
|
+
- **OAuth2**
|
|
12
|
+
Supported Providers:
|
|
13
|
+
- Google
|
|
14
|
+
- Github
|
|
15
|
+
|
|
16
|
+
define in `.env`,
|
|
17
|
+
named `OAUTH_{provider}_CLIENTID` & `OAUTH_{provider}_CLIENTSECRET`
|
|
18
|
+
```bash
|
|
19
|
+
OAUTH_GOOGLE_CLIENTID=xxxxx
|
|
20
|
+
OAUTH_GOOGLE_CLIENTSECRET=xxxxx
|
|
21
|
+
```
|
|
22
|
+
- Stated
|
|
23
|
+
- not yet implement
|
package/docs/developmentNote.md
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
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. **Esbuild**
|
|
13
|
-
the project require to compile into bundle to run.
|
|
14
|
-
due to the single file design, working directory of the project will always be at "dist/".
|
|
15
|
-
refer to [package.json](./../package.json) `scripts > compile`.
|
|
16
|
-
|
|
17
|
-
3. **File Generate Template**
|
|
18
|
-
if there is any function calling pass by object need to be write in file output,
|
|
19
|
-
use syntax: `FUNC{{ <myFunc(){...}> }}`.
|
|
20
|
-
refer to :
|
|
21
|
-
1. [controller custom validatior](./../src/generators/controller/controllers.generator.ts#L<202>)
|
|
22
|
-
2. [controller template return](./../src/generators/controller/controller.template.ts#L<246>)
|
|
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. **Esbuild**
|
|
13
|
+
the project require to compile into bundle to run.
|
|
14
|
+
due to the single file design, working directory of the project will always be at "dist/".
|
|
15
|
+
refer to [package.json](./../package.json) `scripts > compile`.
|
|
16
|
+
|
|
17
|
+
3. **File Generate Template**
|
|
18
|
+
if there is any function calling pass by object need to be write in file output,
|
|
19
|
+
use syntax: `FUNC{{ <myFunc(){...}> }}`.
|
|
20
|
+
refer to :
|
|
21
|
+
1. [controller custom validatior](./../src/generators/controller/controllers.generator.ts#L<202>)
|
|
22
|
+
2. [controller template return](./../src/generators/controller/controller.template.ts#L<246>)
|
|
23
23
|
3. [template formatter function](./../src/utils/template.ts#L<6>)
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# v0.5.0 Plan
|
|
2
|
-
|
|
3
|
-
### foreign-key
|
|
4
|
-
- [x] define FK, add props at field, `x-foreignKey: "targetCollectionName"`
|
|
5
|
-
```JSON
|
|
6
|
-
{
|
|
7
|
-
"username": {
|
|
8
|
-
"type" : "string",
|
|
9
|
-
},
|
|
10
|
-
"contactId": {
|
|
11
|
-
"type" : "string",
|
|
12
|
-
"x-foreignKey" : "contact" // target collection's name
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
```
|
|
16
|
-
- [x] REST API, to request data with foreign-key collection:
|
|
17
|
-
add field name as array into querystring "_join"
|
|
1
|
+
# v0.5.0 Plan
|
|
2
|
+
|
|
3
|
+
### foreign-key
|
|
4
|
+
- [x] define FK, add props at field, `x-foreignKey: "targetCollectionName"`
|
|
5
|
+
```JSON
|
|
6
|
+
{
|
|
7
|
+
"username": {
|
|
8
|
+
"type" : "string",
|
|
9
|
+
},
|
|
10
|
+
"contactId": {
|
|
11
|
+
"type" : "string",
|
|
12
|
+
"x-foreignKey" : "contact" // target collection's name
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
- [x] REST API, to request data with foreign-key collection:
|
|
17
|
+
add field name as array into querystring "_join"
|
|
18
18
|
example `/user?_join=["contact"]_select=["contactNo"]&`
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
- [x] App level foreign-key. `x-foreign-key` under properties
|
|
26
|
+
```JSON
|
|
27
|
+
{
|
|
28
|
+
"username": {
|
|
29
|
+
"type" : "string",
|
|
30
|
+
},
|
|
31
|
+
"contactId": {
|
|
32
|
+
"type" : "string",
|
|
33
|
+
"x-foreignKey" : "contact", // target collection's name
|
|
34
|
+
"x-foreignValue" : [ // fields to join
|
|
35
|
+
"contactName",
|
|
36
|
+
"contactNumber",
|
|
37
|
+
"isActive"
|
|
38
|
+
]
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
- [x] REST API, to request data with foreign-key collection:
|
|
43
|
+
add field name as array into querystring "_join"
|
|
44
|
+
example `/user?_join=["contact"]_select=["contactNo"]&`
|
|
45
|
+
- [ ] DB field encryption. `x-encrypt`
|
|
46
|
+
|
|
47
|
+
- [x] Role Base Access Control
|
|
48
|
+
- [x] API access control
|
|
49
|
+
- different controller data validation rule by role **(ON HOLD)**
|
package/docs/roadMap/v0-6-0.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# v0.6.0 Plan
|
|
2
|
-
|
|
3
|
-
### dockernize
|
|
4
|
-
- [ ] dockernize
|
|
5
|
-
### oauth2 support
|
|
6
|
-
- [x] google
|
|
7
|
-
- [ ] apple
|
|
8
|
-
- [ ] microsoft
|
|
9
|
-
- [
|
|
10
|
-
- [ ] meta/facebook
|
|
11
|
-
### session storage
|
|
12
|
-
- [x] jwt
|
|
13
|
-
- [
|
|
14
|
-
- [ ] redis cache
|
|
15
|
-
- [
|
|
1
|
+
# v0.6.0 Plan
|
|
2
|
+
|
|
3
|
+
### dockernize
|
|
4
|
+
- [ ] dockernize
|
|
5
|
+
### oauth2 support
|
|
6
|
+
- [x] google
|
|
7
|
+
- [ ] apple
|
|
8
|
+
- [ ] microsoft
|
|
9
|
+
- [x] github
|
|
10
|
+
- [ ] meta/facebook
|
|
11
|
+
### session storage
|
|
12
|
+
- [x] jwt
|
|
13
|
+
- [x] stateless design
|
|
14
|
+
- [ ] redis cache
|
|
15
|
+
- [x] rolling session secret
|
package/docs/roadMap/v0-7-0.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# v0.7.0 Plan
|
|
2
|
-
|
|
3
|
-
## security
|
|
4
|
-
- [ ] Rate Limiting
|
|
5
|
-
- [ ] db fields encryption
|
|
1
|
+
# v0.7.0 Plan
|
|
2
|
+
|
|
3
|
+
## security
|
|
4
|
+
- [ ] Rate Limiting
|
|
5
|
+
- [ ] db fields encryption
|
package/docs/vexJsonSchema.md
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
# Define Json Schema for VeryExpress
|
|
2
|
-
|
|
3
|
-
## x-documentConfig:
|
|
4
|
-
|
|
5
|
-
| Fields | Data Type | Options | Description |
|
|
6
|
-
| - | - | - | - |
|
|
7
|
-
| documentName | `string` | - | auto generated using file name. this value should be same as the collection name, it will used to name **Collection**, **TS Interface**, **ODM Model** etc. |
|
|
8
|
-
| methods | `array<string>` | `get`, `post`, `put`, `patch`, `delete` | array of **REST API Method** to be enable. |
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Properties Definition:
|
|
12
|
-
|
|
13
|
-
| Fields | Data Type | Required | options | Description |
|
|
14
|
-
| - | - | - | - | - |
|
|
15
|
-
| type | `string` | true | - | [JsonSchema's type field](https://json-schema.org/understanding-json-schema/reference/type) |
|
|
16
|
-
| required | `boolean` | false | - | rest api's validator will check value cannot be falsy / undefined. |
|
|
17
|
-
| x-vexData | `string` | false | `primaryKey`, `role` | determine veryExpress generation process. |
|
|
18
|
-
| x-foreignKey | `string` | false | - | `documentName` from other JsonSchema, auto indexed, use to join collection |
|
|
19
|
-
| x-foreignValue | `array<String>` | false | - | default selected fields for target collection |
|
|
20
|
-
<!-- | format | `string` | false | - | veryExpress did not handle this field | -->
|
|
21
|
-
|
|
22
|
-
### System Fields
|
|
23
|
-
System Fields is the properties to let generator run as expected,it should not be changed.
|
|
24
|
-
- `_id` : if defined in schema, it will auto being set as `"index": true`, `"x-vexData": "ObjectId"`.
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
#### Example :
|
|
28
|
-
```JSON
|
|
29
|
-
{
|
|
30
|
-
"x-documentConfig": {
|
|
31
|
-
"documentName": "user", // auto generated using name
|
|
32
|
-
"methods": [
|
|
33
|
-
"get",
|
|
34
|
-
"post",
|
|
35
|
-
"put",
|
|
36
|
-
"patch",
|
|
37
|
-
"delete"
|
|
38
|
-
]
|
|
39
|
-
},
|
|
40
|
-
"properties": {
|
|
41
|
-
"_id": {
|
|
42
|
-
"type": "string",
|
|
43
|
-
"index": true,
|
|
44
|
-
"x-vexData": "ObjectId"
|
|
45
|
-
},
|
|
46
|
-
"username": {
|
|
47
|
-
"type": "string"
|
|
48
|
-
},
|
|
49
|
-
"invoice_id": {
|
|
50
|
-
"type": "string",
|
|
51
|
-
"required": true,
|
|
52
|
-
"x-foreignKey": "invoice"
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
# Define Json Schema for VeryExpress
|
|
2
|
+
|
|
3
|
+
## x-documentConfig:
|
|
4
|
+
|
|
5
|
+
| Fields | Data Type | Options | Description |
|
|
6
|
+
| - | - | - | - |
|
|
7
|
+
| documentName | `string` | - | auto generated using file name. this value should be same as the collection name, it will used to name **Collection**, **TS Interface**, **ODM Model** etc. |
|
|
8
|
+
| methods | `array<string>` | `get`, `post`, `put`, `patch`, `delete` | array of **REST API Method** to be enable. |
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Properties Definition:
|
|
12
|
+
|
|
13
|
+
| Fields | Data Type | Required | options | Description |
|
|
14
|
+
| - | - | - | - | - |
|
|
15
|
+
| type | `string` | true | - | [JsonSchema's type field](https://json-schema.org/understanding-json-schema/reference/type) |
|
|
16
|
+
| required | `boolean` | false | - | rest api's validator will check value cannot be falsy / undefined. |
|
|
17
|
+
| x-vexData | `string` | false | `primaryKey`, `role` | determine veryExpress generation process. |
|
|
18
|
+
| x-foreignKey | `string` | false | - | `documentName` from other JsonSchema, auto indexed, use to join collection |
|
|
19
|
+
| x-foreignValue | `array<String>` | false | - | default selected fields for target collection |
|
|
20
|
+
<!-- | format | `string` | false | - | veryExpress did not handle this field | -->
|
|
21
|
+
|
|
22
|
+
### System Fields
|
|
23
|
+
System Fields is the properties to let generator run as expected,it should not be changed.
|
|
24
|
+
- `_id` : if defined in schema, it will auto being set as `"index": true`, `"x-vexData": "ObjectId"`.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
#### Example :
|
|
28
|
+
```JSON
|
|
29
|
+
{
|
|
30
|
+
"x-documentConfig": {
|
|
31
|
+
"documentName": "user", // auto generated using name
|
|
32
|
+
"methods": [
|
|
33
|
+
"get",
|
|
34
|
+
"post",
|
|
35
|
+
"put",
|
|
36
|
+
"patch",
|
|
37
|
+
"delete"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"properties": {
|
|
41
|
+
"_id": {
|
|
42
|
+
"type": "string",
|
|
43
|
+
"index": true,
|
|
44
|
+
"x-vexData": "ObjectId"
|
|
45
|
+
},
|
|
46
|
+
"username": {
|
|
47
|
+
"type": "string"
|
|
48
|
+
},
|
|
49
|
+
"invoice_id": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"required": true,
|
|
52
|
+
"x-foreignKey": "invoice"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
56
|
```
|
package/package.json
CHANGED
|
@@ -1,49 +1,50 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "very-express",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
|
|
5
|
-
"author": "Justin26l",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"main": "index.js",
|
|
8
|
-
"bin": {
|
|
9
|
-
"vex": "./dist/index.js"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"start": "node ./dist/index.js",
|
|
13
|
-
"dev": "npm run compile && npm run start",
|
|
14
|
-
"build": "npm run lint && npm run compile",
|
|
15
|
-
"lint": "eslint ./src --ext .ts --fix",
|
|
16
|
-
"compile": "node ./scripts/build.js && node ./scripts/copyTsTemplates.js"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"jsonSchema",
|
|
20
|
-
"express",
|
|
21
|
-
"RestApi",
|
|
22
|
-
"mongoDb",
|
|
23
|
-
"mongoose",
|
|
24
|
-
"json2mongoose"
|
|
25
|
-
],
|
|
26
|
-
"repository": {
|
|
27
|
-
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/Justin26l/VeryExpress.git"
|
|
29
|
-
},
|
|
30
|
-
"devDependencies": {
|
|
31
|
-
"@types/js-yaml": "^4.0.9",
|
|
32
|
-
"@types/minimist": "^1.2.5",
|
|
33
|
-
"@types/node": "^20.10.5",
|
|
34
|
-
"@types/passport": "^1.0.16",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
36
|
-
"@typescript-eslint/parser": "^6.18.1",
|
|
37
|
-
"dotenv": "^16.3.1",
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"json-schema-to-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
|
|
49
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "very-express",
|
|
3
|
+
"version": "0.5.3",
|
|
4
|
+
"description": "based on json schema and openapi, generate Express RestApi server with mongoDb ",
|
|
5
|
+
"author": "Justin26l",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "index.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"vex": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"start": "node ./dist/index.js",
|
|
13
|
+
"dev": "npm run compile && npm run start",
|
|
14
|
+
"build": "npm run lint && npm run compile",
|
|
15
|
+
"lint": "eslint ./src --ext .ts --fix",
|
|
16
|
+
"compile": "node ./scripts/build.js && node ./scripts/copyTsTemplates.js"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"jsonSchema",
|
|
20
|
+
"express",
|
|
21
|
+
"RestApi",
|
|
22
|
+
"mongoDb",
|
|
23
|
+
"mongoose",
|
|
24
|
+
"json2mongoose"
|
|
25
|
+
],
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/Justin26l/VeryExpress.git"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/js-yaml": "^4.0.9",
|
|
32
|
+
"@types/minimist": "^1.2.5",
|
|
33
|
+
"@types/node": "^20.10.5",
|
|
34
|
+
"@types/passport": "^1.0.16",
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^6.18.1",
|
|
36
|
+
"@typescript-eslint/parser": "^6.18.1",
|
|
37
|
+
"dotenv": "^16.3.1",
|
|
38
|
+
"diff-match-patch": "^1.0.5",
|
|
39
|
+
"esbuild": "0.23.0",
|
|
40
|
+
"eslint": "^8.57.1",
|
|
41
|
+
"js-yaml": "^4.1.0",
|
|
42
|
+
"json-schema-to-openapi-schema": "^0.4.0",
|
|
43
|
+
"json-schema-to-typescript": "^13.1.1",
|
|
44
|
+
"json2mongoose": "^0.4.4",
|
|
45
|
+
"minimist": "^1.2.8",
|
|
46
|
+
"mongoose": "^8.7.1",
|
|
47
|
+
"ts-node": "^10.9.2",
|
|
48
|
+
"typescript": "^5.3.3"
|
|
49
|
+
}
|
|
50
|
+
}
|
package/scripts/build.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const esbuild = require('esbuild');
|
|
2
|
-
|
|
3
|
-
esbuild.build({
|
|
4
|
-
entryPoints: ['./src/cli.ts'], // Your main file
|
|
5
|
-
bundle: true, // Bundle all dependencies
|
|
6
|
-
platform: 'node', // Specify the platform
|
|
7
|
-
target: 'es2016', // Target Node version, adjust as needed
|
|
8
|
-
minify: true, // Minify the output
|
|
9
|
-
tsconfig: './tsconfig.json', // Your tsconfig file
|
|
10
|
-
outfile: './dist/index.js', // Output file
|
|
11
|
-
}).catch((e) => {
|
|
12
|
-
console.error(e);
|
|
13
|
-
process.exit(1);
|
|
1
|
+
const esbuild = require('esbuild');
|
|
2
|
+
|
|
3
|
+
esbuild.build({
|
|
4
|
+
entryPoints: ['./src/cli.ts'], // Your main file
|
|
5
|
+
bundle: true, // Bundle all dependencies
|
|
6
|
+
platform: 'node', // Specify the platform
|
|
7
|
+
target: 'es2016', // Target Node version, adjust as needed
|
|
8
|
+
minify: true, // Minify the output
|
|
9
|
+
tsconfig: './tsconfig.json', // Your tsconfig file
|
|
10
|
+
outfile: './dist/index.js', // Output file
|
|
11
|
+
}).catch((e) => {
|
|
12
|
+
console.error(e);
|
|
13
|
+
process.exit(1);
|
|
14
14
|
});
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
// copy dir src/templates/utils to dist/templates/utils
|
|
2
|
-
const fs = require('fs');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* to copy template files into tsc output dir (dist)
|
|
7
|
-
*/
|
|
8
|
-
function copyDir (src, destination) {
|
|
9
|
-
|
|
10
|
-
if (!fs.existsSync(destination)) {
|
|
11
|
-
fs.mkdirSync(destination);
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
fs.
|
|
15
|
-
fs.mkdirSync(destination);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
fs.readdirSync(src).forEach((file) => {
|
|
19
|
-
const srcPath = path.join(src, file);
|
|
20
|
-
const destPath = path.join(destination, file);
|
|
21
|
-
const stat = fs.statSync(srcPath);
|
|
22
|
-
if (stat.isFile()) {
|
|
23
|
-
fs.writeFileSync(destPath, fs.readFileSync(srcPath));
|
|
24
|
-
} else if (stat.isDirectory()) {
|
|
25
|
-
copyDir(srcPath, destPath);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
copyDir('src/templates', 'dist/templates');
|
|
1
|
+
// copy dir src/templates/utils to dist/templates/utils
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* to copy template files into tsc output dir (dist)
|
|
7
|
+
*/
|
|
8
|
+
function copyDir (src, destination) {
|
|
9
|
+
|
|
10
|
+
if (!fs.existsSync(destination)) {
|
|
11
|
+
fs.mkdirSync(destination);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
fs.rmSync(destination, { recursive: true });
|
|
15
|
+
fs.mkdirSync(destination);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fs.readdirSync(src).forEach((file) => {
|
|
19
|
+
const srcPath = path.join(src, file);
|
|
20
|
+
const destPath = path.join(destination, file);
|
|
21
|
+
const stat = fs.statSync(srcPath);
|
|
22
|
+
if (stat.isFile()) {
|
|
23
|
+
fs.writeFileSync(destPath, fs.readFileSync(srcPath));
|
|
24
|
+
} else if (stat.isDirectory()) {
|
|
25
|
+
copyDir(srcPath, destPath);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
copyDir('src/templates', 'dist/templates');
|