express-generator-typescript 2.7.11 → 2.7.14

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 (50) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +0 -0
  3. package/lib/cli.js +0 -0
  4. package/lib/express-generator-typescript.js +44 -11
  5. package/lib/project-files/.prettierignore +12 -0
  6. package/lib/project-files/.prettierrc.json +15 -0
  7. package/lib/project-files/README.md +54 -65
  8. package/lib/project-files/config/.env.development +0 -0
  9. package/lib/project-files/config/.env.production +0 -0
  10. package/lib/project-files/config/.env.test +0 -0
  11. package/lib/project-files/eslint.config.ts +46 -100
  12. package/lib/project-files/gitignore +0 -2
  13. package/lib/project-files/package.json +62 -56
  14. package/lib/project-files/src/common/constants/HttpStatusCodes.ts +393 -394
  15. package/lib/project-files/src/common/constants/Paths.ts +15 -15
  16. package/lib/project-files/src/common/constants/{EnvVars.ts → env.ts} +28 -19
  17. package/lib/project-files/src/common/utils/{misc.ts → number-utils.ts} +10 -11
  18. package/lib/project-files/src/common/utils/route-errors.ts +35 -36
  19. package/lib/project-files/src/common/utils/validators.ts +14 -14
  20. package/lib/project-files/src/{index.ts → main.ts} +24 -27
  21. package/lib/project-files/src/models/User.ts +73 -72
  22. package/lib/project-files/src/models/common/IModel.ts +4 -0
  23. package/lib/project-files/src/public/stylesheets/users.css +50 -48
  24. package/lib/project-files/src/repos/MockOrm.ts +57 -63
  25. package/lib/project-files/src/repos/UserRepo.ts +131 -133
  26. package/lib/project-files/src/repos/{database.json → common/database.json} +0 -0
  27. package/lib/project-files/src/repos/common/database.test.json +1 -0
  28. package/lib/project-files/src/routes/UserRoutes.ts +77 -69
  29. package/lib/project-files/src/routes/{index.ts → apiRouter.ts} +28 -28
  30. package/lib/project-files/src/routes/common/{types.ts → express-types.ts} +9 -10
  31. package/lib/project-files/src/routes/common/{utils.ts → parseReq.ts} +19 -16
  32. package/lib/project-files/src/server.ts +79 -84
  33. package/lib/project-files/src/services/{UserService/index.ts → UserService.ts} +64 -58
  34. package/lib/project-files/src/views/users.html +118 -132
  35. package/lib/project-files/tests/common/{utils.ts → comparators.ts} +38 -55
  36. package/lib/project-files/tests/common/error-utils.ts +25 -0
  37. package/lib/project-files/tests/common/{types.ts → supertest-types.ts} +15 -16
  38. package/lib/project-files/tests/{aux/setup.ts → support/agent.ts} +23 -26
  39. package/lib/project-files/tests/users.test.ts +131 -123
  40. package/lib/project-files/tsconfig.json +29 -35
  41. package/lib/project-files/tsconfig.prod.json +27 -30
  42. package/lib/project-files/vitest.config.mts +21 -18
  43. package/package.json +1 -1
  44. package/lib/project-files/config.ts +0 -22
  45. package/lib/project-files/scripts/build.ts +0 -28
  46. package/lib/project-files/scripts/common/utils.ts +0 -93
  47. package/lib/project-files/src/common/constants/index.ts +0 -11
  48. package/lib/project-files/src/models/common/types.ts +0 -5
  49. package/lib/project-files/src/repos/database.test.json +0 -1
  50. package/lib/project-files/src/services/UserService/constants.ts +0 -5
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
package/lib/cli.js CHANGED
File without changes
@@ -9,18 +9,51 @@ const path = require('path'),
9
9
  Constants
10
10
  ******************************************************************************/
11
11
 
12
- // Project folder paths
13
12
  const PROJECT_FOLDER_PATH = './project-files';
14
13
 
15
- // Project-folder dependencies
16
- const DEPENDENCIES = 'express dotenv morgan cookie-parser jet-logger ' +
17
- 'module-alias helmet jsonfile jet-paths dayjs jet-env ' +
14
+ const DEPENDENCIES = [
15
+ 'cookie-parser',
16
+ 'dayjs',
17
+ 'dotenv',
18
+ 'express',
19
+ 'helmet',
20
+ 'jet-env',
21
+ 'jet-logger',
22
+ 'jet-paths',
18
23
  'jet-validators',
19
- DEV_DEPENDENCIES = 'ts-node typescript nodemon find supertest vitest ' +
20
- '@types/node @types/find @types/morgan @types/cookie-parser ' +
21
- '@types/supertest fs-extra tsconfig-paths jiti @swc/core @types/jsonfile ' +
22
- '@types/fs-extra @types/module-alias @stylistic/eslint-plugin eslint ' +
23
- '@eslint/js typescript-eslint eslint-plugin-n';
24
+ 'jsonfile',
25
+ 'module-alias',
26
+ 'morgan',
27
+ ];
28
+
29
+ const DEV_DEPENDENCIES = [
30
+ '@eslint/js',
31
+ '@swc/core',
32
+ '@trivago/prettier-plugin-sort-imports',
33
+ '@types/cookie-parser',
34
+ '@types/find',
35
+ '@types/fs-extra',
36
+ '@types/jsonfile',
37
+ '@types/module-alias',
38
+ '@types/morgan',
39
+ '@types/node',
40
+ '@types/supertest',
41
+ 'eslint',
42
+ 'eslint-config-prettier',
43
+ 'eslint-plugin-n',
44
+ 'find',
45
+ 'fs-extra',
46
+ 'jiti',
47
+ 'nodemon',
48
+ 'prettier',
49
+ 'supertest',
50
+ 'ts-node',
51
+ 'tsconfig-paths',
52
+ 'typescript',
53
+ 'typescript-eslint',
54
+ 'vitest',
55
+ ];
56
+
24
57
 
25
58
  // "ncp" options
26
59
  const ncpOpts = {
@@ -91,8 +124,8 @@ function renameGitigoreFile(destination) {
91
124
  function downloadNodeModules(destination, useYarn) {
92
125
  const options = { cwd: destination };
93
126
  // Setup dependencies string
94
- let depStr = DEPENDENCIES,
95
- devDepStr = DEV_DEPENDENCIES;
127
+ let depStr = DEPENDENCIES.join(' '),
128
+ devDepStr = DEV_DEPENDENCIES.join(' ');
96
129
  // Setup download command
97
130
  let downloadLibCmd,
98
131
  downloadDepCmd;
@@ -0,0 +1,12 @@
1
+ # Ignore everything
2
+ *
3
+
4
+ # Allow these folders
5
+ !src/
6
+ !test/
7
+ !script/
8
+
9
+ # Allow all files inside them
10
+ !src/**
11
+ !test/**
12
+ !scripts/**
@@ -0,0 +1,15 @@
1
+ {
2
+ "plugins": ["@trivago/prettier-plugin-sort-imports"],
3
+ "importOrder": [
4
+ "<THIRD_PARTY_MODULES>",
5
+ "^@src/[^/]+(/.*)?$",
6
+ "^\\.(?!.*\\.css$).*$",
7
+ "^.+\\.css$"
8
+ ],
9
+ "importOrderSeparation": true,
10
+ "importOrderSortSpecifiers": true,
11
+ "importOrderCaseInsensitive": true,
12
+ "singleQuote": true,
13
+ "printWidth": 80,
14
+ "tabWidth": 2
15
+ }
@@ -1,65 +1,54 @@
1
- ## About
2
-
3
- This project was created with [express-generator-typescript](https://github.com/seanpmaxwell/express-generator-typescript).
4
-
5
- **IMPORTANT** for demo purposes I had to disable `helmet` in production. In any real world app you should change these 3 lines of code in `src/server.ts`:
6
- ```ts
7
- // eslint-disable-next-line n/no-process-env
8
- if (!process.env.DISABLE_HELMET) {
9
- app.use(helmet());
10
- }
11
- ```
12
-
13
- To just this:
14
- ```ts
15
- app.use(helmet());
16
- ```
17
-
18
-
19
- ## Available Scripts
20
-
21
- ### `npm run clean-install`
22
-
23
- Remove the existing `node_modules/` folder, `package-lock.json`, and reinstall all library modules.
24
-
25
-
26
- ### `npm run dev` or `npm run dev:hot` (hot reloading)
27
-
28
- Run the server in development mode.<br/>
29
-
30
- **IMPORTANT** development mode uses `swc` for performance reasons which DOES NOT check for typescript errors. Run `npm run type-check` to check for type errors. NOTE: you should use your IDE to prevent most type errors.
31
-
32
-
33
- ### `npm test` or `npm run test:hot` (hot reloading)
34
-
35
- Run all unit-tests.
36
-
37
-
38
- ### `npm test -- "name of test file" (i.e. users).`
39
-
40
- Run a single unit-test.
41
-
42
-
43
- ### `npm run lint`
44
-
45
- Check for linting errors.
46
-
47
-
48
- ### `npm run build`
49
-
50
- Build the project for production.
51
-
52
-
53
- ### `npm start`
54
-
55
- Run the production build (Must be built first).
56
-
57
-
58
- ### `npm run type-check`
59
-
60
- Check for typescript errors.
61
-
62
-
63
- ## Additional Notes
64
-
65
- - If `npm run dev` gives you issues with bcrypt on MacOS you may need to run: `npm rebuild bcrypt --build-from-source`.
1
+ ## About
2
+
3
+ This project was created with [express-generator-typescript](https://github.com/seanpmaxwell/express-generator-typescript).
4
+
5
+ **IMPORTANT** for demo purposes I had to disable `helmet` in production. In any real world app you should change these 3 lines of code in `src/server.ts`:
6
+
7
+ ```ts
8
+ // eslint-disable-next-line n/no-process-env
9
+ if (!process.env.DISABLE_HELMET) {
10
+ app.use(helmet());
11
+ }
12
+ ```
13
+
14
+ To just this:
15
+
16
+ ```ts
17
+ app.use(helmet());
18
+ ```
19
+
20
+ ## Available Scripts
21
+
22
+ ### `npm run clean-install`
23
+
24
+ Remove the existing `node_modules/` folder, `package-lock.json`, and reinstall all library modules.
25
+
26
+ ### `npm run dev` or `npm run dev:watch` (hot reloading)
27
+
28
+ Run the server in development mode.<br/>
29
+
30
+ **IMPORTANT** development mode uses `swc` for performance reasons which DOES NOT check for typescript errors. Run `npm run type-check` to check for type errors. NOTE: you should use your IDE to prevent most type errors.
31
+
32
+ ### `npm test`
33
+
34
+ Run unit-tests with <a href="https://vitest.dev/guide/">vitest</a>.
35
+
36
+ ### `npm run lint`
37
+
38
+ Check for linting errors.
39
+
40
+ ### `npm run build`
41
+
42
+ Build the project for production.
43
+
44
+ ### `npm start`
45
+
46
+ Run the production build (Must be built first).
47
+
48
+ ### `npm run type-check`
49
+
50
+ Check for typescript errors.
51
+
52
+ ## Additional Notes
53
+
54
+ - If `npm run dev` gives you issues with bcrypt on MacOS you may need to run: `npm rebuild bcrypt --build-from-source`.
File without changes
File without changes
File without changes
@@ -1,100 +1,46 @@
1
- import eslint from '@eslint/js';
2
- import tseslint from 'typescript-eslint';
3
- import stylistic from '@stylistic/eslint-plugin';
4
- import nodePlugin from 'eslint-plugin-n';
5
- import { defineConfig } from 'eslint/config';
6
-
7
- export default defineConfig(
8
- eslint.configs.recommended,
9
- nodePlugin.configs['flat/recommended-script'],
10
- ...tseslint.configs.strictTypeChecked,
11
- ...tseslint.configs.stylisticTypeChecked,
12
- {
13
- ignores: [
14
- '**/node_modules/*',
15
- '**/*.mjs',
16
- '**/*.js',
17
- ],
18
- },
19
- {
20
- languageOptions: {
21
- parserOptions: {
22
- project: './tsconfig.json',
23
- warnOnUnsupportedTypeScriptVersion: false,
24
- },
25
- },
26
- },
27
- {
28
- plugins: {
29
- '@stylistic': stylistic,
30
- },
31
- },
32
- {
33
- files: ['**/*.ts'],
34
- },
35
- {
36
- rules: {
37
- '@typescript-eslint/explicit-member-accessibility': 'warn',
38
- '@typescript-eslint/no-misused-promises': 0,
39
- '@typescript-eslint/no-floating-promises': 0,
40
- '@typescript-eslint/no-confusing-void-expression': 0,
41
- '@typescript-eslint/no-unnecessary-condition': 0,
42
- '@typescript-eslint/restrict-template-expressions': [
43
- 'error', { allowNumber: true },
44
- ],
45
- '@typescript-eslint/restrict-plus-operands': [
46
- 'warn', { allowNumberAndString: true },
47
- ],
48
- '@typescript-eslint/no-unused-vars': [
49
- 'warn',
50
- {
51
- argsIgnorePattern: '^_',
52
- varsIgnorePattern: '^_',
53
- },
54
- ],
55
- '@typescript-eslint/no-unsafe-enum-comparison': 0,
56
- '@typescript-eslint/no-unnecessary-type-parameters': 0,
57
- '@stylistic/no-extra-semi': 'warn',
58
- 'max-len': [
59
- 'warn',
60
- {
61
- 'code': 80,
62
- },
63
- ],
64
- '@stylistic/semi': ['warn', 'always'],
65
- '@stylistic/member-delimiter-style': ['warn', {
66
- 'multiline': {
67
- 'delimiter': 'comma',
68
- 'requireLast': true,
69
- },
70
- 'singleline': {
71
- 'delimiter': 'comma',
72
- 'requireLast': false,
73
- },
74
- 'overrides': {
75
- 'interface': {
76
- 'singleline': {
77
- 'delimiter': 'semi',
78
- 'requireLast': false,
79
- },
80
- 'multiline': {
81
- 'delimiter': 'semi',
82
- 'requireLast': true,
83
- },
84
- },
85
- },
86
- }],
87
- '@typescript-eslint/no-non-null-assertion': 0,
88
- '@typescript-eslint/no-unused-expressions': 'warn',
89
- 'comma-dangle': ['warn', 'always-multiline'],
90
- 'no-console': 1,
91
- 'no-extra-boolean-cast': 0,
92
- 'indent': ['warn', 2],
93
- 'quotes': ['warn', 'single'],
94
- 'n/no-process-env': 1,
95
- 'n/no-missing-import': 0,
96
- 'n/no-unpublished-import': 0,
97
- 'prefer-const': 'warn',
98
- },
99
- },
100
- );
1
+ import js from '@eslint/js';
2
+ import eslintConfigPrettier from 'eslint-config-prettier/flat';
3
+ import n from 'eslint-plugin-n';
4
+ import { defineConfig, globalIgnores } from 'eslint/config';
5
+ import tseslint from 'typescript-eslint';
6
+
7
+ export default defineConfig([
8
+ // global ignores
9
+ globalIgnores(['**/dist/**']),
10
+ // linting rules (code quality only)
11
+ {
12
+ files: ['**/*.{ts,tsx}'],
13
+ extends: [
14
+ js.configs.recommended,
15
+ ...tseslint.configs.recommendedTypeChecked,
16
+ ],
17
+ languageOptions: {
18
+ parser: tseslint.parser,
19
+ parserOptions: {
20
+ project: './tsconfig.json',
21
+ },
22
+ },
23
+ plugins: {
24
+ n,
25
+ },
26
+ rules: {
27
+ // code quality / correctness
28
+ '@typescript-eslint/no-unused-vars': [
29
+ 'warn',
30
+ {
31
+ argsIgnorePattern: '^_',
32
+ caughtErrorsIgnorePattern: '^_',
33
+ destructuredArrayIgnorePattern: '^_',
34
+ ignoreRestSiblings: true,
35
+ },
36
+ ],
37
+ 'no-console': 'warn',
38
+ 'no-extra-boolean-cast': 'off',
39
+ 'no-process-env': 'warn',
40
+ // node correctness
41
+ 'n/no-extraneous-import': 'error'
42
+ },
43
+ },
44
+ // MUST be last — disables ALL formatting rules
45
+ eslintConfigPrettier,
46
+ ]);
@@ -1,6 +1,4 @@
1
1
  **/node_modules
2
2
  dist/
3
- temp/
4
3
  **/**/*.log
5
- config.js
6
4
  tsconfig.tsbuildinfo
@@ -1,56 +1,62 @@
1
- {
2
- "name": "express-typescript-example",
3
- "version": "0.0.0",
4
- "scripts": {
5
- "build": "ts-node ./scripts/build.ts",
6
- "clean-install": "rm -rf ./node_modules && rm -r package-lock.json && npm i",
7
- "dev": "NODE_ENV=development ts-node ./src",
8
- "dev:hot": "nodemon --exec \"npm run dev\" --watch ./src --ext .ts",
9
- "lint": "eslint .",
10
- "start": "NODE_ENV=production node -r ./config.js ./dist",
11
- "test": "NODE_ENV=test vitest",
12
- "type-check": "tsc -b --noEmit"
13
- },
14
- "engines": {
15
- "node": ">=16.0.0"
16
- },
17
- "dependencies": {
18
- "cookie-parser": "^1.4.7",
19
- "dayjs": "^1.11.19",
20
- "dotenv": "^17.2.3",
21
- "express": "^5.2.1",
22
- "helmet": "^8.1.0",
23
- "jet-env": "^1.1.6",
24
- "jet-logger": "^2.2.3",
25
- "jet-paths": "^2.0.1",
26
- "jet-validators": "^2.2.0",
27
- "jsonfile": "^6.2.0",
28
- "module-alias": "^2.2.3",
29
- "morgan": "^1.10.1"
30
- },
31
- "devDependencies": {
32
- "@eslint/js": "^9.39.2",
33
- "@stylistic/eslint-plugin": "^5.7.0",
34
- "@swc/core": "^1.15.8",
35
- "@types/cookie-parser": "^1.4.10",
36
- "@types/find": "^0.2.4",
37
- "@types/fs-extra": "^11.0.4",
38
- "@types/jsonfile": "^6.1.4",
39
- "@types/module-alias": "^2.0.4",
40
- "@types/morgan": "^1.9.10",
41
- "@types/node": "^25.0.5",
42
- "@types/supertest": "^6.0.3",
43
- "eslint": "^9.39.2",
44
- "eslint-plugin-n": "^17.23.1",
45
- "find": "^0.3.0",
46
- "fs-extra": "^11.3.3",
47
- "jiti": "^2.6.1",
48
- "nodemon": "^3.1.11",
49
- "supertest": "^7.2.2",
50
- "ts-node": "^10.9.2",
51
- "tsconfig-paths": "^4.2.0",
52
- "typescript": "^5.9.3",
53
- "typescript-eslint": "^8.52.0",
54
- "vitest": "^4.0.16"
55
- }
56
- }
1
+ {
2
+ "name": "express-typescript-example",
3
+ "version": "0.0.0",
4
+ "scripts": {
5
+ "build": "npm run lint && tsc --project tsconfig.prod.json",
6
+ "clean-install": "rm -rf ./node_modules && rm -r package-lock.json && npm i",
7
+ "dev": "DOTENV_CONFIG_PATH=./config/.env.development ts-node ./src/main",
8
+ "dev:watch": "nodemon --exec \"npm run dev\" --watch ./src --ext .ts",
9
+ "lint": "eslint .",
10
+ "format": "prettier --write .",
11
+ "start": "DOTENV_CONFIG_PATH=./config/.env.production node -r dotenv/config -r module-alias/register ./dist/main.js",
12
+ "test": "NODE_ENV=test vitest",
13
+ "type-check": "tsc -b --noEmit"
14
+ },
15
+ "engines": {
16
+ "node": ">=16.0.0"
17
+ },
18
+ "_moduleAliases": {
19
+ "@src": "dist"
20
+ },
21
+ "dependencies": {
22
+ "cookie-parser": "^1.4.7",
23
+ "dayjs": "^1.11.19",
24
+ "dotenv": "^17.2.3",
25
+ "express": "^5.2.1",
26
+ "helmet": "^8.1.0",
27
+ "jet-env": "^1.1.6",
28
+ "jet-logger": "^2.2.3",
29
+ "jet-paths": "^2.0.1",
30
+ "jet-validators": "^2.2.5",
31
+ "jsonfile": "^6.2.0",
32
+ "module-alias": "^2.2.3",
33
+ "morgan": "^1.10.1"
34
+ },
35
+ "devDependencies": {
36
+ "@eslint/js": "^9.39.2",
37
+ "@swc/core": "^1.15.8",
38
+ "@trivago/prettier-plugin-sort-imports": "^6.0.2",
39
+ "@types/cookie-parser": "^1.4.10",
40
+ "@types/find": "^0.2.4",
41
+ "@types/fs-extra": "^11.0.4",
42
+ "@types/jsonfile": "^6.1.4",
43
+ "@types/module-alias": "^2.0.4",
44
+ "@types/morgan": "^1.9.10",
45
+ "@types/node": "^25.0.9",
46
+ "@types/supertest": "^6.0.3",
47
+ "eslint": "^9.39.2",
48
+ "eslint-config-prettier": "^10.1.8",
49
+ "eslint-plugin-n": "^17.23.2",
50
+ "find": "^0.3.0",
51
+ "fs-extra": "^11.3.3",
52
+ "jiti": "^2.6.1",
53
+ "nodemon": "^3.1.11",
54
+ "prettier": "^3.8.0",
55
+ "supertest": "^7.2.2",
56
+ "ts-node": "^10.9.2",
57
+ "tsconfig-paths": "^4.2.0",
58
+ "typescript": "^5.9.3",
59
+ "typescript-eslint": "^8.53.0",
60
+ "vitest": "^4.0.17"
61
+ }
62
+ }