express-generator-typescript 2.4.22 → 2.4.25

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.
@@ -1,17 +1,21 @@
1
- /* eslint-disable */
2
- // @ts-nocheck
1
+ import eslint from '@eslint/js';
2
+ import tseslint from 'typescript-eslint';
3
+ import stylisticTs from '@stylistic/eslint-plugin-ts';
4
+ import nodePlugin from 'eslint-plugin-n';
3
5
 
4
- const eslint = require('@eslint/js');
5
- const tseslint = require('typescript-eslint');
6
- const stylisticTs = require('@stylistic/eslint-plugin-ts');
7
- const nodePlugin = require('eslint-plugin-n');
8
6
 
9
-
10
- module.exports = tseslint.config(
7
+ export default tseslint.config(
11
8
  eslint.configs.recommended,
12
9
  nodePlugin.configs['flat/recommended-script'],
13
10
  ...tseslint.configs.strictTypeChecked,
14
11
  ...tseslint.configs.stylisticTypeChecked,
12
+ {
13
+ ignores: [
14
+ '**/node_modules/*',
15
+ '**/*.mjs',
16
+ '**/*.js',
17
+ ],
18
+ },
15
19
  {
16
20
  languageOptions: {
17
21
  parserOptions: {
@@ -25,9 +29,8 @@ module.exports = tseslint.config(
25
29
  '@stylistic/ts': stylisticTs,
26
30
  }
27
31
  },
32
+ { files: ['**/*.ts'] },
28
33
  {
29
- files: ['**/*.ts'],
30
- ignores: ['**/*.js'],
31
34
  rules: {
32
35
  '@typescript-eslint/explicit-member-accessibility': 'warn',
33
36
  '@typescript-eslint/no-misused-promises': 0,
@@ -51,5 +54,5 @@ module.exports = tseslint.config(
51
54
  'n/no-missing-import': 0,
52
55
  'n/no-unpublished-import': 0
53
56
  },
54
- }
57
+ },
55
58
  )
@@ -5,8 +5,8 @@
5
5
  "build": "npx ts-node ./scripts/build.ts",
6
6
  "dev": "NODE_ENV=development npx ts-node ./src",
7
7
  "dev:hot": "nodemon --exec \"npm run dev\" --watch ./src -e ts",
8
- "lint": "npx eslint ./src/**/*.ts",
9
- "lint:tests": "npx eslint ./spec/**/*.ts",
8
+ "lint": "npx eslint ./src",
9
+ "lint:tests": "npx eslint ./spec",
10
10
  "start": "NODE_ENV=production node -r ./preload.js ./dist",
11
11
  "test": "NODE_ENV=test npx ts-node ./spec",
12
12
  "test:hot": "nodemon --exec \"npm run test\" --watch ./src --watch ./spec -e ts"
@@ -13,7 +13,7 @@ import check from './common/check';
13
13
  */
14
14
  async function getAll(_: IReq, res: IRes) {
15
15
  const users = await UserService.getAll();
16
- return res.status(HttpStatusCodes.OK).json({ users });
16
+ res.status(HttpStatusCodes.OK).json({ users });
17
17
  }
18
18
 
19
19
  /**
@@ -22,7 +22,7 @@ async function getAll(_: IReq, res: IRes) {
22
22
  async function add(req: IReq, res: IRes) {
23
23
  const user = check.isValid(req.body, 'user', User.isUser);
24
24
  await UserService.addOne(user);
25
- return res.status(HttpStatusCodes.CREATED).end();
25
+ res.status(HttpStatusCodes.CREATED).end();
26
26
  }
27
27
 
28
28
  /**
@@ -31,7 +31,7 @@ async function add(req: IReq, res: IRes) {
31
31
  async function update(req: IReq, res: IRes) {
32
32
  const user = check.isValid(req.body, 'user', User.isUser);
33
33
  await UserService.updateOne(user);
34
- return res.status(HttpStatusCodes.OK).end();
34
+ res.status(HttpStatusCodes.OK).end();
35
35
  }
36
36
 
37
37
  /**
@@ -40,7 +40,7 @@ async function update(req: IReq, res: IRes) {
40
40
  async function delete_(req: IReq, res: IRes) {
41
41
  const id = check.isNum(req.params, 'id');
42
42
  await UserService.delete(id);
43
- return res.status(HttpStatusCodes.OK).end();
43
+ res.status(HttpStatusCodes.OK).end();
44
44
  }
45
45
 
46
46
 
@@ -42,21 +42,16 @@ if (EnvVars.NodeEnv === NodeEnvs.Production.valueOf()) {
42
42
  app.use(Paths.Base, BaseRouter);
43
43
 
44
44
  // Add error handler
45
- app.use((
46
- err: Error,
47
- _: Request,
48
- res: Response,
49
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
50
- next: NextFunction,
51
- ) => {
45
+ app.use((err: Error, _: Request, res: Response, next: NextFunction) => {
52
46
  if (EnvVars.NodeEnv !== NodeEnvs.Test.valueOf()) {
53
47
  logger.err(err, true);
54
48
  }
55
49
  let status = HttpStatusCodes.BAD_REQUEST;
56
50
  if (err instanceof RouteError) {
57
51
  status = err.status;
52
+ res.status(status).json({ error: err.message });
58
53
  }
59
- return res.status(status).json({ error: err.message });
54
+ return next(err);
60
55
  });
61
56
 
62
57
 
@@ -79,7 +79,6 @@
79
79
  "src/**/*.ts",
80
80
  "spec/**/*.ts",
81
81
  "scripts",
82
- "eslint.config.js",
83
82
  "preload.js"
84
83
  ],
85
84
  "exclude": [
@@ -1,17 +1,21 @@
1
- /* eslint-disable */
2
- // @ts-nocheck
1
+ import eslint from '@eslint/js';
2
+ import tseslint from 'typescript-eslint';
3
+ import stylisticTs from '@stylistic/eslint-plugin-ts';
4
+ import nodePlugin from 'eslint-plugin-n';
3
5
 
4
- const eslint = require('@eslint/js');
5
- const tseslint = require('typescript-eslint');
6
- const stylisticTs = require('@stylistic/eslint-plugin-ts');
7
- const nodePlugin = require('eslint-plugin-n');
8
6
 
9
-
10
- module.exports = tseslint.config(
7
+ export default tseslint.config(
11
8
  eslint.configs.recommended,
12
9
  nodePlugin.configs['flat/recommended-script'],
13
10
  ...tseslint.configs.strictTypeChecked,
14
11
  ...tseslint.configs.stylisticTypeChecked,
12
+ {
13
+ ignores: [
14
+ '**/node_modules/*',
15
+ '**/*.mjs',
16
+ '**/*.js',
17
+ ],
18
+ },
15
19
  {
16
20
  languageOptions: {
17
21
  parserOptions: {
@@ -25,9 +29,8 @@ module.exports = tseslint.config(
25
29
  '@stylistic/ts': stylisticTs,
26
30
  }
27
31
  },
32
+ { files: ['**/*.ts'] },
28
33
  {
29
- files: ['**/*.ts'],
30
- ignores: ['**/*.js'],
31
34
  rules: {
32
35
  '@typescript-eslint/explicit-member-accessibility': 'warn',
33
36
  '@typescript-eslint/no-misused-promises': 0,
@@ -51,5 +54,5 @@ module.exports = tseslint.config(
51
54
  'n/no-missing-import': 0,
52
55
  'n/no-unpublished-import': 0
53
56
  },
54
- }
55
- )
57
+ },
58
+ )
@@ -5,8 +5,8 @@
5
5
  "build": "npx ts-node ./scripts/build.ts",
6
6
  "dev": "NODE_ENV=development npx ts-node ./src",
7
7
  "dev:hot": "nodemon --exec \"npm run dev\" --watch ./src -e ts",
8
- "lint": "npx eslint ./src/**/*.ts",
9
- "lint:tests": "npx eslint ./spec/**/*.ts",
8
+ "lint": "npx eslint ./src",
9
+ "lint:tests": "npx eslint ./spec",
10
10
  "start": "NODE_ENV=production node -r ./preload.js ./dist",
11
11
  "test": "NODE_ENV=test npx ts-node ./spec",
12
12
  "test:hot": "nodemon --exec \"npm run test\" --watch ./src --watch ./spec -e ts"
@@ -22,7 +22,7 @@ async function login(req: IReq, res: IRes) {
22
22
  role: user.role,
23
23
  });
24
24
  // Return
25
- return res.status(HttpStatusCodes.OK).end();
25
+ res.status(HttpStatusCodes.OK).end();
26
26
  }
27
27
 
28
28
  /**
@@ -30,7 +30,7 @@ async function login(req: IReq, res: IRes) {
30
30
  */
31
31
  function logout(_: IReq, res: IRes) {
32
32
  SessionUtil.clearCookie(res);
33
- return res.status(HttpStatusCodes.OK).end();
33
+ res.status(HttpStatusCodes.OK).end();
34
34
  }
35
35
 
36
36
 
@@ -14,7 +14,7 @@ import check from './common/check';
14
14
  */
15
15
  async function getAll(_: IReq, res: IRes) {
16
16
  const users = await UserService.getAll();
17
- return res.status(HttpStatusCodes.OK).json({ users });
17
+ res.status(HttpStatusCodes.OK).json({ users });
18
18
  }
19
19
 
20
20
  /**
@@ -23,7 +23,7 @@ async function getAll(_: IReq, res: IRes) {
23
23
  async function add(req: IReq, res: IRes) {
24
24
  const user = check.isValid(req.body, 'user', User.isUser);
25
25
  await UserService.addOne(user);
26
- return res.status(HttpStatusCodes.CREATED).end();
26
+ res.status(HttpStatusCodes.CREATED).end();
27
27
  }
28
28
 
29
29
  /**
@@ -32,7 +32,7 @@ async function add(req: IReq, res: IRes) {
32
32
  async function update(req: IReq, res: IRes) {
33
33
  const user = check.isValid(req.body, 'user', User.isUser);
34
34
  await UserService.updateOne(user);
35
- return res.status(HttpStatusCodes.OK).end();
35
+ res.status(HttpStatusCodes.OK).end();
36
36
  }
37
37
 
38
38
  /**
@@ -41,7 +41,7 @@ async function update(req: IReq, res: IRes) {
41
41
  async function delete_(req: IReq, res: IRes) {
42
42
  const id = check.isNum(req.params, 'id');
43
43
  await UserService.delete(id);
44
- return res.status(HttpStatusCodes.OK).end();
44
+ res.status(HttpStatusCodes.OK).end();
45
45
  }
46
46
 
47
47
 
@@ -1,7 +1,3 @@
1
- /**
2
- * Middleware to verify user logged in and is an an admin.
3
- */
4
-
5
1
  import { NextFunction } from 'express';
6
2
  import { JwtPayload } from 'jsonwebtoken';
7
3
 
@@ -38,9 +34,10 @@ async function adminMw(
38
34
  return next();
39
35
  // Return an unauth error if user is not an admin
40
36
  } else {
41
- return res
37
+ res
42
38
  .status(HttpStatusCodes.UNAUTHORIZED)
43
39
  .json({ error: USER_UNAUTHORIZED_ERR });
40
+ return;
44
41
  }
45
42
  }
46
43
 
@@ -47,21 +47,16 @@ if (EnvVars.NodeEnv === NodeEnvs.Production.valueOf()) {
47
47
  app.use(Paths.Base, BaseRouter);
48
48
 
49
49
  // Add error handler
50
- app.use((
51
- err: Error,
52
- _: Request,
53
- res: Response,
54
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
55
- next: NextFunction,
56
- ) => {
50
+ app.use((err: Error, _: Request, res: Response, next: NextFunction) => {
57
51
  if (EnvVars.NodeEnv !== NodeEnvs.Test.valueOf()) {
58
52
  logger.err(err, true);
59
53
  }
60
54
  let status = HttpStatusCodes.BAD_REQUEST;
61
55
  if (err instanceof RouteError) {
62
56
  status = err.status;
57
+ res.status(status).json({ error: err.message });
63
58
  }
64
- return res.status(status).json({ error: err.message });
59
+ return next(err);
65
60
  });
66
61
 
67
62
 
@@ -79,7 +79,6 @@
79
79
  "src/**/*.ts",
80
80
  "spec/**/*.ts",
81
81
  "scripts",
82
- "eslint.config.js",
83
82
  "preload.js"
84
83
  ],
85
84
  "exclude": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-generator-typescript",
3
- "version": "2.4.22",
3
+ "version": "2.4.25",
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",