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
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
{
|
|
2
|
-
"type": "object",
|
|
3
|
-
"x-documentConfig": {
|
|
4
|
-
"methods": [
|
|
5
|
-
"get",
|
|
6
|
-
"getList",
|
|
7
|
-
"post",
|
|
8
|
-
"patch"
|
|
9
|
-
],
|
|
10
|
-
"documentName": "User"
|
|
11
|
-
},
|
|
12
|
-
"properties": {
|
|
13
|
-
"_id": {
|
|
14
|
-
"type": "string",
|
|
15
|
-
"x-format": "ObjectId",
|
|
16
|
-
"index": true
|
|
17
|
-
},
|
|
18
|
-
"authProfiles": {
|
|
19
|
-
"type": "array",
|
|
20
|
-
"items": {
|
|
21
|
-
"type": "object",
|
|
22
|
-
"properties": {
|
|
23
|
-
"provider": {
|
|
24
|
-
"type": "string",
|
|
25
|
-
"index": true
|
|
26
|
-
},
|
|
27
|
-
"authId": {
|
|
28
|
-
"type": "string",
|
|
29
|
-
"index": true
|
|
30
|
-
},
|
|
31
|
-
"username": {
|
|
32
|
-
"type": "string"
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
"required": []
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"email": {
|
|
39
|
-
"type": "string",
|
|
40
|
-
"format": "email",
|
|
41
|
-
"index": true
|
|
42
|
-
},
|
|
43
|
-
"name": {
|
|
44
|
-
"type": "string",
|
|
45
|
-
"maxLength": 64,
|
|
46
|
-
"required": true
|
|
47
|
-
},
|
|
48
|
-
"active": {
|
|
49
|
-
"type": "boolean",
|
|
50
|
-
"default": true,
|
|
51
|
-
"required": true
|
|
52
|
-
},
|
|
53
|
-
"locale": {
|
|
54
|
-
"type": "string",
|
|
55
|
-
"maxLength": 8
|
|
56
|
-
},
|
|
57
|
-
"roles": {
|
|
58
|
-
"type": "array",
|
|
59
|
-
"x-vexData": "role",
|
|
60
|
-
"items": {
|
|
61
|
-
"type": "string",
|
|
62
|
-
"enum": [
|
|
63
|
-
"visitor",
|
|
64
|
-
"member",
|
|
65
|
-
"admin"
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
"default": [
|
|
69
|
-
"visitor"
|
|
70
|
-
]
|
|
71
|
-
},
|
|
72
|
-
"profileErrors": {
|
|
73
|
-
"type": "array",
|
|
74
|
-
"items": {
|
|
75
|
-
"type": "string"
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
"required": [
|
|
80
|
-
"name",
|
|
81
|
-
"active"
|
|
82
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"x-documentConfig": {
|
|
4
|
+
"methods": [
|
|
5
|
+
"get",
|
|
6
|
+
"getList",
|
|
7
|
+
"post",
|
|
8
|
+
"patch"
|
|
9
|
+
],
|
|
10
|
+
"documentName": "User"
|
|
11
|
+
},
|
|
12
|
+
"properties": {
|
|
13
|
+
"_id": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"x-format": "ObjectId",
|
|
16
|
+
"index": true
|
|
17
|
+
},
|
|
18
|
+
"authProfiles": {
|
|
19
|
+
"type": "array",
|
|
20
|
+
"items": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"properties": {
|
|
23
|
+
"provider": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"index": true
|
|
26
|
+
},
|
|
27
|
+
"authId": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"index": true
|
|
30
|
+
},
|
|
31
|
+
"username": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": []
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"email": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"format": "email",
|
|
41
|
+
"index": true
|
|
42
|
+
},
|
|
43
|
+
"name": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"maxLength": 64,
|
|
46
|
+
"required": true
|
|
47
|
+
},
|
|
48
|
+
"active": {
|
|
49
|
+
"type": "boolean",
|
|
50
|
+
"default": true,
|
|
51
|
+
"required": true
|
|
52
|
+
},
|
|
53
|
+
"locale": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"maxLength": 8
|
|
56
|
+
},
|
|
57
|
+
"roles": {
|
|
58
|
+
"type": "array",
|
|
59
|
+
"x-vexData": "role",
|
|
60
|
+
"items": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"enum": [
|
|
63
|
+
"visitor",
|
|
64
|
+
"member",
|
|
65
|
+
"admin"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"default": [
|
|
69
|
+
"visitor"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"profileErrors": {
|
|
73
|
+
"type": "array",
|
|
74
|
+
"items": {
|
|
75
|
+
"type": "string"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"required": [
|
|
80
|
+
"name",
|
|
81
|
+
"active"
|
|
82
|
+
]
|
|
83
83
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"x-documentConfig": {
|
|
4
|
+
"documentName": "Session",
|
|
5
|
+
"methods": []
|
|
6
|
+
},
|
|
7
|
+
"properties": {
|
|
8
|
+
"_id": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"x-format": "ObjectId",
|
|
11
|
+
"index": true
|
|
12
|
+
},
|
|
13
|
+
"sessionCode": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"index": true
|
|
16
|
+
},
|
|
17
|
+
"provider": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"required": true
|
|
20
|
+
},
|
|
21
|
+
"userId":{
|
|
22
|
+
"type": "string",
|
|
23
|
+
"x-format": "ObjectId",
|
|
24
|
+
"required": true
|
|
25
|
+
},
|
|
26
|
+
"expired": {
|
|
27
|
+
"type": "number",
|
|
28
|
+
"description": "expired time in unix timestamp format (ms)",
|
|
29
|
+
"required": true
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
package/dist/templates/root/.env
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
APP_HOST=http://localhost:3000
|
|
2
|
-
MONGODB_URI=mongodb://localhost:27017/veryExpressDB
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
APP_HOST=http://localhost:3000
|
|
2
|
+
MONGODB_URI=mongodb://localhost:27017/veryExpressDB
|
|
3
|
+
|
|
4
|
+
LOGIN_SUCCESS_REDIRECT_PATH=/logincallback
|
|
5
|
+
LOGIN_FAILED_REDIRECT_PATH=/logincallback
|
|
6
|
+
|
|
7
|
+
OAUTH_GOOGLE_CLIENTID=
|
|
8
|
+
OAUTH_GOOGLE_CLIENTSECRET=
|
|
9
|
+
|
|
10
|
+
OAUTH_GITHUB_CLIENTID=
|
|
11
|
+
OAUTH_GITHUB_CLIENTSECRET=
|
|
12
|
+
|
|
13
|
+
# OAUTH_APPLE_CLIENTID=
|
|
14
|
+
# OAUTH_APPLE_CLIENTSECRET=
|
|
15
|
+
|
|
16
|
+
ACCESS_TOKEN_EXPIRE_TIME='5m'
|
|
17
|
+
REFRESH_TOKEN_EXPIRE_TIME='15m'
|
|
18
|
+
|
|
19
|
+
JWT_ALGORITHM='HS256'
|
|
14
20
|
JWT_KEY0='my-secret-key0'
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# Use the official Node.js image as the base image
|
|
2
|
-
FROM node:14
|
|
3
|
-
|
|
4
|
-
# Set the working directory inside the container
|
|
5
|
-
WORKDIR /app
|
|
6
|
-
|
|
7
|
-
# Copy package.json and package-lock.json to the working directory
|
|
8
|
-
COPY package*.json ./
|
|
9
|
-
|
|
10
|
-
# Install dependencies
|
|
11
|
-
RUN npm install
|
|
12
|
-
|
|
13
|
-
# Copy only the /dist directory to the working directory
|
|
14
|
-
COPY dist ./dist
|
|
15
|
-
|
|
16
|
-
# Expose the port the app runs on
|
|
17
|
-
EXPOSE 3000
|
|
18
|
-
|
|
19
|
-
# Define the command to run the application
|
|
1
|
+
# Use the official Node.js image as the base image
|
|
2
|
+
FROM node:14
|
|
3
|
+
|
|
4
|
+
# Set the working directory inside the container
|
|
5
|
+
WORKDIR /app
|
|
6
|
+
|
|
7
|
+
# Copy package.json and package-lock.json to the working directory
|
|
8
|
+
COPY package*.json ./
|
|
9
|
+
|
|
10
|
+
# Install dependencies
|
|
11
|
+
RUN npm install
|
|
12
|
+
|
|
13
|
+
# Copy only the /dist directory to the working directory
|
|
14
|
+
COPY dist ./dist
|
|
15
|
+
|
|
16
|
+
# Expose the port the app runs on
|
|
17
|
+
EXPOSE 3000
|
|
18
|
+
|
|
19
|
+
# Define the command to run the application
|
|
20
20
|
CMD ["npm", "start"]
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
# This app is generated by [VeryExpress](https://github.com/Justin26l/VeryExpress)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
# Quick Start
|
|
5
|
-
|
|
6
|
-
1. check configuration file **vex.config.json** under your project root directory.
|
|
7
|
-
[vex.config.json](./vex.config.json)
|
|
8
|
-
|
|
9
|
-
2. generate the app with your vex.config settings.
|
|
10
|
-
*Note : every db schema changes require to regenerate app.
|
|
11
|
-
`vex`
|
|
12
|
-
3. you should saw a express typescript app being generated.
|
|
13
|
-
```
|
|
14
|
-
├── src/
|
|
15
|
-
│ └── ...
|
|
16
|
-
├── package.json
|
|
17
|
-
├── tsconfig.json
|
|
18
|
-
├── vex.config.json
|
|
19
|
-
├── .env
|
|
20
|
-
└── ...
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
4. start the generated express app.
|
|
24
|
-
```
|
|
25
|
-
npm i
|
|
26
|
-
npm build
|
|
27
|
-
npm run start
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
5. start the app in docker.
|
|
31
|
-
```
|
|
32
|
-
npm run docker-build
|
|
33
|
-
npm run docker-start
|
|
34
|
-
```
|
|
35
|
-
# Resource
|
|
36
|
-
- [Documents](https://github.com/Justin26l/VeryExpress/blob/main/README.md)
|
|
37
|
-
|
|
38
|
-
- [Discord](https://discord.gg/PZGMzDp7)
|
|
1
|
+
# This app is generated by [VeryExpress](https://github.com/Justin26l/VeryExpress)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# Quick Start
|
|
5
|
+
|
|
6
|
+
1. check configuration file **vex.config.json** under your project root directory.
|
|
7
|
+
[vex.config.json](./vex.config.json)
|
|
8
|
+
|
|
9
|
+
2. generate the app with your vex.config settings.
|
|
10
|
+
*Note : every db schema changes require to regenerate app.
|
|
11
|
+
`vex`
|
|
12
|
+
3. you should saw a express typescript app being generated.
|
|
13
|
+
```
|
|
14
|
+
├── src/
|
|
15
|
+
│ └── ...
|
|
16
|
+
├── package.json
|
|
17
|
+
├── tsconfig.json
|
|
18
|
+
├── vex.config.json
|
|
19
|
+
├── .env
|
|
20
|
+
└── ...
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
4. start the generated express app.
|
|
24
|
+
```
|
|
25
|
+
npm i
|
|
26
|
+
npm build
|
|
27
|
+
npm run start
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
5. start the app in docker.
|
|
31
|
+
```
|
|
32
|
+
npm run docker-build
|
|
33
|
+
npm run docker-start
|
|
34
|
+
```
|
|
35
|
+
# Resource
|
|
36
|
+
- [Documents](https://github.com/Justin26l/VeryExpress/blob/main/README.md)
|
|
37
|
+
|
|
38
|
+
- [Discord](https://discord.gg/PZGMzDp7)
|
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
{
|
|
2
|
-
"main": "index.js",
|
|
3
|
-
"scripts": {
|
|
4
|
-
"build": "tsc -p . && node scripts/build.js",
|
|
5
|
-
"start": "node dist/server.js",
|
|
6
|
-
"dev": "nodemon --watch src --exec ts-node src/server.ts",
|
|
7
|
-
"docker-build": "docker build -t very-express .",
|
|
8
|
-
"docker-start": "docker run -p 3000:3000 very-express"
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"cookie": "^0.6.0",
|
|
12
|
-
"cookie-parser": "^1.4.6",
|
|
13
|
-
"dotenv": "^16.4.4",
|
|
14
|
-
"express": "^4.18.2",
|
|
15
|
-
"express-validator": "^7.0.1",
|
|
16
|
-
"helmet": "^7.1.0",
|
|
17
|
-
"js-yaml": "^4.1.0",
|
|
18
|
-
"jsonwebtoken": "^9.0.2",
|
|
19
|
-
"mongo-ts-querystring": "^1.0.4",
|
|
20
|
-
"mongodb": "^5.6.0",
|
|
21
|
-
"mongoose": "^7.4.0",
|
|
22
|
-
"passport": "^0.7.0",
|
|
23
|
-
"passport-google-oauth20": "^2.0.0",
|
|
24
|
-
"passport-github": "^1.1.0",
|
|
25
|
-
"passport-jwt": "^4.0.1",
|
|
26
|
-
"swagger-ui-express": "^5.0.0"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/cookie-parser": "^1.4.7",
|
|
30
|
-
"@types/jsonwebtoken": "^9.0.7",
|
|
31
|
-
"@types/crypto-js": "^4.1.2",
|
|
32
|
-
"@types/dotenv": "^8.2.0",
|
|
33
|
-
"@types/express": "^4.17.17",
|
|
34
|
-
"@types/express-validator": "^3.0.0",
|
|
35
|
-
"@types/js-yaml": "^4.0.9",
|
|
36
|
-
"@types/mongodb": "^4.0.7",
|
|
37
|
-
"@types/node": "^20.4.2",
|
|
38
|
-
"@types/passport": "^1.0.16",
|
|
39
|
-
"@types/passport-google-oauth20": "^2.0.14",
|
|
40
|
-
"@types/passport-github": "^1.1.12",
|
|
41
|
-
"@types/sequelize": "^4.28.15",
|
|
42
|
-
"@types/swagger-ui-express": "^4.1.6",
|
|
43
|
-
"@types/ws": "^8.5.5",
|
|
44
|
-
"nodemon": "^2.0.22",
|
|
45
|
-
"strip-json-comments": "^5.0.1",
|
|
46
|
-
"ts-node": "^10.9.1",
|
|
47
|
-
"typescript": "^5.1.6"
|
|
48
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"main": "index.js",
|
|
3
|
+
"scripts": {
|
|
4
|
+
"build": "tsc -p . && node scripts/build.js",
|
|
5
|
+
"start": "node dist/server.js",
|
|
6
|
+
"dev": "nodemon --watch src --exec ts-node src/server.ts",
|
|
7
|
+
"docker-build": "docker build -t very-express .",
|
|
8
|
+
"docker-start": "docker run -p 3000:3000 very-express"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"cookie": "^0.6.0",
|
|
12
|
+
"cookie-parser": "^1.4.6",
|
|
13
|
+
"dotenv": "^16.4.4",
|
|
14
|
+
"express": "^4.18.2",
|
|
15
|
+
"express-validator": "^7.0.1",
|
|
16
|
+
"helmet": "^7.1.0",
|
|
17
|
+
"js-yaml": "^4.1.0",
|
|
18
|
+
"jsonwebtoken": "^9.0.2",
|
|
19
|
+
"mongo-ts-querystring": "^1.0.4",
|
|
20
|
+
"mongodb": "^5.6.0",
|
|
21
|
+
"mongoose": "^7.4.0",
|
|
22
|
+
"passport": "^0.7.0",
|
|
23
|
+
"passport-google-oauth20": "^2.0.0",
|
|
24
|
+
"passport-github": "^1.1.0",
|
|
25
|
+
"passport-jwt": "^4.0.1",
|
|
26
|
+
"swagger-ui-express": "^5.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/cookie-parser": "^1.4.7",
|
|
30
|
+
"@types/jsonwebtoken": "^9.0.7",
|
|
31
|
+
"@types/crypto-js": "^4.1.2",
|
|
32
|
+
"@types/dotenv": "^8.2.0",
|
|
33
|
+
"@types/express": "^4.17.17",
|
|
34
|
+
"@types/express-validator": "^3.0.0",
|
|
35
|
+
"@types/js-yaml": "^4.0.9",
|
|
36
|
+
"@types/mongodb": "^4.0.7",
|
|
37
|
+
"@types/node": "^20.4.2",
|
|
38
|
+
"@types/passport": "^1.0.16",
|
|
39
|
+
"@types/passport-google-oauth20": "^2.0.14",
|
|
40
|
+
"@types/passport-github": "^1.1.12",
|
|
41
|
+
"@types/sequelize": "^4.28.15",
|
|
42
|
+
"@types/swagger-ui-express": "^4.1.6",
|
|
43
|
+
"@types/ws": "^8.5.5",
|
|
44
|
+
"nodemon": "^2.0.22",
|
|
45
|
+
"strip-json-comments": "^5.0.1",
|
|
46
|
+
"ts-node": "^10.9.1",
|
|
47
|
+
"typescript": "^5.1.6"
|
|
48
|
+
}
|
|
49
49
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
document.addEventListener("DOMContentLoaded", function() {
|
|
3
|
+
console.log('Exchange Tokens from /auth/token');
|
|
4
|
+
let sessionCode = new URLSearchParams(location.search).get('code');
|
|
5
|
+
fetch(
|
|
6
|
+
'/auth/token?code=' + sessionCode, {
|
|
7
|
+
method: 'POST'
|
|
8
|
+
}
|
|
9
|
+
)
|
|
10
|
+
.then((res) => res.text())
|
|
11
|
+
.then((data) => {
|
|
12
|
+
const jsonData = JSON.parse(data);
|
|
13
|
+
document.querySelector("#tokenData").innerHTML = JSON.stringify(jsonData, null, 2);
|
|
14
|
+
localStorage.setItem('accessToken', jsonData.result.accessToken);
|
|
15
|
+
localStorage.setItem('accessTokenIndex', jsonData.result.accessTokenIndex);
|
|
16
|
+
localStorage.setItem('refreshToken', jsonData.result.refreshToken);
|
|
17
|
+
localStorage.setItem('refreshTokenIndex', jsonData.result.refreshTokenIndex);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
let jsonData = {};
|
|
2
|
+
|
|
3
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
4
|
+
jsonData = {
|
|
5
|
+
accessToken: localStorage.getItem("accessToken"),
|
|
6
|
+
accessTokenIndex: localStorage.getItem("accessTokenIndex"),
|
|
7
|
+
refreshToken: localStorage.getItem("refreshToken"),
|
|
8
|
+
refreshTokenIndex: localStorage.getItem("refreshTokenIndex"),
|
|
9
|
+
};
|
|
10
|
+
document.querySelector("#tokenData").innerHTML = JSON.stringify(jsonData, null, 2);
|
|
11
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
document.addEventListener("DOMContentLoaded", function () {
|
|
2
|
+
jsonPayload = {
|
|
3
|
+
refreshToken: localStorage.getItem("refreshToken"),
|
|
4
|
+
refreshTokenIndex: localStorage.getItem("refreshTokenIndex"),
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
fetch("/auth/refresh", {
|
|
8
|
+
method: "POST",
|
|
9
|
+
body: JSON.stringify(jsonPayload),
|
|
10
|
+
headers: {
|
|
11
|
+
"Content-Type": "application/json",
|
|
12
|
+
"Accept": "application/json",
|
|
13
|
+
"Authorization": "Bearer " + localStorage.getItem("accessToken"),
|
|
14
|
+
"X-Auth-Index": localStorage.getItem("accessTokenIndex")
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
.then(res => res.json())
|
|
18
|
+
.then((response) => {
|
|
19
|
+
localStorage.setItem("accessToken", response.accessToken);
|
|
20
|
+
localStorage.setItem("accessTokenIndex", response.accessTokenIndex);
|
|
21
|
+
document.querySelector("#tokenData").innerHTML = JSON.stringify(response, null, 2);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
// copy openapiDir to tsconfig's outDir
|
|
2
|
-
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
|
|
6
|
-
async function loadStripJsonComments() {
|
|
7
|
-
const { default: stripJsonComments } = await import('strip-json-comments');
|
|
8
|
-
return stripJsonComments;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async function main() {
|
|
12
|
-
// Load strip-json-comments dynamically
|
|
13
|
-
const stripJsonComments = await loadStripJsonComments();
|
|
14
|
-
|
|
15
|
-
const openapiDir = "{{openapiDir}}";
|
|
16
|
-
const tsconfigPath = "tsconfig.json"
|
|
17
|
-
|
|
18
|
-
// 1. read tsconfig.json to get outDir
|
|
19
|
-
const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf-8');
|
|
20
|
-
const tsconfig = JSON.parse(stripJsonComments(tsconfigContent));
|
|
21
|
-
const outDir = tsconfig.compilerOptions.outDir;
|
|
22
|
-
|
|
23
|
-
// 2. copy ./openapi to outDir
|
|
24
|
-
const outDirOpenapi = path.resolve(outDir, 'openapi');
|
|
25
|
-
if (!fs.existsSync(outDirOpenapi)) {
|
|
26
|
-
fs.mkdirSync(outDirOpenapi, { recursive: true });
|
|
27
|
-
}
|
|
28
|
-
fs.readdirSync(openapiDir).forEach((file) => {
|
|
29
|
-
fs.copyFileSync(path.resolve(openapiDir, file), path.resolve(outDirOpenapi, file));
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// Execute the main function
|
|
35
|
-
main()
|
|
36
|
-
.catch(err => {
|
|
37
|
-
console.error(err);
|
|
38
|
-
process.exit(1);
|
|
1
|
+
// copy openapiDir to tsconfig's outDir
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
async function loadStripJsonComments() {
|
|
7
|
+
const { default: stripJsonComments } = await import('strip-json-comments');
|
|
8
|
+
return stripJsonComments;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async function main() {
|
|
12
|
+
// Load strip-json-comments dynamically
|
|
13
|
+
const stripJsonComments = await loadStripJsonComments();
|
|
14
|
+
|
|
15
|
+
const openapiDir = "{{openapiDir}}";
|
|
16
|
+
const tsconfigPath = "tsconfig.json"
|
|
17
|
+
|
|
18
|
+
// 1. read tsconfig.json to get outDir
|
|
19
|
+
const tsconfigContent = fs.readFileSync(tsconfigPath, 'utf-8');
|
|
20
|
+
const tsconfig = JSON.parse(stripJsonComments(tsconfigContent));
|
|
21
|
+
const outDir = tsconfig.compilerOptions.outDir;
|
|
22
|
+
|
|
23
|
+
// 2. copy ./openapi to outDir
|
|
24
|
+
const outDirOpenapi = path.resolve(outDir, 'openapi');
|
|
25
|
+
if (!fs.existsSync(outDirOpenapi)) {
|
|
26
|
+
fs.mkdirSync(outDirOpenapi, { recursive: true });
|
|
27
|
+
}
|
|
28
|
+
fs.readdirSync(openapiDir).forEach((file) => {
|
|
29
|
+
fs.copyFileSync(path.resolve(openapiDir, file), path.resolve(outDirOpenapi, file));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
// Execute the main function
|
|
35
|
+
main()
|
|
36
|
+
.catch(err => {
|
|
37
|
+
console.error(err);
|
|
38
|
+
process.exit(1);
|
|
39
39
|
});
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Language and Environment */
|
|
6
|
-
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
7
|
-
|
|
8
|
-
/* Modules */
|
|
9
|
-
"module": "commonjs", /* Specify what module code is generated. */
|
|
10
|
-
|
|
11
|
-
/* Emit */
|
|
12
|
-
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
13
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
14
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
15
|
-
"allowArbitraryExtensions": true, /* Allow arbitrary file extensions. */
|
|
16
|
-
|
|
17
|
-
/* Type Checking */
|
|
18
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
19
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
20
|
-
}
|
|
21
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
+
|
|
5
|
+
/* Language and Environment */
|
|
6
|
+
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
7
|
+
|
|
8
|
+
/* Modules */
|
|
9
|
+
"module": "commonjs", /* Specify what module code is generated. */
|
|
10
|
+
|
|
11
|
+
/* Emit */
|
|
12
|
+
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
13
|
+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
14
|
+
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
15
|
+
"allowArbitraryExtensions": true, /* Allow arbitrary file extensions. */
|
|
16
|
+
|
|
17
|
+
/* Type Checking */
|
|
18
|
+
"strict": true, /* Enable all strict type-checking options. */
|
|
19
|
+
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
22
|
|