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,15 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ const als = new AsyncLocalStorage();
3
+
4
+ // L0 middleware: tenant known from header
5
+ als.run({ tenantId: "t1" }, () => {
6
+ // L1 Auth middleware: token known
7
+ als.run({ tokenData: { vexUserId: "u1" } }, () => {
8
+ // L2 repository adapter
9
+ Promise.resolve().then(() => {
10
+ console.log("downstream store:", JSON.stringify(als.getStore()));
11
+ // after inner run returns, outer store is restored
12
+ setImmediate(() => console.log("after inner callback (outer frame):", JSON.stringify(als.getStore())));
13
+ });
14
+ });
15
+ });
@@ -0,0 +1,9 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ const als = new AsyncLocalStorage();
3
+ als.run({ tenantId: "t1" }, () => {
4
+ console.log("outer:", JSON.stringify(als.getStore()));
5
+ als.run({ tokenData: { vexUserId: "u1" } }, () => {
6
+ console.log("inner:", JSON.stringify(als.getStore()));
7
+ });
8
+ console.log("sync after inner returns:", JSON.stringify(als.getStore()));
9
+ });
@@ -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,381 @@
1
+ {
2
+ "lastGeneratedVersion": "0.9.0",
3
+ "files": {
4
+ "src": {
5
+ "system": {
6
+ "_controllers": {
7
+ "_ControllerFactory.gen.ts": {
8
+ "lastWriteVersion": "0.9.0",
9
+ "allowOverwrite": true
10
+ },
11
+ "ProjectController.gen.ts": {
12
+ "lastWriteVersion": "0.9.0",
13
+ "allowOverwrite": true
14
+ },
15
+ "UserController.gen.ts": {
16
+ "lastWriteVersion": "0.9.0",
17
+ "allowOverwrite": true
18
+ },
19
+ "TenantController.gen.ts": {
20
+ "lastWriteVersion": "0.9.0",
21
+ "allowOverwrite": true
22
+ },
23
+ "AuthController.gen.ts": {
24
+ "lastWriteVersion": "0.9.0",
25
+ "allowOverwrite": true
26
+ }
27
+ },
28
+ "_middlewares": {
29
+ "Authentication.gen.ts": {
30
+ "lastWriteVersion": "0.9.0",
31
+ "allowOverwrite": true
32
+ },
33
+ "JoinWhitelistMiddleware.gen.ts": {
34
+ "lastWriteVersion": "0.9.0",
35
+ "allowOverwrite": true
36
+ },
37
+ "UserContext.gen.ts": {
38
+ "lastWriteVersion": "0.9.0",
39
+ "allowOverwrite": true
40
+ },
41
+ "tsoaAuthentication.gen.ts": {
42
+ "lastWriteVersion": "0.9.0",
43
+ "allowOverwrite": true
44
+ },
45
+ "RoleBaseAccessControl.gen.ts": {
46
+ "lastWriteVersion": "0.9.0",
47
+ "allowOverwrite": true
48
+ },
49
+ "JoinWhitelistRegistry.gen.ts": {
50
+ "lastWriteVersion": "0.9.0",
51
+ "allowOverwrite": true
52
+ },
53
+ "DataIsolationRegistry.gen.ts": {
54
+ "lastWriteVersion": "0.9.0",
55
+ "allowOverwrite": true
56
+ },
57
+ "VexFieldRegistry.gen.ts": {
58
+ "lastWriteVersion": "0.9.0",
59
+ "allowOverwrite": true
60
+ },
61
+ "TenantScopeContext.gen.ts": {
62
+ "lastWriteVersion": "0.9.0",
63
+ "allowOverwrite": true
64
+ },
65
+ "TenantScope.gen.ts": {
66
+ "lastWriteVersion": "0.9.0",
67
+ "allowOverwrite": true
68
+ }
69
+ },
70
+ "_routes": {
71
+ "FirebaseAuthUI.gen.ts": {
72
+ "lastWriteVersion": "0.9.0",
73
+ "allowOverwrite": true
74
+ },
75
+ "LoginUI.gen.ts": {
76
+ "lastWriteVersion": "0.9.0",
77
+ "allowOverwrite": true
78
+ },
79
+ "oauth": {
80
+ "OAuthRouteFactory.gen.ts": {
81
+ "lastWriteVersion": "0.9.0",
82
+ "allowOverwrite": true
83
+ }
84
+ },
85
+ "SwaggerRouter.gen.ts": {
86
+ "lastWriteVersion": "0.9.0",
87
+ "allowOverwrite": true
88
+ }
89
+ },
90
+ "_services": {
91
+ "MongooseRepositoryAdapter.gen.ts": {
92
+ "lastWriteVersion": "0.9.0",
93
+ "allowOverwrite": true
94
+ },
95
+ "TypeOrmRepositoryAdapter.gen.ts": {
96
+ "lastWriteVersion": "0.9.0",
97
+ "allowOverwrite": true
98
+ },
99
+ "VexDb.gen.ts": {
100
+ "lastWriteVersion": "0.9.0",
101
+ "allowOverwrite": true
102
+ },
103
+ "VexDbConnector.gen.ts": {
104
+ "lastWriteVersion": "0.9.0",
105
+ "allowOverwrite": true
106
+ },
107
+ "VexSystem.gen.ts": {
108
+ "lastWriteVersion": "0.9.0",
109
+ "allowOverwrite": true
110
+ },
111
+ "auth": {
112
+ "JWTKeyStore.gen.ts": {
113
+ "lastWriteVersion": "0.9.0",
114
+ "allowOverwrite": true
115
+ },
116
+ "JWTService.gen.ts": {
117
+ "lastWriteVersion": "0.9.0",
118
+ "allowOverwrite": true
119
+ },
120
+ "AccountStateGuard.gen.ts": {
121
+ "lastWriteVersion": "0.9.0",
122
+ "allowOverwrite": true
123
+ }
124
+ },
125
+ "oauth": {
126
+ "OAuthProfileMap.gen.ts": {
127
+ "lastWriteVersion": "0.9.0",
128
+ "allowOverwrite": true
129
+ },
130
+ "OAuthStrategyService.gen.ts": {
131
+ "lastWriteVersion": "0.9.0",
132
+ "allowOverwrite": true
133
+ }
134
+ },
135
+ "TenantService.gen.ts": {
136
+ "lastWriteVersion": "0.9.0",
137
+ "allowOverwrite": true
138
+ },
139
+ "account": {
140
+ "AccountDeletionService.gen.ts": {
141
+ "lastWriteVersion": "0.9.0",
142
+ "allowOverwrite": true
143
+ }
144
+ }
145
+ },
146
+ "_types": {
147
+ "auth.gen.ts": {
148
+ "lastWriteVersion": "0.9.0",
149
+ "allowOverwrite": true
150
+ },
151
+ "vex": {
152
+ "VexRepository.gen.ts": {
153
+ "lastWriteVersion": "0.9.0",
154
+ "allowOverwrite": true
155
+ },
156
+ "VexRequest.gen.ts": {
157
+ "lastWriteVersion": "0.9.0",
158
+ "allowOverwrite": true
159
+ },
160
+ "VexResErr.gen.ts": {
161
+ "lastWriteVersion": "0.9.0",
162
+ "allowOverwrite": true
163
+ },
164
+ "VexResOk.gen.ts": {
165
+ "lastWriteVersion": "0.9.0",
166
+ "allowOverwrite": true
167
+ },
168
+ "VexResponse.gen.ts": {
169
+ "lastWriteVersion": "0.9.0",
170
+ "allowOverwrite": true
171
+ },
172
+ "index.ts": {
173
+ "lastWriteVersion": "0.9.0",
174
+ "allowOverwrite": true
175
+ }
176
+ },
177
+ "Project.gen.ts": {
178
+ "lastWriteVersion": "0.9.0",
179
+ "allowOverwrite": true
180
+ },
181
+ "Session.gen.ts": {
182
+ "lastWriteVersion": "0.9.0",
183
+ "allowOverwrite": true
184
+ },
185
+ "User.gen.ts": {
186
+ "lastWriteVersion": "0.9.0",
187
+ "allowOverwrite": true
188
+ },
189
+ "UserAuthProfiles.gen.ts": {
190
+ "lastWriteVersion": "0.9.0",
191
+ "allowOverwrite": true
192
+ },
193
+ "UserRole.gen.ts": {
194
+ "lastWriteVersion": "0.9.0",
195
+ "allowOverwrite": true
196
+ },
197
+ "UserTenant.gen.ts": {
198
+ "lastWriteVersion": "0.9.0",
199
+ "allowOverwrite": true
200
+ },
201
+ "Tenant.gen.ts": {
202
+ "lastWriteVersion": "0.9.0",
203
+ "allowOverwrite": true
204
+ }
205
+ },
206
+ "_utils": {
207
+ "hash.gen.ts": {
208
+ "lastWriteVersion": "0.9.0",
209
+ "allowOverwrite": true
210
+ },
211
+ "index.ts": {
212
+ "lastWriteVersion": "0.9.0",
213
+ "allowOverwrite": true
214
+ },
215
+ "logger.gen.ts": {
216
+ "lastWriteVersion": "0.9.0",
217
+ "allowOverwrite": true
218
+ },
219
+ "processTimer.gen.ts": {
220
+ "lastWriteVersion": "0.9.0",
221
+ "allowOverwrite": true
222
+ },
223
+ "response.gen.ts": {
224
+ "lastWriteVersion": "0.9.0",
225
+ "allowOverwrite": true
226
+ },
227
+ "validator.gen.ts": {
228
+ "lastWriteVersion": "0.9.0",
229
+ "allowOverwrite": true
230
+ }
231
+ },
232
+ "_roles": {
233
+ "_RoleFactory.gen.ts": {
234
+ "lastWriteVersion": "0.9.0",
235
+ "allowOverwrite": true
236
+ },
237
+ "visitor.gen.ts": {
238
+ "lastWriteVersion": "0.9.0",
239
+ "allowOverwrite": true
240
+ },
241
+ "member.gen.ts": {
242
+ "lastWriteVersion": "0.9.0",
243
+ "allowOverwrite": true
244
+ },
245
+ "admin.gen.ts": {
246
+ "lastWriteVersion": "0.9.0",
247
+ "allowOverwrite": true
248
+ },
249
+ "index.ts": {
250
+ "lastWriteVersion": "0.9.0",
251
+ "allowOverwrite": true
252
+ }
253
+ },
254
+ "_models": {
255
+ "ProjectModel.gen.ts": {
256
+ "lastWriteVersion": "0.9.0",
257
+ "allowOverwrite": true
258
+ },
259
+ "SessionModel.gen.ts": {
260
+ "lastWriteVersion": "0.9.0",
261
+ "allowOverwrite": true
262
+ },
263
+ "UserModel.gen.ts": {
264
+ "lastWriteVersion": "0.9.0",
265
+ "allowOverwrite": true
266
+ },
267
+ "UserAuthProfilesModel.gen.ts": {
268
+ "lastWriteVersion": "0.9.0",
269
+ "allowOverwrite": true
270
+ },
271
+ "UserRoleModel.gen.ts": {
272
+ "lastWriteVersion": "0.9.0",
273
+ "allowOverwrite": true
274
+ },
275
+ "UserTenantModel.gen.ts": {
276
+ "lastWriteVersion": "0.9.0",
277
+ "allowOverwrite": true
278
+ }
279
+ }
280
+ },
281
+ "roles": {
282
+ "visitor.json": {
283
+ "lastWriteVersion": "0.9.0",
284
+ "allowOverwrite": true
285
+ },
286
+ "member.json": {
287
+ "lastWriteVersion": "0.9.0",
288
+ "allowOverwrite": true
289
+ },
290
+ "admin.json": {
291
+ "lastWriteVersion": "0.9.0",
292
+ "allowOverwrite": true
293
+ }
294
+ },
295
+ "server.ts": {
296
+ "lastWriteVersion": "0.9.0",
297
+ "allowOverwrite": true
298
+ }
299
+ },
300
+ "Dockerfile": {
301
+ "lastWriteVersion": "0.9.0",
302
+ "allowOverwrite": true
303
+ },
304
+ "README.md": {
305
+ "lastWriteVersion": "0.9.0",
306
+ "allowOverwrite": true
307
+ },
308
+ "public": {
309
+ "css": {
310
+ "style.css": {
311
+ "lastWriteVersion": "0.9.0",
312
+ "allowOverwrite": true
313
+ }
314
+ },
315
+ "js": {
316
+ "deleteaccount.js": {
317
+ "lastWriteVersion": "0.9.0",
318
+ "allowOverwrite": true
319
+ },
320
+ "login.js": {
321
+ "lastWriteVersion": "0.9.0",
322
+ "allowOverwrite": true
323
+ },
324
+ "logincallback.js": {
325
+ "lastWriteVersion": "0.9.0",
326
+ "allowOverwrite": true
327
+ },
328
+ "mytokens.js": {
329
+ "lastWriteVersion": "0.9.0",
330
+ "allowOverwrite": true
331
+ },
332
+ "refreshtokens.js": {
333
+ "lastWriteVersion": "0.9.0",
334
+ "allowOverwrite": true
335
+ }
336
+ }
337
+ },
338
+ "scripts": {
339
+ "build.js": {
340
+ "lastWriteVersion": "0.9.0",
341
+ "allowOverwrite": true
342
+ },
343
+ "oacg-fix.js": {
344
+ "lastWriteVersion": "0.9.0",
345
+ "allowOverwrite": true
346
+ }
347
+ },
348
+ "tsconfig.json": {
349
+ "lastWriteVersion": "0.9.0",
350
+ "allowOverwrite": true
351
+ },
352
+ "..": {
353
+ "schemas": {
354
+ "Session.json": {
355
+ "lastWriteVersion": "0.9.0",
356
+ "allowOverwrite": true
357
+ },
358
+ "User.json": {
359
+ "lastWriteVersion": "0.9.0",
360
+ "allowOverwrite": true
361
+ },
362
+ "UserAuthProfiles.json": {
363
+ "lastWriteVersion": "0.9.0",
364
+ "allowOverwrite": true
365
+ }
366
+ }
367
+ },
368
+ "package.json": {
369
+ "lastWriteVersion": "0.9.0",
370
+ "allowOverwrite": true
371
+ },
372
+ ".env": {
373
+ "lastWriteVersion": "0.9.0",
374
+ "allowOverwrite": true
375
+ },
376
+ "tsoa.json": {
377
+ "lastWriteVersion": "0.9.0",
378
+ "allowOverwrite": true
379
+ }
380
+ }
381
+ }
@@ -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
+ });