very-express 0.9.0 → 0.10.0

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.
Files changed (129) hide show
  1. package/.tmp/als-proof.mjs +15 -0
  2. package/.tmp/als-proof2.mjs +9 -0
  3. package/.tmp/gen/out/.env +41 -0
  4. package/.tmp/gen/out/.vex/meta.json +381 -0
  5. package/.tmp/gen/out/Dockerfile +20 -0
  6. package/.tmp/gen/out/README.md +39 -0
  7. package/.tmp/gen/out/package.json +51 -0
  8. package/.tmp/gen/out/public/css/style.css +8 -0
  9. package/.tmp/gen/out/public/js/deleteaccount.js +80 -0
  10. package/.tmp/gen/out/public/js/login.js +59 -0
  11. package/.tmp/gen/out/public/js/logincallback.js +19 -0
  12. package/.tmp/gen/out/public/js/mytokens.js +11 -0
  13. package/.tmp/gen/out/public/js/refreshtokens.js +23 -0
  14. package/.tmp/gen/out/scripts/build.js +39 -0
  15. package/.tmp/gen/out/scripts/oacg-fix.js +83 -0
  16. package/.tmp/gen/out/tsconfig.json +30 -0
  17. package/.tmp/gen/out/tsoa.json +32 -0
  18. package/.tmp/gen/schemas/Project.json +50 -0
  19. package/.tmp/gen/schemas/Session.json +49 -0
  20. package/.tmp/gen/schemas/User.json +81 -0
  21. package/.tmp/gen/schemas/UserAuthProfiles.json +54 -0
  22. package/.tmp/gen/schemas/UserRole.json +40 -0
  23. package/.tmp/gen/schemas/UserTenant.json +39 -0
  24. package/.tmp/gen/vex.config.json +39 -0
  25. package/.tmp/gen0/out/.env +41 -0
  26. package/.tmp/gen0/out/.vex/meta.json +323 -0
  27. package/.tmp/gen0/out/Dockerfile +20 -0
  28. package/.tmp/gen0/out/README.md +39 -0
  29. package/.tmp/gen0/out/package.json +51 -0
  30. package/.tmp/gen0/out/public/css/style.css +8 -0
  31. package/.tmp/gen0/out/public/js/deleteaccount.js +80 -0
  32. package/.tmp/gen0/out/public/js/login.js +59 -0
  33. package/.tmp/gen0/out/public/js/logincallback.js +19 -0
  34. package/.tmp/gen0/out/public/js/mytokens.js +11 -0
  35. package/.tmp/gen0/out/public/js/refreshtokens.js +23 -0
  36. package/.tmp/gen0/out/scripts/build.js +39 -0
  37. package/.tmp/gen0/out/scripts/oacg-fix.js +83 -0
  38. package/.tmp/gen0/out/tsconfig.json +30 -0
  39. package/.tmp/gen0/out/tsoa.json +32 -0
  40. package/.tmp/gen0/schemas/Session.json +49 -0
  41. package/.tmp/gen0/schemas/User.json +81 -0
  42. package/.tmp/gen0/schemas/UserAuthProfiles.json +54 -0
  43. package/.tmp/gen0/schemas/UserRole.json +38 -0
  44. package/.tmp/gen0/vex.config.json +32 -0
  45. package/.tmp/gend/out/.env +41 -0
  46. package/.tmp/gend/out/.vex/meta.json +317 -0
  47. package/.tmp/gend/out/Dockerfile +20 -0
  48. package/.tmp/gend/out/README.md +39 -0
  49. package/.tmp/gend/out/package.json +51 -0
  50. package/.tmp/gend/out/public/css/style.css +8 -0
  51. package/.tmp/gend/out/public/js/deleteaccount.js +80 -0
  52. package/.tmp/gend/out/public/js/login.js +59 -0
  53. package/.tmp/gend/out/public/js/logincallback.js +19 -0
  54. package/.tmp/gend/out/public/js/mytokens.js +11 -0
  55. package/.tmp/gend/out/public/js/refreshtokens.js +23 -0
  56. package/.tmp/gend/out/scripts/build.js +39 -0
  57. package/.tmp/gend/out/scripts/oacg-fix.js +83 -0
  58. package/.tmp/gend/out/tsconfig.json +30 -0
  59. package/.tmp/gend/out/tsoa.json +32 -0
  60. package/.tmp/gend/schemas/Session.json +49 -0
  61. package/.tmp/gend/schemas/User.json +81 -0
  62. package/.tmp/gend/schemas/UserAuthProfiles.json +54 -0
  63. package/.tmp/gend/schemas/UserContact.json +40 -0
  64. package/.tmp/gend/schemas/UserNote.json +27 -0
  65. package/.tmp/gend/vex.config.json +33 -0
  66. package/.tmp/genh/out/.env +41 -0
  67. package/.tmp/genh/out/.vex/meta.json +323 -0
  68. package/.tmp/genh/out/Dockerfile +20 -0
  69. package/.tmp/genh/out/README.md +39 -0
  70. package/.tmp/genh/out/package.json +51 -0
  71. package/.tmp/genh/out/public/css/style.css +8 -0
  72. package/.tmp/genh/out/public/js/deleteaccount.js +80 -0
  73. package/.tmp/genh/out/public/js/login.js +59 -0
  74. package/.tmp/genh/out/public/js/logincallback.js +19 -0
  75. package/.tmp/genh/out/public/js/mytokens.js +11 -0
  76. package/.tmp/genh/out/public/js/refreshtokens.js +23 -0
  77. package/.tmp/genh/out/scripts/build.js +39 -0
  78. package/.tmp/genh/out/scripts/oacg-fix.js +83 -0
  79. package/.tmp/genh/out/tsconfig.json +30 -0
  80. package/.tmp/genh/out/tsoa.json +32 -0
  81. package/.tmp/genh/schemas/Project.json +41 -0
  82. package/.tmp/genh/schemas/Session.json +49 -0
  83. package/.tmp/genh/schemas/User.json +81 -0
  84. package/.tmp/genh/schemas/UserAuthProfiles.json +54 -0
  85. package/.tmp/genh/schemas/UserTenant.json +39 -0
  86. package/.tmp/genh/vex.config.json +31 -0
  87. package/.tmp/gens/out/.env +41 -0
  88. package/.tmp/gens/out/.vex/meta.json +335 -0
  89. package/.tmp/gens/out/Dockerfile +20 -0
  90. package/.tmp/gens/out/README.md +39 -0
  91. package/.tmp/gens/out/package.json +51 -0
  92. package/.tmp/gens/out/public/css/style.css +8 -0
  93. package/.tmp/gens/out/public/js/deleteaccount.js +80 -0
  94. package/.tmp/gens/out/public/js/login.js +59 -0
  95. package/.tmp/gens/out/public/js/logincallback.js +19 -0
  96. package/.tmp/gens/out/public/js/mytokens.js +11 -0
  97. package/.tmp/gens/out/public/js/refreshtokens.js +23 -0
  98. package/.tmp/gens/out/scripts/build.js +39 -0
  99. package/.tmp/gens/out/scripts/oacg-fix.js +83 -0
  100. package/.tmp/gens/out/tsconfig.json +30 -0
  101. package/.tmp/gens/out/tsoa.json +32 -0
  102. package/.tmp/gens/schemas/Session.json +49 -0
  103. package/.tmp/gens/schemas/User.json +81 -0
  104. package/.tmp/gens/schemas/UserAuthProfiles.json +54 -0
  105. package/.tmp/gens/schemas/UserRole.json +38 -0
  106. package/.tmp/gens/vex.config.json +32 -0
  107. package/.tmp/npmtest/package.json +1 -0
  108. package/.tmp/ro-test +0 -0
  109. package/AGENTS.md +3 -3
  110. package/README.md +1 -0
  111. package/dist/index.js +946 -653
  112. package/dist/templates/_middlewares/Authentication.ts +1 -1
  113. package/dist/templates/_middlewares/UserContext.ts +30 -4
  114. package/dist/templates/_services/MongooseRepositoryAdapter.ts +68 -4
  115. package/dist/templates/_services/TypeOrmRepositoryAdapter.ts +68 -18
  116. package/dist/templates/_services/auth/JWTService.ts +13 -2
  117. package/dist/templates/_tenant/TenantScopeContext.ts +56 -0
  118. package/dist/templates/_types/auth.ts +7 -1
  119. package/dist/templates/_types/vex/VexRepository.ts +2 -2
  120. package/dist/templates/tenantJsonSchema/UserTenant.json +33 -0
  121. package/docs/architecture/databaseTargets.md +15 -7
  122. package/docs/architecture/generatorPipeline.md +2 -1
  123. package/docs/features/accountDeletion.md +61 -9
  124. package/docs/features/dataIsolation.md +58 -31
  125. package/docs/features/tenantIsolation.md +138 -0
  126. package/docs/releaseNote/v0-10-0.md +147 -0
  127. package/docs/vexJsonSchema.md +22 -0
  128. package/package.json +1 -1
  129. package/vitest.config.ts +3 -0
@@ -0,0 +1,41 @@
1
+ APP_HOST=http://localhost
2
+ APP_PORT=3000
3
+ MONGODB_URI=mongodb://localhost:27017/veryExpressDB
4
+ SQL_URI=postgresql://username:password@localhost:5432/mydatabase
5
+ SQL_CA=""
6
+ SQL_INSECURE_TLS=true
7
+ SQL_SYNCHRONIZE=true
8
+
9
+ LOGIN_SUCCESS_REDIRECT_PATH=/logincallback
10
+ LOGIN_FAILED_REDIRECT_PATH=/logincallback
11
+
12
+ # OAUTH
13
+ OAUTH_GOOGLE_CLIENTID=
14
+ OAUTH_GOOGLE_CLIENTSECRET=
15
+ OAUTH_GITHUB_CLIENTID=
16
+ OAUTH_GITHUB_CLIENTSECRET=
17
+ # OAUTH_MICROSOFT_CLIENTID=
18
+ # OAUTH_MICROSOFT_CLIENTSECRET=
19
+ # OAUTH_APPLE_CLIENTID=
20
+ # OAUTH_APPLE_CLIENTSECRET=
21
+
22
+ # FIREBASE (auth.firebase in vex.config.json) — see docs/appGenerated/auth.md
23
+ # Server credential: firebase-admin verifies ID tokens, so the project's service account is required.
24
+ # The JSON itself, as one value — generate it in the Firebase console:
25
+ # Project settings > Service accounts > Generate new private key.
26
+ FIREBASE_SERVICE_ACCOUNT_JSON=
27
+ # Browser config: Firebase's *public* web app values, served to the login page by design. There is no
28
+ # secret among them, and no appId — Firebase Auth does not read one.
29
+ FIREBASE_WEB_API_KEY=
30
+ FIREBASE_WEB_AUTH_DOMAIN=
31
+ FIREBASE_WEB_PROJECT_ID=
32
+ # Optional: which sign-in methods the login page renders a button for, comma separated. Defaults to
33
+ # google. The server accepts any provider it knows regardless of this list.
34
+ # FIREBASE_PROVIDERS=google
35
+
36
+ # JWT token
37
+ ACCESS_TOKEN_EXPIRE_TIME='1h'
38
+ REFRESH_TOKEN_EXPIRE_TIME='24h'
39
+ SESSION_COOKIE_SECRET='my-session-cookie-secret'
40
+ JWT_ALGORITHM='HS256'
41
+ JWT_SECRET0='my-secret-key0'
@@ -0,0 +1,323 @@
1
+ {
2
+ "lastGeneratedVersion": "0.9.0",
3
+ "files": {
4
+ "..": {
5
+ "vex.config.json": {
6
+ "lastWriteVersion": "0.9.0",
7
+ "allowOverwrite": true
8
+ },
9
+ "schemas": {
10
+ "Session.json": {
11
+ "lastWriteVersion": "0.9.0",
12
+ "allowOverwrite": true
13
+ },
14
+ "User.json": {
15
+ "lastWriteVersion": "0.9.0",
16
+ "allowOverwrite": true
17
+ },
18
+ "UserAuthProfiles.json": {
19
+ "lastWriteVersion": "0.9.0",
20
+ "allowOverwrite": true
21
+ },
22
+ "UserRole.json": {
23
+ "lastWriteVersion": "0.9.0",
24
+ "allowOverwrite": true
25
+ }
26
+ }
27
+ },
28
+ "src": {
29
+ "system": {
30
+ "_controllers": {
31
+ "_ControllerFactory.gen.ts": {
32
+ "lastWriteVersion": "0.9.0",
33
+ "allowOverwrite": true
34
+ },
35
+ "UserController.gen.ts": {
36
+ "lastWriteVersion": "0.9.0",
37
+ "allowOverwrite": true
38
+ }
39
+ },
40
+ "_middlewares": {
41
+ "Authentication.gen.ts": {
42
+ "lastWriteVersion": "0.9.0",
43
+ "allowOverwrite": true
44
+ },
45
+ "JoinWhitelistMiddleware.gen.ts": {
46
+ "lastWriteVersion": "0.9.0",
47
+ "allowOverwrite": true
48
+ },
49
+ "UserContext.gen.ts": {
50
+ "lastWriteVersion": "0.9.0",
51
+ "allowOverwrite": true
52
+ },
53
+ "tsoaAuthentication.gen.ts": {
54
+ "lastWriteVersion": "0.9.0",
55
+ "allowOverwrite": true
56
+ },
57
+ "RoleBaseAccessControl.gen.ts": {
58
+ "lastWriteVersion": "0.9.0",
59
+ "allowOverwrite": true
60
+ },
61
+ "JoinWhitelistRegistry.gen.ts": {
62
+ "lastWriteVersion": "0.9.0",
63
+ "allowOverwrite": true
64
+ },
65
+ "DataIsolationRegistry.gen.ts": {
66
+ "lastWriteVersion": "0.9.0",
67
+ "allowOverwrite": true
68
+ },
69
+ "VexFieldRegistry.gen.ts": {
70
+ "lastWriteVersion": "0.9.0",
71
+ "allowOverwrite": true
72
+ }
73
+ },
74
+ "_routes": {
75
+ "FirebaseAuthUI.gen.ts": {
76
+ "lastWriteVersion": "0.9.0",
77
+ "allowOverwrite": true
78
+ },
79
+ "LoginUI.gen.ts": {
80
+ "lastWriteVersion": "0.9.0",
81
+ "allowOverwrite": true
82
+ },
83
+ "oauth": {
84
+ "OAuthRouteFactory.gen.ts": {
85
+ "lastWriteVersion": "0.9.0",
86
+ "allowOverwrite": true
87
+ }
88
+ },
89
+ "SwaggerRouter.gen.ts": {
90
+ "lastWriteVersion": "0.9.0",
91
+ "allowOverwrite": true
92
+ }
93
+ },
94
+ "_services": {
95
+ "MongooseRepositoryAdapter.gen.ts": {
96
+ "lastWriteVersion": "0.9.0",
97
+ "allowOverwrite": true
98
+ },
99
+ "TypeOrmRepositoryAdapter.gen.ts": {
100
+ "lastWriteVersion": "0.9.0",
101
+ "allowOverwrite": true
102
+ },
103
+ "VexDb.gen.ts": {
104
+ "lastWriteVersion": "0.9.0",
105
+ "allowOverwrite": true
106
+ },
107
+ "VexDbConnector.gen.ts": {
108
+ "lastWriteVersion": "0.9.0",
109
+ "allowOverwrite": true
110
+ },
111
+ "VexSystem.gen.ts": {
112
+ "lastWriteVersion": "0.9.0",
113
+ "allowOverwrite": true
114
+ },
115
+ "auth": {
116
+ "JWTKeyStore.gen.ts": {
117
+ "lastWriteVersion": "0.9.0",
118
+ "allowOverwrite": true
119
+ },
120
+ "JWTService.gen.ts": {
121
+ "lastWriteVersion": "0.9.0",
122
+ "allowOverwrite": true
123
+ },
124
+ "AccountStateGuard.gen.ts": {
125
+ "lastWriteVersion": "0.9.0",
126
+ "allowOverwrite": true
127
+ }
128
+ },
129
+ "oauth": {
130
+ "OAuthProfileMap.gen.ts": {
131
+ "lastWriteVersion": "0.9.0",
132
+ "allowOverwrite": true
133
+ },
134
+ "OAuthStrategyService.gen.ts": {
135
+ "lastWriteVersion": "0.9.0",
136
+ "allowOverwrite": true
137
+ }
138
+ }
139
+ },
140
+ "_types": {
141
+ "auth.gen.ts": {
142
+ "lastWriteVersion": "0.9.0",
143
+ "allowOverwrite": true
144
+ },
145
+ "vex": {
146
+ "VexRepository.gen.ts": {
147
+ "lastWriteVersion": "0.9.0",
148
+ "allowOverwrite": true
149
+ },
150
+ "VexRequest.gen.ts": {
151
+ "lastWriteVersion": "0.9.0",
152
+ "allowOverwrite": true
153
+ },
154
+ "VexResErr.gen.ts": {
155
+ "lastWriteVersion": "0.9.0",
156
+ "allowOverwrite": true
157
+ },
158
+ "VexResOk.gen.ts": {
159
+ "lastWriteVersion": "0.9.0",
160
+ "allowOverwrite": true
161
+ },
162
+ "VexResponse.gen.ts": {
163
+ "lastWriteVersion": "0.9.0",
164
+ "allowOverwrite": true
165
+ },
166
+ "index.ts": {
167
+ "lastWriteVersion": "0.9.0",
168
+ "allowOverwrite": true
169
+ }
170
+ },
171
+ "Session.gen.ts": {
172
+ "lastWriteVersion": "0.9.0",
173
+ "allowOverwrite": true
174
+ },
175
+ "User.gen.ts": {
176
+ "lastWriteVersion": "0.9.0",
177
+ "allowOverwrite": true
178
+ },
179
+ "UserAuthProfiles.gen.ts": {
180
+ "lastWriteVersion": "0.9.0",
181
+ "allowOverwrite": true
182
+ },
183
+ "UserRole.gen.ts": {
184
+ "lastWriteVersion": "0.9.0",
185
+ "allowOverwrite": true
186
+ }
187
+ },
188
+ "_utils": {
189
+ "hash.gen.ts": {
190
+ "lastWriteVersion": "0.9.0",
191
+ "allowOverwrite": true
192
+ },
193
+ "index.ts": {
194
+ "lastWriteVersion": "0.9.0",
195
+ "allowOverwrite": true
196
+ },
197
+ "logger.gen.ts": {
198
+ "lastWriteVersion": "0.9.0",
199
+ "allowOverwrite": true
200
+ },
201
+ "processTimer.gen.ts": {
202
+ "lastWriteVersion": "0.9.0",
203
+ "allowOverwrite": true
204
+ },
205
+ "response.gen.ts": {
206
+ "lastWriteVersion": "0.9.0",
207
+ "allowOverwrite": true
208
+ },
209
+ "validator.gen.ts": {
210
+ "lastWriteVersion": "0.9.0",
211
+ "allowOverwrite": true
212
+ }
213
+ },
214
+ "_roles": {
215
+ "_RoleFactory.gen.ts": {
216
+ "lastWriteVersion": "0.9.0",
217
+ "allowOverwrite": true
218
+ },
219
+ "member.gen.ts": {
220
+ "lastWriteVersion": "0.9.0",
221
+ "allowOverwrite": true
222
+ },
223
+ "index.ts": {
224
+ "lastWriteVersion": "0.9.0",
225
+ "allowOverwrite": true
226
+ }
227
+ },
228
+ "_models": {
229
+ "SessionModel.gen.ts": {
230
+ "lastWriteVersion": "0.9.0",
231
+ "allowOverwrite": true
232
+ },
233
+ "UserModel.gen.ts": {
234
+ "lastWriteVersion": "0.9.0",
235
+ "allowOverwrite": true
236
+ },
237
+ "UserAuthProfilesModel.gen.ts": {
238
+ "lastWriteVersion": "0.9.0",
239
+ "allowOverwrite": true
240
+ },
241
+ "UserRoleModel.gen.ts": {
242
+ "lastWriteVersion": "0.9.0",
243
+ "allowOverwrite": true
244
+ }
245
+ }
246
+ },
247
+ "roles": {
248
+ "member.json": {
249
+ "lastWriteVersion": "0.9.0",
250
+ "allowOverwrite": true
251
+ }
252
+ },
253
+ "server.ts": {
254
+ "lastWriteVersion": "0.9.0",
255
+ "allowOverwrite": true
256
+ }
257
+ },
258
+ "Dockerfile": {
259
+ "lastWriteVersion": "0.9.0",
260
+ "allowOverwrite": true
261
+ },
262
+ "README.md": {
263
+ "lastWriteVersion": "0.9.0",
264
+ "allowOverwrite": true
265
+ },
266
+ "public": {
267
+ "css": {
268
+ "style.css": {
269
+ "lastWriteVersion": "0.9.0",
270
+ "allowOverwrite": true
271
+ }
272
+ },
273
+ "js": {
274
+ "deleteaccount.js": {
275
+ "lastWriteVersion": "0.9.0",
276
+ "allowOverwrite": true
277
+ },
278
+ "login.js": {
279
+ "lastWriteVersion": "0.9.0",
280
+ "allowOverwrite": true
281
+ },
282
+ "logincallback.js": {
283
+ "lastWriteVersion": "0.9.0",
284
+ "allowOverwrite": true
285
+ },
286
+ "mytokens.js": {
287
+ "lastWriteVersion": "0.9.0",
288
+ "allowOverwrite": true
289
+ },
290
+ "refreshtokens.js": {
291
+ "lastWriteVersion": "0.9.0",
292
+ "allowOverwrite": true
293
+ }
294
+ }
295
+ },
296
+ "scripts": {
297
+ "build.js": {
298
+ "lastWriteVersion": "0.9.0",
299
+ "allowOverwrite": true
300
+ },
301
+ "oacg-fix.js": {
302
+ "lastWriteVersion": "0.9.0",
303
+ "allowOverwrite": true
304
+ }
305
+ },
306
+ "tsconfig.json": {
307
+ "lastWriteVersion": "0.9.0",
308
+ "allowOverwrite": true
309
+ },
310
+ "package.json": {
311
+ "lastWriteVersion": "0.9.0",
312
+ "allowOverwrite": true
313
+ },
314
+ ".env": {
315
+ "lastWriteVersion": "0.9.0",
316
+ "allowOverwrite": true
317
+ },
318
+ "tsoa.json": {
319
+ "lastWriteVersion": "0.9.0",
320
+ "allowOverwrite": true
321
+ }
322
+ }
323
+ }
@@ -0,0 +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
20
+ CMD ["npm", "start"]
@@ -0,0 +1,39 @@
1
+ # This app is generated by [VeryExpress](https://github.com/Justin26l/VeryExpress)
2
+
3
+
4
+ # Quick Start
5
+ 1. install `very-express` from npm
6
+ `npm install -g very-express` or `npm update -g very-express`
7
+
8
+ 2. check configuration file [vex.config.json](./vex.config.json) under project root directory and keep it updated (re-generate the app with very-express).
9
+ `vex`
10
+
11
+ 3. we should have a express typescript app.
12
+ ```
13
+ ├── src/
14
+ │ └── openapi
15
+ │ └── roles (role based access control settings)
16
+ │ └── system (very express generated app)
17
+ ├── package.json
18
+ ├── tsconfig.json
19
+ ├── vex.config.json
20
+ ├── .env
21
+ └── ...
22
+ ```
23
+
24
+ 4. start the generated express app.
25
+ ```
26
+ npm i
27
+ npm build
28
+ npm run start
29
+ ```
30
+
31
+ 5. start the app in docker.
32
+ ```
33
+ npm run docker-build
34
+ npm run docker-start
35
+ ```
36
+
37
+ # Resource
38
+ - [Documents](https://github.com/Justin26l/VeryExpress/blob/main/README.md)
39
+ - [VeryExpress Discord](https://discord.gg/PZGMzDp7)
@@ -0,0 +1,51 @@
1
+ {
2
+ "main": "index.js",
3
+ "scripts": {
4
+ "build": "npm run openapi && tsc -p . && node scripts/build.js",
5
+ "start": "node dist/server.js",
6
+ "dev": "nodemon --watch src --ext ts --ignore src/system/_routes/tsoa_routes.ts --ignore src/openapi/ --exec \"tsoa spec-and-routes && ts-node src/server.ts\"",
7
+ "openapi": "tsoa spec-and-routes",
8
+ "docker-build": "docker build -t very-express .",
9
+ "docker-start": "docker run -p 3000:3000 very-express"
10
+ },
11
+ "dependencies": {
12
+ "cookie": "^0.6.0",
13
+ "cookie-parser": "^1.4.6",
14
+ "dotenv": "^16.4.4",
15
+ "express": "^4.18.2",
16
+ "firebase-admin": "^14.1.0",
17
+ "helmet": "^7.1.0",
18
+ "js-yaml": "^4.1.0",
19
+ "jsonwebtoken": "^9.0.2",
20
+ "passport": "^0.7.0",
21
+ "passport-github": "^1.1.0",
22
+ "passport-google-oauth20": "^2.0.0",
23
+ "passport-jwt": "^4.0.1",
24
+ "pg": "^8.20.0",
25
+ "reflect-metadata": "^0.2.2",
26
+ "swagger-ui-express": "^5.0.0",
27
+ "tsoa": "^7.0.0-alpha.0",
28
+ "typeorm": "^0.3.20"
29
+ },
30
+ "devDependencies": {
31
+ "@types/cookie-parser": "^1.4.7",
32
+ "@types/crypto-js": "^4.1.2",
33
+ "@types/dotenv": "^8.2.0",
34
+ "@types/express": "^4.17.17",
35
+ "@types/js-yaml": "^4.0.9",
36
+ "@types/jsonwebtoken": "^9.0.7",
37
+ "@types/mongodb": "^4.0.7",
38
+ "@types/ms": "^2.1.0",
39
+ "@types/node": "^20.4.2",
40
+ "@types/passport": "^1.0.16",
41
+ "@types/passport-github": "^1.1.12",
42
+ "@types/passport-google-oauth20": "^2.0.14",
43
+ "@types/pg": "^8.11.0",
44
+ "@types/swagger-ui-express": "^4.1.6",
45
+ "@types/ws": "^8.5.5",
46
+ "nodemon": "^2.0.22",
47
+ "strip-json-comments": "^5.0.1",
48
+ "ts-node": "^10.9.1",
49
+ "typescript": "^5.1.6"
50
+ }
51
+ }
@@ -0,0 +1,8 @@
1
+
2
+ pre {
3
+ background-color: #f4f4f4;
4
+ padding: 20px;
5
+ overflow: auto;
6
+ border: 1px solid #ccc;
7
+ white-space: pre-wrap;
8
+ }
@@ -0,0 +1,80 @@
1
+ // Self-service account deletion page.
2
+ //
3
+ // Sends the access token the same way the rest of the app does — Authorization + X-Auth-Index —
4
+ // and clears the stored tokens on success, because the account is gone the moment the tombstone
5
+ // is written: keeping a token the server will now reject only produces confusing 401s.
6
+
7
+ // The page loads this script from <head>, so it must wait for the DOM: at parse time the
8
+ // button does not exist yet and getElementById would return null.
9
+ document.addEventListener("DOMContentLoaded", function () {
10
+ var button = document.getElementById("deleteAccountBtn");
11
+ var input = document.getElementById("confirmInput");
12
+ var result = document.getElementById("deleteResult");
13
+
14
+ if (!button || !input || !result) return;
15
+
16
+ function clearTokens() {
17
+ localStorage.removeItem("accessToken");
18
+ localStorage.removeItem("accessTokenIndex");
19
+ localStorage.removeItem("refreshToken");
20
+ localStorage.removeItem("refreshTokenIndex");
21
+ }
22
+
23
+ function render(data) {
24
+ result.textContent = JSON.stringify(data, null, 2);
25
+ }
26
+
27
+ button.addEventListener("click", function () {
28
+ if (input.value !== "DELETE") {
29
+ render({ error: 'Type DELETE in the box to confirm.' });
30
+ return;
31
+ }
32
+
33
+ button.disabled = true;
34
+ render({ status: "Deleting…" });
35
+
36
+ fetch("/api/auth/delete-account", {
37
+ method: "POST",
38
+ credentials: "include",
39
+ headers: {
40
+ "Content-Type": "application/json",
41
+ "Authorization": "Bearer " + (localStorage.getItem("accessToken") || ""),
42
+ "X-Auth-Index": localStorage.getItem("accessTokenIndex") || "",
43
+ },
44
+ })
45
+ .then(function (response) {
46
+ // read as text first: an error response may not be JSON (a proxy or the
47
+ // express error handler can return HTML), and response.json() would then
48
+ // reject and hide the real status behind a parse error
49
+ return response.text().then(function (text) {
50
+ var body;
51
+ try {
52
+ body = text ? JSON.parse(text) : {};
53
+ }
54
+ catch (e) {
55
+ body = { raw: text };
56
+ }
57
+
58
+ return { ok: response.ok, status: response.status, body: body };
59
+ });
60
+ })
61
+ .then(function (outcome) {
62
+ if (!outcome.ok) {
63
+ render({ status: outcome.status, error: outcome.body });
64
+ button.disabled = false;
65
+ return;
66
+ }
67
+
68
+ clearTokens();
69
+ render({
70
+ status: "Account deleted. You have been signed out.",
71
+ result: outcome.body,
72
+ });
73
+ input.value = "";
74
+ })
75
+ .catch(function (err) {
76
+ render({ error: String(err) });
77
+ button.disabled = false;
78
+ });
79
+ });
80
+ });
@@ -0,0 +1,59 @@
1
+
2
+ document.addEventListener("DOMContentLoaded", function () {
3
+ // add event listener to login button
4
+ document.querySelector("#localLoginBtn").addEventListener("click", function () {
5
+ // call /api/auth/local
6
+ fetch("/api/auth/local", {
7
+ method: "POST",
8
+ headers: {
9
+ "Content-Type": "application/json"
10
+ },
11
+ body: JSON.stringify({
12
+ email: document.querySelector("#email").value,
13
+ password: document.querySelector("#password").value
14
+ })
15
+ })
16
+ .then(async (res) => {
17
+ if (res.status === 301 || res.status === 302) {
18
+ const data = await res.json();
19
+ if (data.result?.url) {
20
+ window.location.href = data.result?.url;
21
+ }
22
+ else {
23
+ alert("Login successful, but no redirect URL provided.");
24
+ }
25
+ }
26
+ else {
27
+ const data = await res.json();
28
+ alert("Login Failed: " + data.message);
29
+ }
30
+ })
31
+ .catch((err) => {
32
+ console.error("Error during login:", err);
33
+ alert("Login Error: " + err.message);
34
+ });
35
+ });
36
+
37
+ document.querySelector("#localRegisterBtn").addEventListener("click", function () {
38
+ // call /api/auth/register
39
+ fetch("/api/auth/register", {
40
+ method: "POST",
41
+ headers: {
42
+ "Content-Type": "application/json"
43
+ },
44
+ body: JSON.stringify({
45
+ email: document.querySelector("#email").value,
46
+ password: document.querySelector("#password").value
47
+ })
48
+ })
49
+ .then(async (res) => {
50
+ if (res.status === 201) {
51
+ alert("Registration successful. You can now log in.");
52
+ }
53
+ })
54
+ .catch((err) => {
55
+ console.error("Error during registration:", err);
56
+ alert("An error occurred during registration. Please try again later.");
57
+ });
58
+ });
59
+ });
@@ -0,0 +1,19 @@
1
+
2
+ document.addEventListener("DOMContentLoaded", function() {
3
+ console.log('Exchange Tokens from /api/auth/token');
4
+ let sessionCode = new URLSearchParams(location.search).get('code');
5
+ fetch(
6
+ '/api/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("/api/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
+ });