express-generator-typescript 3.0.4 → 3.2.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 (48) hide show
  1. package/README.md +10 -11
  2. package/bin/cli.js +1 -20
  3. package/lib/template/.prettierrc.json +1 -1
  4. package/lib/template/README.md +13 -15
  5. package/lib/template/eslint.config.ts +10 -1
  6. package/lib/template/gitignore +0 -1
  7. package/lib/template/package.json +19 -29
  8. package/lib/template/src/common/classes/route-errors.ts +1 -14
  9. package/lib/template/src/common/constants/HttpStatusCodes.ts +1 -1
  10. package/lib/template/src/common/constants/Paths/Paths.ts +29 -0
  11. package/lib/template/src/common/constants/Paths/helpers.ts +29 -0
  12. package/lib/template/src/common/constants/Paths/index.ts +1 -0
  13. package/lib/template/src/common/constants/{environment-consts.ts → env.constants.ts} +13 -15
  14. package/lib/template/src/common/utils/{date-utils.ts → date.utils.ts} +10 -12
  15. package/lib/template/src/common/utils/dev-only.ts +1 -1
  16. package/lib/template/src/common/utils/validators.ts +0 -23
  17. package/lib/template/src/entities/User/index.ts +2 -2
  18. package/lib/template/src/entities/User/module.ts +77 -28
  19. package/lib/template/src/entities/User/types.ts +1 -1
  20. package/lib/template/src/entities/common/entity-base-types.ts +1 -1
  21. package/lib/template/src/main.ts +4 -4
  22. package/lib/template/src/public/scripts/lib/bootstrap.bundle.min.js +0 -1
  23. package/lib/template/src/public/scripts/users.js +19 -10
  24. package/lib/template/src/public/stylesheets/lib/bootstrap.min.css +0 -1
  25. package/lib/template/src/public/stylesheets/users.css +24 -1
  26. package/lib/template/src/repos/MockOrm.ts +6 -6
  27. package/lib/template/src/repos/UserRepo.ts +6 -16
  28. package/lib/template/src/repos/common/database.json +3 -3
  29. package/lib/template/src/{routes/apiRouter.ts → routers/api.router.ts} +4 -12
  30. package/lib/template/src/routers/user.router.ts +65 -0
  31. package/lib/template/src/server.ts +24 -11
  32. package/lib/template/src/services/UserService.ts +6 -3
  33. package/lib/template/src/views/users.html +8 -0
  34. package/lib/template/tests/frontend.test.ts +28 -17
  35. package/lib/template/tests/support/agent.ts +4 -4
  36. package/lib/template/tests/support/utils.ts +23 -0
  37. package/lib/template/tests/users.test.ts +136 -83
  38. package/lib/template/tsconfig.json +10 -13
  39. package/package.json +6 -6
  40. package/lib/template/src/common/constants/Paths.ts +0 -16
  41. package/lib/template/src/entities/User/_internal/validators.ts +0 -47
  42. package/lib/template/src/routes/UserRoutes.ts +0 -74
  43. package/lib/template/src/routes/common/express-types.ts +0 -9
  44. package/lib/template/src/routes/common/parseReq.ts +0 -23
  45. package/lib/template/tests/common/comparators.ts +0 -36
  46. package/lib/template/tests/common/supertest-types.ts +0 -11
  47. package/lib/template/tsconfig.prod.json +0 -30
  48. package/lib/template/vitest.config.ts +0 -25
@@ -1,23 +0,0 @@
1
- import { parseObject, type Schema } from 'jet-validators/utils';
2
-
3
- import { ValidationError } from '@src/common/classes/route-errors';
4
-
5
- // ========================================================================= //
6
- // FUNCTIONS //
7
- // ========================================================================= //
8
-
9
- /**
10
- * Build a request parser for `schema` that throws a `ValidationError`
11
- * (400) listing every failed field.
12
- */
13
- function parseReq<U extends Schema>(schema: U) {
14
- return parseObject(schema, (errors) => {
15
- throw new ValidationError(errors);
16
- });
17
- }
18
-
19
- // ========================================================================= //
20
- // EXPORT //
21
- // ========================================================================= //
22
-
23
- export default parseReq;
@@ -1,36 +0,0 @@
1
- import type { UserEntity } from '@src/entities/User';
2
-
3
- // ========================================================================= //
4
- // TYPES //
5
- // ========================================================================= //
6
-
7
- type UserArray = UserEntity[] | readonly UserEntity[];
8
-
9
- // ========================================================================= //
10
- // FUNCTIONS //
11
- // ========================================================================= //
12
-
13
- /**
14
- * Compare to user arrays. Order does not matter and this assumes the email
15
- * field is unique
16
- */
17
- export function compareUserArrays(a: UserArray, b: UserArray): boolean {
18
- if (a.length !== b.length) return false;
19
- const aSorted = sortByEmail(a);
20
- const bSorted = sortByEmail(b);
21
- for (let i = 0; i < aSorted.length; i++) {
22
- const a = aSorted[i];
23
- const b = bSorted[i];
24
- if (a.email !== b.email || a.name !== b.name) return false;
25
- }
26
- return true;
27
- }
28
-
29
- /**
30
- * Sort user array by email.
31
- */
32
- function sortByEmail(arr: UserArray): UserEntity[] {
33
- return [...arr].sort((x, y) => {
34
- return x.email.localeCompare(y.email);
35
- });
36
- }
@@ -1,11 +0,0 @@
1
- import type { ParseError } from 'jet-validators/utils';
2
- import type { Response } from 'supertest';
3
-
4
- // ========================================================================= //
5
- // TYPES //
6
- // ========================================================================= //
7
-
8
- // Use generics to add properties to 'body'
9
- export interface TestRes<T = object> extends Omit<Response, 'body'> {
10
- body: T & { error?: string; errors?: ParseError[] };
11
- }
@@ -1,30 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "esnext",
5
- "moduleResolution": "bundler",
6
- "esModuleInterop": true,
7
- "lib": ["ES2022"],
8
- "strict": true,
9
- "rootDir": "./src",
10
- "outDir": "dist",
11
- "skipLibCheck": true,
12
- "forceConsistentCasingInFileNames": true,
13
- "paths": {
14
- "@src/*": ["./src/*"]
15
- },
16
- "verbatimModuleSyntax": true,
17
- "useUnknownInCatchVariables": false,
18
- "types": ["node"],
19
- "sourceMap": false,
20
- "removeComments": true
21
- },
22
- // After tsc, tsc-alias rewrites "@src/..." imports in dist/ to relative
23
- // paths and adds the ".js" extensions Node's ESM loader requires (source
24
- // imports are written without extensions)
25
- "tsc-alias": {
26
- "resolveFullPaths": true
27
- },
28
- "include": ["src/**/*.ts"],
29
- "exclude": ["src/public/"]
30
- }
@@ -1,25 +0,0 @@
1
- import path from 'path';
2
- import { defineConfig } from 'vitest/config';
3
-
4
- // ========================================================================= //
5
- // EXPORT //
6
- // ========================================================================= //
7
-
8
- export default defineConfig({
9
- test: {
10
- globals: true,
11
- environment: 'node',
12
- setupFiles: ['dotenv/config', './tests/support/agent.ts'],
13
- isolate: true,
14
- // All test files share one JSON database file, so run them one at a time
15
- fileParallelism: false,
16
- env: {
17
- DOTENV_CONFIG_PATH: 'config/.env.test',
18
- },
19
- },
20
- resolve: {
21
- alias: {
22
- '@src': path.resolve(import.meta.dirname, './src'),
23
- },
24
- },
25
- });