express-generator-typescript 2.4.18 → 2.4.19

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.
package/README.md CHANGED
@@ -32,7 +32,7 @@ are packaged with this library.
32
32
 
33
33
  In addition, relative paths are also setup, so you don't have to go through the trouble of installing
34
34
  and configuring _tsconfig-paths_ and _module-alias_. Just make sure to update `paths` in _tsconfig.json_
35
- and `_moduleAliases` in _package.json_ if you want to add/edit the relative paths.
35
+ and `_moduleAliases` in _preload.js_ if you want to add/edit the relative paths.
36
36
 
37
37
 
38
38
  ## Sample-project
@@ -74,13 +74,11 @@ $ cd "project name" && npm run dev
74
74
  ## Available commands for the server.
75
75
 
76
76
  - Run the server in development mode: `npm run dev`.
77
- - Run all unit-tests with hot-reloading: `npm test`.
77
+ - Run all unit-tests: `npm test`.
78
78
  - Run a single unit-test: `npm test -- --testFile="name of test file" (i.e. --testFile=Users)`.
79
- - Run all unit-tests without hot-reloading: `npm run test:no-reloading`
80
79
  - Check for linting errors: `npm run lint`.
81
80
  - Build the project for production: `npm run build`.
82
81
  - Run the production build: `npm start`.
83
- - Run production build with a different env file `npm start -- --env="name of env file" (default is production)`.
84
82
 
85
83
 
86
84
  ## Debugging
@@ -91,34 +89,6 @@ This is located under `nodemonConfig:` in `package.json` for the server and `./s
91
89
  unit-testing. For the `exec` property, replace `ts-node` with `node --inspect -r ts-node/register`.
92
90
 
93
91
 
94
- ## Note for VS-Code users
95
-
96
- A lot of users have asked about _launch.json_ configurations for running this in VS-Code, so
97
- here's a snippet of the launch.json configuration you need to bypass nodemon and run directly with
98
- VS-Code.
99
-
100
- ```JSON
101
- {
102
- "type": "pwa-node",
103
- "request": "launch",
104
- "name": "Debug Dev Env",
105
- "runtimeArgs": [
106
- "-r",
107
- "ts-node/register",
108
- "-r",
109
- "tsconfig-paths/register",
110
- ],
111
- "args": [
112
- "${workspaceFolder:express-gen-ts}/src/index.ts"
113
- ],
114
- "resolveSourceMapLocations": [
115
- "${workspaceFolder}/**",
116
- "!**/node_modules/**"
117
- ],
118
- }
119
- ```
120
-
121
-
122
92
  ## Note for windows users
123
93
 
124
94
  If you are on Windows, the `bcrypt` module tends to be fussy. To use this module on Windows you
@@ -1,2 +1,2 @@
1
1
  src/public/
2
- dotenv.config.js
2
+ preload.js
@@ -2,18 +2,14 @@
2
2
  "name": "express-typescript-example",
3
3
  "version": "0.0.0",
4
4
  "scripts": {
5
- "_ts": "./node_modules/.bin/ts-node --files -r tsconfig-paths/register -r ./dotenv.config.js",
6
- "build": "npx ts-node build.ts",
7
- "dev": "npm run _ts -- ./src",
8
- "dev:hot": "nodemon",
5
+ "build": "ts-node ./scripts/build.ts",
6
+ "dev": "NODE_ENV=development ts-node ./src",
7
+ "dev:hot": "nodemon --exec \"npm run dev\" --watch ./src -e ts",
9
8
  "lint": "npx eslint --ext .ts src/",
10
9
  "lint:tests": "npx eslint --ext .ts spec/",
11
- "start": "NODE_ENV=production node -r module-alias/register -r ./dotenv.config.js ./dist",
12
- "test": "NODE_ENV=test npm run _ts -- ./spec",
13
- "test:hot": "nodemon --config ./nodemon.spec.json"
14
- },
15
- "_moduleAliases": {
16
- "@src": "dist"
10
+ "start": "NODE_ENV=production node -r ./preload.js ./dist",
11
+ "test": "NODE_ENV=test ts-node ./spec",
12
+ "test:hot": "nodemon --exec \"npm run test\" --watch ./src --watch ./spec -e ts"
17
13
  },
18
14
  "engines": {
19
15
  "node": ">=8.10.0"
@@ -0,0 +1,20 @@
1
+ const dotenv = require('dotenv');
2
+ const path = require('path');
3
+ const moduleAlias = require('module-alias');
4
+
5
+
6
+ // Check the env
7
+ const NODE_ENV = (process.env.NODE_ENV || 'development');
8
+
9
+ // Configure "dotenv"
10
+ const result2 = dotenv.config({
11
+ path: path.join(__dirname, `./env/${NODE_ENV}.env`),
12
+ });
13
+ if (result2.error) {
14
+ throw result2.error;
15
+ }
16
+
17
+ // Configure module-alias
18
+ if (NODE_ENV === 'production') {
19
+ moduleAlias.addAlias('@src', __dirname + '/dist');
20
+ }
@@ -14,11 +14,11 @@ import childProcess from 'child_process';
14
14
  try {
15
15
  // Remove current build
16
16
  await remove('./dist/');
17
- // Copy front-end files
17
+ await exec('npx eslint --ext .ts src/', './');
18
+ await exec('tsc --build tsconfig.prod.json', './');
19
+ // Copy
18
20
  await copy('./src/public', './dist/public');
19
21
  await copy('./src/views', './dist/views');
20
- // Copy back-end files
21
- await exec('tsc --build tsconfig.prod.json', './');
22
22
  } catch (err) {
23
23
  logger.err(err);
24
24
  process.exit(1);
@@ -1,22 +1 @@
1
- {
2
- "users": [
3
- {
4
- "id": 366115170645,
5
- "name": "Sean Maxwell",
6
- "email": "smaxwell@example.com",
7
- "created": "2024-03-22T05:14:36.252Z"
8
- },
9
- {
10
- "id": 310946254456,
11
- "name": "John Smith",
12
- "email": "john.smith@example.com",
13
- "created": "2024-03-22T05:20:55.079Z"
14
- },
15
- {
16
- "id": 143027113460,
17
- "name": "Gordan Freeman",
18
- "email": "nova@prospect.com",
19
- "created": "2024-03-22T05:42:18.895Z"
20
- }
21
- ]
22
- }
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"}]}
@@ -72,10 +72,13 @@
72
72
  },
73
73
  "useUnknownInCatchVariables": false
74
74
  },
75
+ "ts-node": {
76
+ "require": ["tsconfig-paths/register", "./preload.js"]
77
+ },
75
78
  "include": [
76
79
  "src/**/*.ts",
77
80
  "spec/**/*.ts",
78
- "build.ts"
81
+ "scripts"
79
82
  ],
80
83
  "exclude": [
81
84
  "src/public/"
@@ -7,6 +7,6 @@
7
7
  "exclude": [
8
8
  "spec",
9
9
  "src/public/",
10
- "build.ts"
10
+ "scripts"
11
11
  ]
12
12
  }
@@ -1,2 +1,2 @@
1
1
  src/public/
2
- dotenv.config.js
2
+ preload.js
@@ -2,18 +2,14 @@
2
2
  "name": "express-typescript-example",
3
3
  "version": "0.0.0",
4
4
  "scripts": {
5
- "_ts": "./node_modules/.bin/ts-node --files -r tsconfig-paths/register -r ./dotenv.config.js",
6
- "build": "npx ts-node build.ts",
7
- "dev": "npm run _ts -- ./src",
8
- "dev:hot": "nodemon",
5
+ "build": "ts-node ./scripts/build.ts",
6
+ "dev": "NODE_ENV=development ts-node ./src",
7
+ "dev:hot": "nodemon --exec \"npm run dev\" --watch ./src -e ts",
9
8
  "lint": "npx eslint --ext .ts src/",
10
9
  "lint:tests": "npx eslint --ext .ts spec/",
11
- "start": "NODE_ENV=production node -r module-alias/register -r ./dotenv.config.js ./dist",
12
- "test": "NODE_ENV=test npm run _ts -- ./spec",
13
- "test:hot": "nodemon --config ./nodemon.spec.json"
14
- },
15
- "_moduleAliases": {
16
- "@src": "dist"
10
+ "start": "NODE_ENV=production node -r ./preload.js ./dist",
11
+ "test": "NODE_ENV=test ts-node ./spec",
12
+ "test:hot": "nodemon --exec \"npm run test\" --watch ./src --watch ./spec -e ts"
17
13
  },
18
14
  "engines": {
19
15
  "node": ">=8.10.0"
@@ -0,0 +1,20 @@
1
+ const dotenv = require('dotenv');
2
+ const path = require('path');
3
+ const moduleAlias = require('module-alias');
4
+
5
+
6
+ // Check the env
7
+ const NODE_ENV = (process.env.NODE_ENV || 'development');
8
+
9
+ // Configure "dotenv"
10
+ const result2 = dotenv.config({
11
+ path: path.join(__dirname, `./env/${NODE_ENV}.env`),
12
+ });
13
+ if (result2.error) {
14
+ throw result2.error;
15
+ }
16
+
17
+ // Configure module-alias
18
+ if (NODE_ENV === 'production') {
19
+ moduleAlias.addAlias('@src', __dirname + '/dist');
20
+ }
@@ -14,9 +14,9 @@ import childProcess from 'child_process';
14
14
  try {
15
15
  // Remove current build
16
16
  await remove('./dist/');
17
- // Copy back-end files
17
+ await exec('npx eslint --ext .ts src/', './');
18
18
  await exec('tsc --build tsconfig.prod.json', './');
19
- // Copy front-end files
19
+ // Copy
20
20
  await copy('./src/public', './dist/public');
21
21
  await copy('./src/views', './dist/views');
22
22
  } catch (err) {
@@ -72,10 +72,13 @@
72
72
  },
73
73
  "useUnknownInCatchVariables": false
74
74
  },
75
+ "ts-node": {
76
+ "require": ["tsconfig-paths/register", "./preload.js"]
77
+ },
75
78
  "include": [
76
79
  "src/**/*.ts",
77
80
  "spec/**/*.ts",
78
- "build.ts"
81
+ "scripts"
79
82
  ],
80
83
  "exclude": [
81
84
  "src/public/"
@@ -7,6 +7,6 @@
7
7
  "exclude": [
8
8
  "spec",
9
9
  "src/public/",
10
- "build.ts"
10
+ "scripts"
11
11
  ]
12
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-generator-typescript",
3
- "version": "2.4.18",
3
+ "version": "2.4.19",
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,16 +0,0 @@
1
- var dotenv = require('dotenv');
2
- var path = require('path');
3
-
4
-
5
- // Check the env
6
- var NODE_ENV = process.env.NODE_ENV || 'development';
7
-
8
- // Configure the file
9
- const result2 = dotenv.config({
10
- path: path.join(__dirname, `./env/${NODE_ENV}.env`),
11
- });
12
-
13
- // Check for errors
14
- if (result2.error) {
15
- throw result2.error;
16
- }
@@ -1,10 +0,0 @@
1
- {
2
- "watch": [
3
- "src"
4
- ],
5
- "ext": "ts, html",
6
- "ignore": [
7
- "src/public"
8
- ],
9
- "exec": "npm run dev"
10
- }
@@ -1,6 +0,0 @@
1
- {
2
- "watch": ["spec"],
3
- "ext": "spec.ts",
4
- "ignore": ["spec/support"],
5
- "exec": "npm run test"
6
- }
@@ -1,16 +0,0 @@
1
- var dotenv = require('dotenv');
2
- var path = require('path');
3
-
4
-
5
- // Check the env
6
- var NODE_ENV = process.env.NODE_ENV || 'development';
7
-
8
- // Configure the file
9
- const result2 = dotenv.config({
10
- path: path.join(__dirname, `./env/${NODE_ENV}.env`),
11
- });
12
-
13
- // Check for errors
14
- if (result2.error) {
15
- throw result2.error;
16
- }
@@ -1,10 +0,0 @@
1
- {
2
- "watch": [
3
- "src"
4
- ],
5
- "ext": "ts, html",
6
- "ignore": [
7
- "src/public"
8
- ],
9
- "exec": "npm run dev"
10
- }
@@ -1,6 +0,0 @@
1
- {
2
- "watch": ["spec"],
3
- "ext": "spec.ts",
4
- "ignore": ["spec/support"],
5
- "exec": "npm run test"
6
- }
@@ -1,6 +0,0 @@
1
- {
2
- "watch": ["spec"],
3
- "ext": "spec.ts",
4
- "ignore": ["spec/support"],
5
- "exec": "./node_modules/.bin/ts-node --files -r tsconfig-paths/register ./spec"
6
- }