express-generator-typescript 2.4.15 → 2.4.18
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/lib/express-generator-typescript.js +3 -2
- package/lib/project-files/.eslintignore +1 -0
- package/lib/project-files/README.md +3 -11
- package/lib/project-files/dotenv.config.js +16 -0
- package/lib/project-files/nodemon.json +10 -0
- package/lib/project-files/nodemon.spec.json +6 -0
- package/lib/project-files/package.json +8 -16
- package/lib/project-files/spec/index.ts +3 -24
- package/lib/project-files/src/index.ts +0 -1
- package/lib/project-files-auth/.eslintignore +1 -0
- package/lib/project-files-auth/README.md +3 -11
- package/lib/project-files-auth/build.ts +2 -2
- package/lib/project-files-auth/dotenv.config.js +16 -0
- package/lib/project-files-auth/nodemon.json +10 -0
- package/lib/project-files-auth/nodemon.spec.json +6 -0
- package/lib/project-files-auth/package.json +8 -16
- package/lib/project-files-auth/spec/index.ts +3 -24
- package/lib/project-files-auth/src/index.ts +0 -1
- package/package.json +1 -1
- package/lib/project-files/spec/nodemon.json +0 -6
- package/lib/project-files/src/pre-start.ts +0 -37
- package/lib/project-files-auth/src/pre-start.ts +0 -37
|
@@ -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
|
|
@@ -5,22 +5,18 @@ This project was created with [express-generator-typescript](https://github.com/
|
|
|
5
5
|
|
|
6
6
|
## Available Scripts
|
|
7
7
|
|
|
8
|
-
### `npm run dev`
|
|
8
|
+
### `npm run dev` or `npm run dev:hot` (hot reloading)
|
|
9
9
|
|
|
10
10
|
Run the server in development mode.
|
|
11
11
|
|
|
12
|
-
### `npm test`
|
|
12
|
+
### `npm test` or `npm run test:hot` (hot reloading)
|
|
13
13
|
|
|
14
|
-
Run all unit-tests
|
|
14
|
+
Run all unit-tests.
|
|
15
15
|
|
|
16
16
|
### `npm test -- --testFile="name of test file" (i.e. --testFile=Users).`
|
|
17
17
|
|
|
18
18
|
Run a single unit-test.
|
|
19
19
|
|
|
20
|
-
### `npm run test:no-reloading`
|
|
21
|
-
|
|
22
|
-
Run all unit-tests without hot-reloading.
|
|
23
|
-
|
|
24
20
|
### `npm run lint`
|
|
25
21
|
|
|
26
22
|
Check for linting errors.
|
|
@@ -33,10 +29,6 @@ Build the project for production.
|
|
|
33
29
|
|
|
34
30
|
Run the production build (Must be built first).
|
|
35
31
|
|
|
36
|
-
### `npm start -- --env="name of env file" (default is production).`
|
|
37
|
-
|
|
38
|
-
Run production build with a different env file.
|
|
39
|
-
|
|
40
32
|
|
|
41
33
|
## Additional Notes
|
|
42
34
|
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -2,23 +2,15 @@
|
|
|
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",
|
|
5
6
|
"build": "npx ts-node build.ts",
|
|
7
|
+
"dev": "npm run _ts -- ./src",
|
|
8
|
+
"dev:hot": "nodemon",
|
|
6
9
|
"lint": "npx eslint --ext .ts src/",
|
|
7
10
|
"lint:tests": "npx eslint --ext .ts spec/",
|
|
8
|
-
"start": "node -r module-alias/register ./dist
|
|
9
|
-
"
|
|
10
|
-
"test": "nodemon --config ./
|
|
11
|
-
"test:no-reloading": "npx ts-node --files -r tsconfig-paths/register ./spec"
|
|
12
|
-
},
|
|
13
|
-
"nodemonConfig": {
|
|
14
|
-
"watch": [
|
|
15
|
-
"src"
|
|
16
|
-
],
|
|
17
|
-
"ext": "ts, html",
|
|
18
|
-
"ignore": [
|
|
19
|
-
"src/public"
|
|
20
|
-
],
|
|
21
|
-
"exec": "./node_modules/.bin/ts-node --files -r tsconfig-paths/register ./src"
|
|
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"
|
|
22
14
|
},
|
|
23
15
|
"_moduleAliases": {
|
|
24
16
|
"@src": "dist"
|
|
@@ -40,8 +32,7 @@
|
|
|
40
32
|
"jsonwebtoken": "^8.5.1",
|
|
41
33
|
"module-alias": "^2.2.2",
|
|
42
34
|
"moment": "^2.30.1",
|
|
43
|
-
"morgan": "^1.10.0"
|
|
44
|
-
"ts-command-line-args": "^2.4.2"
|
|
35
|
+
"morgan": "^1.10.0"
|
|
45
36
|
},
|
|
46
37
|
"devDependencies": {
|
|
47
38
|
"@types/bcrypt": "^5.0.0",
|
|
@@ -64,6 +55,7 @@
|
|
|
64
55
|
"jasmine": "^4.3.0",
|
|
65
56
|
"nodemon": "^2.0.19",
|
|
66
57
|
"supertest": "^6.3.4",
|
|
58
|
+
"ts-command-line-args": "^2.4.2",
|
|
67
59
|
"ts-node": "^10.9.1",
|
|
68
60
|
"tsconfig-paths": "^4.1.0",
|
|
69
61
|
"typescript": "^4.8.2"
|
|
@@ -1,40 +1,19 @@
|
|
|
1
|
-
import dotenv from 'dotenv';
|
|
2
1
|
import find from 'find';
|
|
3
2
|
import Jasmine from 'jasmine';
|
|
4
3
|
import { parse } from 'ts-command-line-args';
|
|
5
4
|
import logger from 'jet-logger';
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
// **** Types **** //
|
|
9
|
-
|
|
10
|
-
interface IArgs {
|
|
11
|
-
testFile: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// **** Setup **** //
|
|
16
|
-
|
|
17
|
-
// ** Init ** //
|
|
18
|
-
|
|
19
|
-
// NOTE: MUST BE FIRST!! Load env vars
|
|
20
|
-
const result2 = dotenv.config({
|
|
21
|
-
path: './env/test.env',
|
|
22
|
-
});
|
|
23
|
-
if (result2.error) {
|
|
24
|
-
throw result2.error;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
7
|
// Setup command line options.
|
|
28
|
-
const args = parse<
|
|
8
|
+
const args = parse<{
|
|
9
|
+
testFile: string;
|
|
10
|
+
}>({
|
|
29
11
|
testFile: {
|
|
30
12
|
type: String,
|
|
31
13
|
defaultValue: '',
|
|
32
14
|
},
|
|
33
15
|
});
|
|
34
16
|
|
|
35
|
-
|
|
36
|
-
// ** Start Jasmine ** //
|
|
37
|
-
|
|
38
17
|
// Init Jasmine
|
|
39
18
|
const jasmine = new Jasmine();
|
|
40
19
|
jasmine.exitOnCompletion = false;
|
|
@@ -5,22 +5,18 @@ This project was created with [express-generator-typescript](https://github.com/
|
|
|
5
5
|
|
|
6
6
|
## Available Scripts
|
|
7
7
|
|
|
8
|
-
### `npm run dev`
|
|
8
|
+
### `npm run dev` or `npm run dev:hot` (hot reloading)
|
|
9
9
|
|
|
10
10
|
Run the server in development mode.
|
|
11
11
|
|
|
12
|
-
### `npm test`
|
|
12
|
+
### `npm test` or `npm run test:hot` (hot reloading)
|
|
13
13
|
|
|
14
|
-
Run all unit-tests
|
|
14
|
+
Run all unit-tests.
|
|
15
15
|
|
|
16
16
|
### `npm test -- --testFile="name of test file" (i.e. --testFile=Users).`
|
|
17
17
|
|
|
18
18
|
Run a single unit-test.
|
|
19
19
|
|
|
20
|
-
### `npm run test:no-reloading`
|
|
21
|
-
|
|
22
|
-
Run all unit-tests without hot-reloading.
|
|
23
|
-
|
|
24
20
|
### `npm run lint`
|
|
25
21
|
|
|
26
22
|
Check for linting errors.
|
|
@@ -33,10 +29,6 @@ Build the project for production.
|
|
|
33
29
|
|
|
34
30
|
Run the production build (Must be built first).
|
|
35
31
|
|
|
36
|
-
### `npm start -- --env="name of env file" (default is production).`
|
|
37
|
-
|
|
38
|
-
Run production build with a different env file.
|
|
39
|
-
|
|
40
32
|
|
|
41
33
|
## Additional Notes
|
|
42
34
|
|
|
@@ -14,11 +14,11 @@ import childProcess from 'child_process';
|
|
|
14
14
|
try {
|
|
15
15
|
// Remove current build
|
|
16
16
|
await remove('./dist/');
|
|
17
|
+
// Copy back-end files
|
|
18
|
+
await exec('tsc --build tsconfig.prod.json', './');
|
|
17
19
|
// Copy front-end files
|
|
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);
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -2,23 +2,15 @@
|
|
|
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",
|
|
5
6
|
"build": "npx ts-node build.ts",
|
|
7
|
+
"dev": "npm run _ts -- ./src",
|
|
8
|
+
"dev:hot": "nodemon",
|
|
6
9
|
"lint": "npx eslint --ext .ts src/",
|
|
7
10
|
"lint:tests": "npx eslint --ext .ts spec/",
|
|
8
|
-
"start": "node -r module-alias/register ./dist
|
|
9
|
-
"
|
|
10
|
-
"test": "nodemon --config ./
|
|
11
|
-
"test:no-reloading": "npx ts-node --files -r tsconfig-paths/register ./spec"
|
|
12
|
-
},
|
|
13
|
-
"nodemonConfig": {
|
|
14
|
-
"watch": [
|
|
15
|
-
"src"
|
|
16
|
-
],
|
|
17
|
-
"ext": "ts, html",
|
|
18
|
-
"ignore": [
|
|
19
|
-
"src/public"
|
|
20
|
-
],
|
|
21
|
-
"exec": "./node_modules/.bin/ts-node --files -r tsconfig-paths/register ./src"
|
|
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"
|
|
22
14
|
},
|
|
23
15
|
"_moduleAliases": {
|
|
24
16
|
"@src": "dist"
|
|
@@ -40,8 +32,7 @@
|
|
|
40
32
|
"jsonwebtoken": "^8.5.1",
|
|
41
33
|
"module-alias": "^2.2.2",
|
|
42
34
|
"moment": "^2.30.1",
|
|
43
|
-
"morgan": "^1.10.0"
|
|
44
|
-
"ts-command-line-args": "^2.4.2"
|
|
35
|
+
"morgan": "^1.10.0"
|
|
45
36
|
},
|
|
46
37
|
"devDependencies": {
|
|
47
38
|
"@types/bcrypt": "^5.0.0",
|
|
@@ -64,6 +55,7 @@
|
|
|
64
55
|
"jasmine": "^4.3.0",
|
|
65
56
|
"nodemon": "^2.0.19",
|
|
66
57
|
"supertest": "^6.3.4",
|
|
58
|
+
"ts-command-line-args": "^2.4.2",
|
|
67
59
|
"ts-node": "^10.9.1",
|
|
68
60
|
"tsconfig-paths": "^4.1.0",
|
|
69
61
|
"typescript": "^4.8.2"
|
|
@@ -1,40 +1,19 @@
|
|
|
1
|
-
import dotenv from 'dotenv';
|
|
2
1
|
import find from 'find';
|
|
3
2
|
import Jasmine from 'jasmine';
|
|
4
3
|
import { parse } from 'ts-command-line-args';
|
|
5
4
|
import logger from 'jet-logger';
|
|
6
5
|
|
|
7
6
|
|
|
8
|
-
// **** Types **** //
|
|
9
|
-
|
|
10
|
-
interface IArgs {
|
|
11
|
-
testFile: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// **** Setup **** //
|
|
16
|
-
|
|
17
|
-
// ** Init ** //
|
|
18
|
-
|
|
19
|
-
// NOTE: MUST BE FIRST!! Load env vars
|
|
20
|
-
const result2 = dotenv.config({
|
|
21
|
-
path: './env/test.env',
|
|
22
|
-
});
|
|
23
|
-
if (result2.error) {
|
|
24
|
-
throw result2.error;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
7
|
// Setup command line options.
|
|
28
|
-
const args = parse<
|
|
8
|
+
const args = parse<{
|
|
9
|
+
testFile: string;
|
|
10
|
+
}>({
|
|
29
11
|
testFile: {
|
|
30
12
|
type: String,
|
|
31
13
|
defaultValue: '',
|
|
32
14
|
},
|
|
33
15
|
});
|
|
34
16
|
|
|
35
|
-
|
|
36
|
-
// ** Start Jasmine ** //
|
|
37
|
-
|
|
38
17
|
// Init Jasmine
|
|
39
18
|
const jasmine = new Jasmine();
|
|
40
19
|
jasmine.exitOnCompletion = false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.18",
|
|
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,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pre-start is where we want to place things that must run BEFORE the express
|
|
3
|
-
* server is started. This is useful for environment variables, command-line
|
|
4
|
-
* arguments, and cron-jobs.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// NOTE: DO NOT IMPORT ANY SOURCE CODE HERE
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import dotenv from 'dotenv';
|
|
10
|
-
import { parse } from 'ts-command-line-args';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// **** Types **** //
|
|
14
|
-
|
|
15
|
-
interface IArgs {
|
|
16
|
-
env: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// **** Setup **** //
|
|
21
|
-
|
|
22
|
-
// Command line arguments
|
|
23
|
-
const args = parse<IArgs>({
|
|
24
|
-
env: {
|
|
25
|
-
type: String,
|
|
26
|
-
defaultValue: 'development',
|
|
27
|
-
alias: 'e',
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Set the env file
|
|
32
|
-
const result2 = dotenv.config({
|
|
33
|
-
path: path.join(__dirname, `../env/${args.env}.env`),
|
|
34
|
-
});
|
|
35
|
-
if (result2.error) {
|
|
36
|
-
throw result2.error;
|
|
37
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pre-start is where we want to place things that must run BEFORE the express
|
|
3
|
-
* server is started. This is useful for environment variables, command-line
|
|
4
|
-
* arguments, and cron-jobs.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// NOTE: DO NOT IMPORT ANY SOURCE CODE HERE
|
|
8
|
-
import path from 'path';
|
|
9
|
-
import dotenv from 'dotenv';
|
|
10
|
-
import { parse } from 'ts-command-line-args';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// **** Types **** //
|
|
14
|
-
|
|
15
|
-
interface IArgs {
|
|
16
|
-
env: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// **** Setup **** //
|
|
21
|
-
|
|
22
|
-
// Command line arguments
|
|
23
|
-
const args = parse<IArgs>({
|
|
24
|
-
env: {
|
|
25
|
-
type: String,
|
|
26
|
-
defaultValue: 'development',
|
|
27
|
-
alias: 'e',
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Set the env file
|
|
32
|
-
const result2 = dotenv.config({
|
|
33
|
-
path: path.join(__dirname, `../env/${args.env}.env`),
|
|
34
|
-
});
|
|
35
|
-
if (result2.error) {
|
|
36
|
-
throw result2.error;
|
|
37
|
-
}
|