express-generator-typescript 2.4.17 → 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 +2 -32
- package/lib/express-generator-typescript.js +3 -2
- package/lib/project-files/.eslintignore +1 -1
- package/lib/project-files/package.json +8 -12
- package/lib/project-files/preload.js +20 -0
- package/lib/project-files/{build.ts → scripts/build.ts} +3 -3
- package/lib/project-files/src/repos/database.json +1 -22
- package/lib/project-files/tsconfig.json +4 -1
- package/lib/project-files/tsconfig.prod.json +1 -1
- package/lib/project-files-auth/.eslintignore +1 -1
- package/lib/project-files-auth/package.json +8 -12
- package/lib/project-files-auth/preload.js +20 -0
- package/lib/project-files-auth/{build.ts → scripts/build.ts} +2 -2
- package/lib/project-files-auth/tsconfig.json +4 -1
- package/lib/project-files-auth/tsconfig.prod.json +1 -1
- package/package.json +1 -1
- package/lib/project-files/dotenv.config.js +0 -16
- package/lib/project-files/nodemon.json +0 -10
- package/lib/project-files/nodemon.spec.json +0 -6
- package/lib/project-files-auth/dotenv.config.js +0 -16
- package/lib/project-files-auth/nodemon.json +0 -10
- package/lib/project-files-auth/nodemon.spec.json +0 -6
- package/lib/project-files-auth/spec/nodemon.json +0 -6
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
|
|
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
|
|
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
|
|
@@ -20,13 +20,14 @@ const PROJECT_FOLDER_PATH = './project-files';
|
|
|
20
20
|
// Project-folder dependencies
|
|
21
21
|
const DEPENDENCIES = 'express dotenv morgan cookie-parser jet-logger ' +
|
|
22
22
|
'module-alias express-async-errors helmet jsonfile inserturlparams ' +
|
|
23
|
-
'
|
|
23
|
+
'jet-paths moment',
|
|
24
24
|
DEPENDENCIES_AUTH = ' bcrypt jsonwebtoken',
|
|
25
25
|
DEV_DEPENDENCIES = 'ts-node typescript nodemon find jasmine supertest ' +
|
|
26
26
|
'@types/node @types/express @types/jasmine @types/find @types/morgan ' +
|
|
27
27
|
'@types/cookie-parser @types/supertest fs-extra tsconfig-paths ' +
|
|
28
28
|
'@types/jsonfile @typescript-eslint/eslint-plugin eslint ' +
|
|
29
|
-
'@typescript-eslint/parser @types/fs-extra eslint-plugin-node'
|
|
29
|
+
'@typescript-eslint/parser @types/fs-extra eslint-plugin-node ' +
|
|
30
|
+
'ts-command-line-args',
|
|
30
31
|
DEV_DEPENDENCIES_AUTH = ' @types/bcrypt @types/jsonwebtoken';
|
|
31
32
|
|
|
32
33
|
// "ncp" options
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
src/public/
|
|
2
|
-
|
|
2
|
+
preload.js
|
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
"name": "express-typescript-example",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"dev": "npm run
|
|
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
|
|
12
|
-
"test": "NODE_ENV=test
|
|
13
|
-
"test:hot": "nodemon --
|
|
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"
|
|
@@ -32,8 +28,7 @@
|
|
|
32
28
|
"jsonwebtoken": "^8.5.1",
|
|
33
29
|
"module-alias": "^2.2.2",
|
|
34
30
|
"moment": "^2.30.1",
|
|
35
|
-
"morgan": "^1.10.0"
|
|
36
|
-
"ts-command-line-args": "^2.4.2"
|
|
31
|
+
"morgan": "^1.10.0"
|
|
37
32
|
},
|
|
38
33
|
"devDependencies": {
|
|
39
34
|
"@types/bcrypt": "^5.0.0",
|
|
@@ -56,6 +51,7 @@
|
|
|
56
51
|
"jasmine": "^4.3.0",
|
|
57
52
|
"nodemon": "^2.0.19",
|
|
58
53
|
"supertest": "^6.3.4",
|
|
54
|
+
"ts-command-line-args": "^2.4.2",
|
|
59
55
|
"ts-node": "^10.9.1",
|
|
60
56
|
"tsconfig-paths": "^4.1.0",
|
|
61
57
|
"typescript": "^4.8.2"
|
|
@@ -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
|
-
|
|
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
|
-
"
|
|
81
|
+
"scripts"
|
|
79
82
|
],
|
|
80
83
|
"exclude": [
|
|
81
84
|
"src/public/"
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
src/public/
|
|
2
|
-
|
|
2
|
+
preload.js
|
|
@@ -2,18 +2,14 @@
|
|
|
2
2
|
"name": "express-typescript-example",
|
|
3
3
|
"version": "0.0.0",
|
|
4
4
|
"scripts": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"dev": "npm run
|
|
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
|
|
12
|
-
"test": "NODE_ENV=test
|
|
13
|
-
"test:hot": "nodemon --
|
|
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"
|
|
@@ -32,8 +28,7 @@
|
|
|
32
28
|
"jsonwebtoken": "^8.5.1",
|
|
33
29
|
"module-alias": "^2.2.2",
|
|
34
30
|
"moment": "^2.30.1",
|
|
35
|
-
"morgan": "^1.10.0"
|
|
36
|
-
"ts-command-line-args": "^2.4.2"
|
|
31
|
+
"morgan": "^1.10.0"
|
|
37
32
|
},
|
|
38
33
|
"devDependencies": {
|
|
39
34
|
"@types/bcrypt": "^5.0.0",
|
|
@@ -56,6 +51,7 @@
|
|
|
56
51
|
"jasmine": "^4.3.0",
|
|
57
52
|
"nodemon": "^2.0.19",
|
|
58
53
|
"supertest": "^6.3.4",
|
|
54
|
+
"ts-command-line-args": "^2.4.2",
|
|
59
55
|
"ts-node": "^10.9.1",
|
|
60
56
|
"tsconfig-paths": "^4.1.0",
|
|
61
57
|
"typescript": "^4.8.2"
|
|
@@ -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
|
-
|
|
17
|
+
await exec('npx eslint --ext .ts src/', './');
|
|
18
18
|
await exec('tsc --build tsconfig.prod.json', './');
|
|
19
|
-
// Copy
|
|
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
|
-
"
|
|
81
|
+
"scripts"
|
|
79
82
|
],
|
|
80
83
|
"exclude": [
|
|
81
84
|
"src/public/"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "2.4.
|
|
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,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
|
-
}
|