express-generator-typescript 2.7.2 → 2.7.4

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 (36) hide show
  1. package/LICENSE +21 -21
  2. package/README-npm +20 -0
  3. package/README.md +85 -20
  4. package/bin/cli.js +0 -0
  5. package/lib/express-generator-typescript.js +2 -2
  6. package/lib/project-files/README.md +65 -65
  7. package/lib/project-files/config.ts +22 -22
  8. package/lib/project-files/eslint.config.ts +100 -95
  9. package/lib/project-files/package.json +57 -58
  10. package/lib/project-files/src/common/constants/ENV.ts +21 -21
  11. package/lib/project-files/src/common/constants/HttpStatusCodes.ts +391 -391
  12. package/lib/project-files/src/common/constants/Paths.ts +11 -11
  13. package/lib/project-files/src/common/constants/index.ts +11 -11
  14. package/lib/project-files/src/common/util/route-errors.ts +37 -37
  15. package/lib/project-files/src/common/util/validators.ts +22 -22
  16. package/lib/project-files/src/models/common/types/index.ts +5 -5
  17. package/lib/project-files/src/public/scripts/http.js +26 -26
  18. package/lib/project-files/src/public/scripts/users.js +141 -141
  19. package/lib/project-files/src/public/stylesheets/users.css +48 -48
  20. package/lib/project-files/src/repos/MockOrm.ts +62 -62
  21. package/lib/project-files/src/repos/UserRepo.ts +2 -1
  22. package/lib/project-files/src/repos/database.json +1 -1
  23. package/lib/project-files/src/repos/database.test.json +1 -1
  24. package/lib/project-files/src/routes/common/types/index.ts +11 -11
  25. package/lib/project-files/src/routes/common/util/index.ts +18 -18
  26. package/lib/project-files/src/routes/index.ts +33 -33
  27. package/lib/project-files/src/services/UserService.ts +73 -73
  28. package/lib/project-files/src/views/users.html +132 -132
  29. package/lib/project-files/tests/common/Paths.ts +5 -5
  30. package/lib/project-files/tests/common/types/index.ts +16 -16
  31. package/lib/project-files/tests/common/util/index.ts +38 -38
  32. package/lib/project-files/tests/support/setup.ts +26 -26
  33. package/lib/project-files/tsconfig.prod.json +30 -30
  34. package/lib/project-files/vitest.config.mts +18 -18
  35. package/package.json +1 -1
  36. package/README-git +0 -95
@@ -1,62 +1,62 @@
1
- import jsonfile from 'jsonfile';
2
-
3
- import ENV from '@src/common/constants/ENV';
4
- import { NodeEnvs } from '@src/common/constants';
5
- import { IUser } from '@src/models/User';
6
-
7
-
8
- /******************************************************************************
9
- Constants
10
- ******************************************************************************/
11
-
12
- const DB_FILE_NAME = (
13
- ENV.NodeEnv === NodeEnvs.Test
14
- ? 'database.test.json'
15
- : 'database.json'
16
- );
17
-
18
-
19
- /******************************************************************************
20
- Types
21
- ******************************************************************************/
22
-
23
- interface IDb {
24
- users: IUser[];
25
- }
26
-
27
-
28
- /******************************************************************************
29
- Functions
30
- ******************************************************************************/
31
-
32
- /**
33
- * Fetch the json from the file.
34
- */
35
- function openDb(): Promise<IDb> {
36
- return jsonfile.readFile(__dirname + '/' + DB_FILE_NAME) as Promise<IDb>;
37
- }
38
-
39
- /**
40
- * Update the file.
41
- */
42
- function saveDb(db: IDb): Promise<void> {
43
- return jsonfile.writeFile((__dirname + '/' + DB_FILE_NAME), db);
44
- }
45
-
46
- /**
47
- * Empty the database
48
- */
49
- function cleanDb(): Promise<void> {
50
- return jsonfile.writeFile((__dirname + '/' + DB_FILE_NAME), {});
51
- }
52
-
53
-
54
- /******************************************************************************
55
- Export default
56
- ******************************************************************************/
57
-
58
- export default {
59
- openDb,
60
- saveDb,
61
- cleanDb,
62
- } as const;
1
+ import jsonfile from 'jsonfile';
2
+
3
+ import ENV from '@src/common/constants/ENV';
4
+ import { NodeEnvs } from '@src/common/constants';
5
+ import { IUser } from '@src/models/User';
6
+
7
+
8
+ /******************************************************************************
9
+ Constants
10
+ ******************************************************************************/
11
+
12
+ const DB_FILE_NAME = (
13
+ ENV.NodeEnv === NodeEnvs.Test
14
+ ? 'database.test.json'
15
+ : 'database.json'
16
+ );
17
+
18
+
19
+ /******************************************************************************
20
+ Types
21
+ ******************************************************************************/
22
+
23
+ interface IDb {
24
+ users: IUser[];
25
+ }
26
+
27
+
28
+ /******************************************************************************
29
+ Functions
30
+ ******************************************************************************/
31
+
32
+ /**
33
+ * Fetch the json from the file.
34
+ */
35
+ function openDb(): Promise<IDb> {
36
+ return jsonfile.readFile(__dirname + '/' + DB_FILE_NAME) as Promise<IDb>;
37
+ }
38
+
39
+ /**
40
+ * Update the file.
41
+ */
42
+ function saveDb(db: IDb): Promise<void> {
43
+ return jsonfile.writeFile((__dirname + '/' + DB_FILE_NAME), db);
44
+ }
45
+
46
+ /**
47
+ * Empty the database
48
+ */
49
+ function cleanDb(): Promise<void> {
50
+ return jsonfile.writeFile((__dirname + '/' + DB_FILE_NAME), {});
51
+ }
52
+
53
+
54
+ /******************************************************************************
55
+ Export default
56
+ ******************************************************************************/
57
+
58
+ export default {
59
+ openDb,
60
+ saveDb,
61
+ cleanDb,
62
+ } as const;
@@ -97,7 +97,7 @@ async function deleteAllUsers(): Promise<void> {
97
97
 
98
98
  /**
99
99
  * Insert multiple users. Can't do multiple at once cause using a plain file
100
- * for nmow.
100
+ * for now.
101
101
  */
102
102
  async function insertMult(
103
103
  users: IUser[] | readonly IUser[],
@@ -128,3 +128,4 @@ export default {
128
128
  deleteAllUsers,
129
129
  insertMult,
130
130
  } as const;
131
+
@@ -1 +1 @@
1
- {"users":[{"id":366115170645,"name":"Sean Maxwell","email":"smaxwell@example.com","created":"2024-03-22T05:14:36.252Z"},{"id":310946254456,"name":"John Smith","email":"john.smith@example.com","created":"2024-03-22T05:20:55.079Z"},{"id":143027113460,"name":"Gordan Freeman","email":"nova@prospect.com","created":"2024-03-22T05:42:18.895Z"}]}
1
+ {"users":[{"id":366115170645,"name":"Sean Maxwell","email":"smaxwell@example.com","created":"2024-03-22T05:14:36.252Z"},{"id":310946254456,"name":"John Smith","email":"john.smith@example.com","created":"2024-03-22T05:20:55.079Z"},{"id":143027113460,"name":"Gordan Freeman","email":"nova@prospect.com","created":"2024-03-22T05:42:18.895Z"}]}
@@ -1 +1 @@
1
- {"users":[{"id":701029715561,"name":"Bill","created":"2025-06-03T15:16:08.805Z","email":"sean.maxwell@gmail.com"},{"id":625166376007,"name":"John Smith","created":"2025-06-03T15:16:08.805Z","email":"john.smith@gmail.com"},{"id":595966642687,"name":"Gordan Freeman","created":"2025-06-03T15:16:08.805Z","email":"gordan.freeman@gmail.com"}]}
1
+ {"users":[{"id":497419234357,"name":"Bill","created":"2025-06-09T14:39:52.401Z","email":"sean.maxwell@gmail.com"},{"id":194170887976,"name":"John Smith","created":"2025-06-09T14:39:52.401Z","email":"john.smith@gmail.com"},{"id":893739541148,"name":"Gordan Freeman","created":"2025-06-09T14:39:52.401Z","email":"gordan.freeman@gmail.com"}]}
@@ -1,11 +1,11 @@
1
- import { Response, Request } from 'express';
2
-
3
-
4
- /******************************************************************************
5
- Types
6
- ******************************************************************************/
7
-
8
- type TRecord = Record<string, unknown>;
9
- export type IReq = Request<TRecord, void, TRecord, TRecord>;
10
- export type IRes = Response<unknown, TRecord>;
11
-
1
+ import { Response, Request } from 'express';
2
+
3
+
4
+ /******************************************************************************
5
+ Types
6
+ ******************************************************************************/
7
+
8
+ type TRecord = Record<string, unknown>;
9
+ export type IReq = Request<TRecord, void, TRecord, TRecord>;
10
+ export type IRes = Response<unknown, TRecord>;
11
+
@@ -1,18 +1,18 @@
1
- import { parseObject, TSchema } from 'jet-validators/utils';
2
-
3
- import { ValidationError } from '@src/common/util/route-errors';
4
-
5
-
6
- /******************************************************************************
7
- Functions
8
- ******************************************************************************/
9
-
10
- /**
11
- * Throw a "ParseObjError" when "parseObject" fails. Also extract a nested
12
- * "ParseObjError" and add it to the nestedErrors array.
13
- */
14
- export function parseReq<U extends TSchema>(schema: U) {
15
- return parseObject(schema, errors => {
16
- throw new ValidationError(errors);
17
- });
18
- }
1
+ import { parseObject, TSchema } from 'jet-validators/utils';
2
+
3
+ import { ValidationError } from '@src/common/util/route-errors';
4
+
5
+
6
+ /******************************************************************************
7
+ Functions
8
+ ******************************************************************************/
9
+
10
+ /**
11
+ * Throw a "ParseObjError" when "parseObject" fails. Also extract a nested
12
+ * "ParseObjError" and add it to the nestedErrors array.
13
+ */
14
+ export function parseReq<U extends TSchema>(schema: U) {
15
+ return parseObject(schema, errors => {
16
+ throw new ValidationError(errors);
17
+ });
18
+ }
@@ -1,33 +1,33 @@
1
- import { Router } from 'express';
2
-
3
- import Paths from '@src/common/constants/Paths';
4
- import UserRoutes from './UserRoutes';
5
-
6
-
7
- /******************************************************************************
8
- Setup
9
- ******************************************************************************/
10
-
11
- const apiRouter = Router();
12
-
13
-
14
- // ** Add UserRouter ** //
15
-
16
- // Init router
17
- const userRouter = Router();
18
-
19
- // Get all users
20
- userRouter.get(Paths.Users.Get, UserRoutes.getAll);
21
- userRouter.post(Paths.Users.Add, UserRoutes.add);
22
- userRouter.put(Paths.Users.Update, UserRoutes.update);
23
- userRouter.delete(Paths.Users.Delete, UserRoutes.delete);
24
-
25
- // Add UserRouter
26
- apiRouter.use(Paths.Users.Base, userRouter);
27
-
28
-
29
- /******************************************************************************
30
- Export default
31
- ******************************************************************************/
32
-
33
- export default apiRouter;
1
+ import { Router } from 'express';
2
+
3
+ import Paths from '@src/common/constants/Paths';
4
+ import UserRoutes from './UserRoutes';
5
+
6
+
7
+ /******************************************************************************
8
+ Setup
9
+ ******************************************************************************/
10
+
11
+ const apiRouter = Router();
12
+
13
+
14
+ // ** Add UserRouter ** //
15
+
16
+ // Init router
17
+ const userRouter = Router();
18
+
19
+ // Get all users
20
+ userRouter.get(Paths.Users.Get, UserRoutes.getAll);
21
+ userRouter.post(Paths.Users.Add, UserRoutes.add);
22
+ userRouter.put(Paths.Users.Update, UserRoutes.update);
23
+ userRouter.delete(Paths.Users.Delete, UserRoutes.delete);
24
+
25
+ // Add UserRouter
26
+ apiRouter.use(Paths.Users.Base, userRouter);
27
+
28
+
29
+ /******************************************************************************
30
+ Export default
31
+ ******************************************************************************/
32
+
33
+ export default apiRouter;
@@ -1,73 +1,73 @@
1
- import { RouteError } from '@src/common/util/route-errors';
2
- import HttpStatusCodes from '@src/common/constants/HttpStatusCodes';
3
-
4
- import UserRepo from '@src/repos/UserRepo';
5
- import { IUser } from '@src/models/User';
6
-
7
-
8
- /******************************************************************************
9
- Constants
10
- ******************************************************************************/
11
-
12
- export const USER_NOT_FOUND_ERR = 'User not found';
13
-
14
-
15
- /******************************************************************************
16
- Functions
17
- ******************************************************************************/
18
-
19
- /**
20
- * Get all users.
21
- */
22
- function getAll(): Promise<IUser[]> {
23
- return UserRepo.getAll();
24
- }
25
-
26
- /**
27
- * Add one user.
28
- */
29
- function addOne(user: IUser): Promise<void> {
30
- return UserRepo.add(user);
31
- }
32
-
33
- /**
34
- * Update one user.
35
- */
36
- async function updateOne(user: IUser): Promise<void> {
37
- const persists = await UserRepo.persists(user.id);
38
- if (!persists) {
39
- throw new RouteError(
40
- HttpStatusCodes.NOT_FOUND,
41
- USER_NOT_FOUND_ERR,
42
- );
43
- }
44
- // Return user
45
- return UserRepo.update(user);
46
- }
47
-
48
- /**
49
- * Delete a user by their id.
50
- */
51
- async function _delete(id: number): Promise<void> {
52
- const persists = await UserRepo.persists(id);
53
- if (!persists) {
54
- throw new RouteError(
55
- HttpStatusCodes.NOT_FOUND,
56
- USER_NOT_FOUND_ERR,
57
- );
58
- }
59
- // Delete user
60
- return UserRepo.delete(id);
61
- }
62
-
63
-
64
- /******************************************************************************
65
- Export default
66
- ******************************************************************************/
67
-
68
- export default {
69
- getAll,
70
- addOne,
71
- updateOne,
72
- delete: _delete,
73
- } as const;
1
+ import { RouteError } from '@src/common/util/route-errors';
2
+ import HttpStatusCodes from '@src/common/constants/HttpStatusCodes';
3
+
4
+ import UserRepo from '@src/repos/UserRepo';
5
+ import { IUser } from '@src/models/User';
6
+
7
+
8
+ /******************************************************************************
9
+ Constants
10
+ ******************************************************************************/
11
+
12
+ export const USER_NOT_FOUND_ERR = 'User not found';
13
+
14
+
15
+ /******************************************************************************
16
+ Functions
17
+ ******************************************************************************/
18
+
19
+ /**
20
+ * Get all users.
21
+ */
22
+ function getAll(): Promise<IUser[]> {
23
+ return UserRepo.getAll();
24
+ }
25
+
26
+ /**
27
+ * Add one user.
28
+ */
29
+ function addOne(user: IUser): Promise<void> {
30
+ return UserRepo.add(user);
31
+ }
32
+
33
+ /**
34
+ * Update one user.
35
+ */
36
+ async function updateOne(user: IUser): Promise<void> {
37
+ const persists = await UserRepo.persists(user.id);
38
+ if (!persists) {
39
+ throw new RouteError(
40
+ HttpStatusCodes.NOT_FOUND,
41
+ USER_NOT_FOUND_ERR,
42
+ );
43
+ }
44
+ // Return user
45
+ return UserRepo.update(user);
46
+ }
47
+
48
+ /**
49
+ * Delete a user by their id.
50
+ */
51
+ async function _delete(id: number): Promise<void> {
52
+ const persists = await UserRepo.persists(id);
53
+ if (!persists) {
54
+ throw new RouteError(
55
+ HttpStatusCodes.NOT_FOUND,
56
+ USER_NOT_FOUND_ERR,
57
+ );
58
+ }
59
+ // Delete user
60
+ return UserRepo.delete(id);
61
+ }
62
+
63
+
64
+ /******************************************************************************
65
+ Export default
66
+ ******************************************************************************/
67
+
68
+ export default {
69
+ getAll,
70
+ addOne,
71
+ updateOne,
72
+ delete: _delete,
73
+ } as const;