express-generator-typescript 2.7.12 → 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 (46) 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 +0 -0
  5. package/lib/project-files/.prettierignore +0 -0
  6. package/lib/project-files/.prettierrc.json +0 -0
  7. package/lib/project-files/README.md +3 -7
  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 +0 -0
  12. package/lib/project-files/gitignore +0 -2
  13. package/lib/project-files/package.json +11 -8
  14. package/lib/project-files/src/common/constants/HttpStatusCodes.ts +0 -0
  15. package/lib/project-files/src/common/constants/Paths.ts +0 -0
  16. package/lib/project-files/src/common/constants/env.ts +0 -0
  17. package/lib/project-files/src/common/utils/number-utils.ts +0 -0
  18. package/lib/project-files/src/common/utils/route-errors.ts +0 -0
  19. package/lib/project-files/src/common/utils/validators.ts +0 -0
  20. package/lib/project-files/src/main.ts +0 -0
  21. package/lib/project-files/src/models/User.ts +10 -6
  22. package/lib/project-files/src/models/common/IModel.ts +2 -2
  23. package/lib/project-files/src/public/stylesheets/users.css +0 -0
  24. package/lib/project-files/src/repos/MockOrm.ts +0 -0
  25. package/lib/project-files/src/repos/UserRepo.ts +4 -6
  26. package/lib/project-files/src/repos/common/database.json +0 -0
  27. package/lib/project-files/src/repos/common/database.test.json +1 -22
  28. package/lib/project-files/src/routes/UserRoutes.ts +0 -0
  29. package/lib/project-files/src/routes/apiRouter.ts +0 -0
  30. package/lib/project-files/src/routes/common/express-types.ts +0 -0
  31. package/lib/project-files/src/routes/common/parseReq.ts +0 -0
  32. package/lib/project-files/src/server.ts +0 -0
  33. package/lib/project-files/src/services/UserService.ts +0 -0
  34. package/lib/project-files/src/views/users.html +0 -0
  35. package/lib/project-files/tests/common/comparators.ts +3 -3
  36. package/lib/project-files/tests/common/error-utils.ts +0 -0
  37. package/lib/project-files/tests/common/supertest-types.ts +0 -0
  38. package/lib/project-files/tests/support/agent.ts +0 -0
  39. package/lib/project-files/tests/users.test.ts +0 -0
  40. package/lib/project-files/tsconfig.json +1 -2
  41. package/lib/project-files/tsconfig.prod.json +2 -2
  42. package/lib/project-files/vitest.config.mts +4 -1
  43. package/package.json +1 -1
  44. package/lib/project-files/config.ts +0 -20
  45. package/lib/project-files/scripts/build.ts +0 -23
  46. package/lib/project-files/scripts/common/utils.ts +0 -93
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
package/lib/cli.js CHANGED
File without changes
File without changes
File without changes
File without changes
@@ -23,19 +23,15 @@ app.use(helmet());
23
23
 
24
24
  Remove the existing `node_modules/` folder, `package-lock.json`, and reinstall all library modules.
25
25
 
26
- ### `npm run dev` or `npm run dev:hot` (hot reloading)
26
+ ### `npm run dev` or `npm run dev:watch` (hot reloading)
27
27
 
28
28
  Run the server in development mode.<br/>
29
29
 
30
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
31
 
32
- ### `npm test` or `npm run test:hot` (hot reloading)
32
+ ### `npm test`
33
33
 
34
- Run all unit-tests.
35
-
36
- ### `npm test -- "name of test file" (i.e. users).`
37
-
38
- Run a single unit-test.
34
+ Run unit-tests with <a href="https://vitest.dev/guide/">vitest</a>.
39
35
 
40
36
  ### `npm run lint`
41
37
 
File without changes
File without changes
File without changes
File without changes
@@ -1,6 +1,4 @@
1
1
  **/node_modules
2
2
  dist/
3
- temp/
4
3
  **/**/*.log
5
- config.js
6
4
  tsconfig.tsbuildinfo
@@ -2,19 +2,22 @@
2
2
  "name": "express-typescript-example",
3
3
  "version": "0.0.0",
4
4
  "scripts": {
5
- "build": "ts-node ./scripts/build.ts",
5
+ "build": "npm run lint && tsc --project tsconfig.prod.json",
6
6
  "clean-install": "rm -rf ./node_modules && rm -r package-lock.json && npm i",
7
- "dev": "NODE_ENV=development ts-node ./src/main",
8
- "dev:hot": "nodemon --exec \"npm run dev\" --watch ./src --ext .ts",
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
9
  "lint": "eslint .",
10
10
  "format": "prettier --write .",
11
- "start": "NODE_ENV=production node -r ./config.js ./dist/main",
11
+ "start": "DOTENV_CONFIG_PATH=./config/.env.production node -r dotenv/config -r module-alias/register ./dist/main.js",
12
12
  "test": "NODE_ENV=test vitest",
13
13
  "type-check": "tsc -b --noEmit"
14
14
  },
15
15
  "engines": {
16
16
  "node": ">=16.0.0"
17
17
  },
18
+ "_moduleAliases": {
19
+ "@src": "dist"
20
+ },
18
21
  "dependencies": {
19
22
  "cookie-parser": "^1.4.7",
20
23
  "dayjs": "^1.11.19",
@@ -24,7 +27,7 @@
24
27
  "jet-env": "^1.1.6",
25
28
  "jet-logger": "^2.2.3",
26
29
  "jet-paths": "^2.0.1",
27
- "jet-validators": "2.2.5",
30
+ "jet-validators": "^2.2.5",
28
31
  "jsonfile": "^6.2.0",
29
32
  "module-alias": "^2.2.3",
30
33
  "morgan": "^1.10.1"
@@ -39,7 +42,7 @@
39
42
  "@types/jsonfile": "^6.1.4",
40
43
  "@types/module-alias": "^2.0.4",
41
44
  "@types/morgan": "^1.9.10",
42
- "@types/node": "^25.0.5",
45
+ "@types/node": "^25.0.9",
43
46
  "@types/supertest": "^6.0.3",
44
47
  "eslint": "^9.39.2",
45
48
  "eslint-config-prettier": "^10.1.8",
@@ -53,7 +56,7 @@
53
56
  "ts-node": "^10.9.2",
54
57
  "tsconfig-paths": "^4.2.0",
55
58
  "typescript": "^5.9.3",
56
- "typescript-eslint": "^8.52.0",
57
- "vitest": "^4.0.16"
59
+ "typescript-eslint": "^8.53.0",
60
+ "vitest": "^4.0.17"
58
61
  }
59
62
  }
File without changes
File without changes
File without changes
File without changes
@@ -16,10 +16,20 @@ const GetDefaults = (): IUser => ({
16
16
  created: new Date(),
17
17
  });
18
18
 
19
+ const schema: Schema<IUser> = {
20
+ id: isUnsignedInteger,
21
+ name: isString,
22
+ email: isString,
23
+ created: transformIsDate,
24
+ };
25
+
19
26
  /******************************************************************************
20
27
  Types
21
28
  ******************************************************************************/
22
29
 
30
+ /**
31
+ * @entity users
32
+ */
23
33
  export interface IUser extends IModel {
24
34
  name: string;
25
35
  email: string;
@@ -29,12 +39,6 @@ export interface IUser extends IModel {
29
39
  Setup
30
40
  ******************************************************************************/
31
41
 
32
- const schema: Schema<IUser> = {
33
- id: isUnsignedInteger,
34
- name: isString,
35
- email: isString,
36
- created: transformIsDate,
37
- };
38
42
 
39
43
  // Set the "parseUser" function
40
44
  const parseUser = parseObject<IUser>(schema);
@@ -1,4 +1,4 @@
1
1
  export interface IModel {
2
- id: number;
3
- created: Date;
2
+ id: number; // @PK
3
+ created: Date | string; // @audit
4
4
  }
File without changes
@@ -85,10 +85,9 @@ async function __delete__(id: number): Promise<void> {
85
85
  // **** Unit-Tests Only **** //
86
86
 
87
87
  /**
88
+ * @testOnly
89
+ *
88
90
  * Delete every user record.
89
- *
90
- * @internal
91
- * Test-only helper. Do not use in production code.
92
91
  */
93
92
  async function deleteAllUsers(): Promise<void> {
94
93
  const db = await orm.openDb();
@@ -97,11 +96,10 @@ async function deleteAllUsers(): Promise<void> {
97
96
  }
98
97
 
99
98
  /**
99
+ * @testOnly
100
+ *
100
101
  * Insert multiple users. Can't do multiple at once cause using a plain file
101
102
  * for now.
102
- *
103
- * @internal
104
- * Test-only helper. Do not use in production code.
105
103
  */
106
104
  async function insertMultiple(
107
105
  users: IUser[] | readonly IUser[],
File without changes
@@ -1,22 +1 @@
1
- {
2
- "users": [
3
- {
4
- "id": 547317739445,
5
- "name": "Bill",
6
- "email": "sean.maxwell@gmail.com",
7
- "created": "2026-01-10T04:06:20.291Z"
8
- },
9
- {
10
- "id": 332906029656,
11
- "name": "John Smith",
12
- "email": "john.smith@gmail.com",
13
- "created": "2026-01-10T04:06:20.291Z"
14
- },
15
- {
16
- "id": 421195709596,
17
- "name": "Gordan Freeman",
18
- "email": "gordan.freeman@gmail.com",
19
- "created": "2026-01-10T04:06:20.291Z"
20
- }
21
- ]
22
- }
1
+ {"users":[{"id":743599328040,"name":"Bill","email":"sean.maxwell@gmail.com","created":"2026-01-22T02:53:04.104Z"},{"id":366376663219,"name":"John Smith","email":"john.smith@gmail.com","created":"2026-01-22T02:53:04.104Z"},{"id":223776680823,"name":"Gordan Freeman","email":"gordan.freeman@gmail.com","created":"2026-01-22T02:53:04.104Z"}]}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -4,7 +4,7 @@ import { IUser } from '@src/models/User';
4
4
  Types
5
5
  ******************************************************************************/
6
6
 
7
- type TUserArray = IUser[] | readonly IUser[];
7
+ type UserArray = IUser[] | readonly IUser[];
8
8
 
9
9
  /******************************************************************************
10
10
  Functions
@@ -14,7 +14,7 @@ type TUserArray = IUser[] | readonly IUser[];
14
14
  * Compare to user arrays. Order does not matter and this assumes the email
15
15
  * field is unique
16
16
  */
17
- export function compareUserArrays(a: TUserArray, b: TUserArray): boolean {
17
+ export function compareUserArrays(a: UserArray, b: UserArray): boolean {
18
18
  if (a.length !== b.length) return false;
19
19
  const aSorted = sortByEmail(a),
20
20
  bSorted = sortByEmail(b);
@@ -31,7 +31,7 @@ export function compareUserArrays(a: TUserArray, b: TUserArray): boolean {
31
31
  /**
32
32
  * Sort user array by email.
33
33
  */
34
- function sortByEmail(arr: TUserArray): IUser[] {
34
+ function sortByEmail(arr: UserArray): IUser[] {
35
35
  return [...arr].sort((x, y) => {
36
36
  return x.email.localeCompare(y.email);
37
37
  });
File without changes
File without changes
File without changes
File without changes
@@ -16,12 +16,11 @@
16
16
  },
17
17
  "ts-node": {
18
18
  "swc": true,
19
- "require": ["tsconfig-paths/register", "./config.ts"]
19
+ "require": ["tsconfig-paths/register", "dotenv/config"],
20
20
  },
21
21
  "include": [
22
22
  "src/**/*.ts",
23
23
  "tests/**/*.ts",
24
- "config.ts",
25
24
  "scripts",
26
25
  "eslint.config.ts",
27
26
  "vitest.config.mts"
@@ -5,7 +5,7 @@
5
5
  "lib": ["ES2020"],
6
6
  "strict": true,
7
7
  "baseUrl": "./",
8
- "outDir": "temp",
8
+ "outDir": "dist",
9
9
  "esModuleInterop": true,
10
10
  "skipLibCheck": true,
11
11
  "forceConsistentCasingInFileNames": true,
@@ -16,7 +16,7 @@
16
16
  "sourceMap": false,
17
17
  "removeComments": true
18
18
  },
19
- "include": ["src/**/*.ts", "config.ts"],
19
+ "include": ["src/**/*.ts"],
20
20
  "exclude": [
21
21
  "tests",
22
22
  "src/public/",
@@ -5,8 +5,11 @@ const config = defineConfig({
5
5
  test: {
6
6
  globals: true,
7
7
  environment: 'node',
8
- setupFiles: ['config.ts', './tests/support/agent.ts'],
8
+ setupFiles: ['dotenv/config', './tests/support/agent.ts'],
9
9
  isolate: true,
10
+ env: {
11
+ DOTENV_CONFIG_PATH: 'config/.env.test',
12
+ },
10
13
  },
11
14
  resolve: {
12
15
  alias: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-generator-typescript",
3
- "version": "2.7.12",
3
+ "version": "2.7.14",
4
4
  "description": "Generate new Express applications similar to express-generate which but sets it up to use TypeScript instead",
5
5
  "scripts": {
6
6
  "express-generator-typescript": "node bin/cli.js",
@@ -1,20 +0,0 @@
1
- import dotenv from 'dotenv';
2
- import moduleAlias from 'module-alias';
3
- import path from 'path';
4
-
5
- // Check the env
6
- // eslint-disable-next-line no-process-env
7
- const NODE_ENV = process.env.NODE_ENV ?? 'development';
8
-
9
- // Configure "dotenv"
10
- const result2 = dotenv.config({
11
- path: path.join(__dirname, `./config/.env.${NODE_ENV}`),
12
- });
13
- if (result2.error) {
14
- throw result2.error;
15
- }
16
-
17
- // Configure moduleAlias
18
- if (__filename.endsWith('js')) {
19
- moduleAlias.addAlias('@src', __dirname + '/dist');
20
- }
@@ -1,23 +0,0 @@
1
- import logger from 'jet-logger';
2
-
3
- import { copy, copyFilesRec, exec, remove } from './common/utils';
4
-
5
- /******************************************************************************
6
- Run
7
- ******************************************************************************/
8
-
9
- (async () => {
10
- // Remove current build
11
- await remove('./dist/');
12
- await exec('npm run lint', '../');
13
- await exec('tsc --project tsconfig.prod.json', '../');
14
- // Copy
15
- await copyFilesRec('./src', './dist', ['.ts']);
16
- await copy('./temp/config.js', './config.js');
17
- await copy('./temp/src', './dist');
18
- await remove('./temp/');
19
- })().catch((err) => {
20
- logger.err(err);
21
- process.exit(1);
22
- })
23
-
@@ -1,93 +0,0 @@
1
- import childProcess from 'child_process';
2
- import fs from 'fs-extra';
3
- import logger from 'jet-logger';
4
- import path from 'path';
5
-
6
- /******************************************************************************
7
- Functions
8
- *******************************************************************************
9
-
10
- /**
11
- * Copy file.
12
- */
13
- export function copy(src: string, dest: string): Promise<void> {
14
- return new Promise((res, rej) => {
15
- return fs.copy(src, dest, (err) => {
16
- return !!err ? rej(err) : res();
17
- });
18
- });
19
- }
20
-
21
- /**
22
- * Remove file
23
- */
24
- export function remove(loc: string): Promise<void> {
25
- return new Promise((res, rej) => {
26
- return fs.remove(loc, (err) => {
27
- return !!err ? rej(err) : res();
28
- });
29
- });
30
- }
31
-
32
- /**
33
- * Run command-line command.
34
- */
35
- export function exec(cmd: string, loc = './'): Promise<string> {
36
- // Setup directory
37
- const callingDir = path.dirname(require.main?.filename ?? './'),
38
- cwd = path.join(callingDir, loc);
39
- // Wrap in promise
40
- return new Promise((res, rej) =>
41
- childProcess.exec(cmd, { cwd }, (err, stdout, stderr) => {
42
- if (!!stdout) {
43
- logger.info(stdout);
44
- }
45
- if (!!stderr) {
46
- logger.err(stderr);
47
- }
48
- if (!!err) {
49
- return rej(err);
50
- } else if (!!stderr) {
51
- return rej(new Error(stderr));
52
- } else {
53
- return res(stdout);
54
- }
55
- }),
56
- );
57
- }
58
-
59
- /**
60
- * Recursively search for a folder for all files and copy them to the new
61
- * destination keeping their paths relative to the "src" param.
62
- *
63
- * Example:
64
- * If file "./src/foo/bar.txt" exists then:
65
- * copyFilesRec('./src', './dest') => ["./dest/foo/bar.txt"]
66
- *
67
- * @param excludeExt Exlude a list of file extensions.
68
- */
69
- export async function copyFilesRec(
70
- src: string,
71
- dest: string,
72
- excludeExt?: string[],
73
- ): Promise<void> {
74
- const copyReqs: Promise<void>[] = [];
75
- try {
76
- const entries = await fs.readdir(src, { withFileTypes: true });
77
- for (const entry of entries) {
78
- const currPath = src + '/' + entry.name,
79
- currDest = dest + '/' + entry.name,
80
- ext = path.extname(entry.name);
81
- if (entry.isFile() && !excludeExt?.includes(ext)) {
82
- const req = fs.copy(currPath, currDest);
83
- copyReqs.push(req);
84
- } else if (entry.isDirectory()) {
85
- const req = copyFilesRec(currPath, currDest, excludeExt);
86
- copyReqs.push(req);
87
- }
88
- }
89
- } catch (error) {
90
- logger.err(`Error searching in ${src}: ` + String(error));
91
- }
92
- await Promise.all(copyReqs);
93
- }