express-generator-typescript 2.1.7 → 2.1.9
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.
|
@@ -5,10 +5,7 @@ import envVars from '@shared/env-vars';
|
|
|
5
5
|
import server from './server';
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
//
|
|
9
|
-
const serverStartMsg = 'Express server started on port: ';
|
|
8
|
+
// **** Start server **** //
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
server.listen(envVars.port, () =>
|
|
13
|
-
logger.info(serverStartMsg + envVars.port.toString());
|
|
14
|
-
});
|
|
10
|
+
const msg = ('Express server started on port: ' + envVars.port.toString());
|
|
11
|
+
server.listen(envVars.port, () => logger.info(msg));
|
|
@@ -8,6 +8,9 @@ import path from 'path';
|
|
|
8
8
|
import dotenv from 'dotenv';
|
|
9
9
|
import commandLineArgs from 'command-line-args';
|
|
10
10
|
|
|
11
|
+
// **NOTE** Do not import any local paths here, or any libraries dependent
|
|
12
|
+
// on environment variables.
|
|
13
|
+
|
|
11
14
|
|
|
12
15
|
// **** Setup command line options **** //
|
|
13
16
|
|
|
@@ -127,7 +127,7 @@ export function validate(...params: Array<string | TParamArr>): RequestHandler {
|
|
|
127
127
|
reqObjProp !== 'params' &&
|
|
128
128
|
reqObjProp !== 'query'
|
|
129
129
|
) {
|
|
130
|
-
throw Error('param[
|
|
130
|
+
throw Error('param[2] must be "body", "query", or "params"');
|
|
131
131
|
}
|
|
132
132
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
133
133
|
const toValidate = req[reqObjProp][paramName] as TAll;
|
|
@@ -9,8 +9,10 @@ import 'express-async-errors';
|
|
|
9
9
|
|
|
10
10
|
import BaseRouter from './routes/api';
|
|
11
11
|
import logger from 'jet-logger';
|
|
12
|
-
import { CustomError } from '@shared/errors';
|
|
13
12
|
import envVars from '@shared/env-vars';
|
|
13
|
+
import { CustomError } from '@shared/errors';
|
|
14
|
+
|
|
15
|
+
import { NodeEnvs } from '@shared/enums';
|
|
14
16
|
|
|
15
17
|
|
|
16
18
|
// **** Init express **** //
|
|
@@ -25,12 +27,12 @@ app.use(express.urlencoded({extended: true}));
|
|
|
25
27
|
app.use(cookieParser(envVars.cookieProps.secret));
|
|
26
28
|
|
|
27
29
|
// Show routes called in console during development
|
|
28
|
-
if (envVars.nodeEnv ===
|
|
30
|
+
if (envVars.nodeEnv === NodeEnvs.Dev) {
|
|
29
31
|
app.use(morgan('dev'));
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
// Security
|
|
33
|
-
if (envVars.nodeEnv ===
|
|
35
|
+
if (envVars.nodeEnv === NodeEnvs.Production) {
|
|
34
36
|
app.use(helmet());
|
|
35
37
|
}
|
|
36
38
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.9",
|
|
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",
|