express-generator-typescript 2.1.5 → 2.1.7

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.
@@ -15,8 +15,6 @@ import childProcess from 'child_process';
15
15
  // Copy front-end files
16
16
  await copy('./src/public', './dist/public');
17
17
  await copy('./src/views', './dist/views');
18
- // Copy production env file
19
- await copy('./src/pre-start/env/production.env', './dist/pre-start/env/production.env');
20
18
  // Copy back-end files
21
19
  await exec('tsc --build tsconfig.prod.json', './');
22
20
  } catch (err) {
@@ -3,7 +3,7 @@ NODE_ENV=development
3
3
 
4
4
 
5
5
  ## Server ##
6
- PORT=3001
6
+ PORT=3000
7
7
  HOST=localhost
8
8
 
9
9
 
@@ -23,7 +23,7 @@
23
23
  "_moduleAliases": {
24
24
  "@services": "dist/services",
25
25
  "@repos": "dist/repos",
26
- "@entities": "dist/entities",
26
+ "@models": "dist/models",
27
27
  "@shared": "dist/shared",
28
28
  "@server": "dist/server",
29
29
  "@routes": "dist/routes",
@@ -9,7 +9,8 @@ import dotenv from 'dotenv';
9
9
  import commandLineArgs from 'command-line-args';
10
10
 
11
11
 
12
- // Setup command line options
12
+ // **** Setup command line options **** //
13
+
13
14
  const options = commandLineArgs([
14
15
  {
15
16
  name: 'env',
@@ -19,9 +20,11 @@ const options = commandLineArgs([
19
20
  },
20
21
  ]);
21
22
 
22
- // Set the env file
23
+
24
+ // **** Set the env file **** //
25
+
23
26
  const result2 = dotenv.config({
24
- path: path.join(__dirname, `env/${String(options.env)}.env`),
27
+ path: path.join(__dirname, `../env/${String(options.env)}.env`),
25
28
  });
26
29
 
27
30
  if (result2.error) {
@@ -1,12 +1,13 @@
1
1
  /* eslint-disable @typescript-eslint/no-unsafe-return */
2
2
 
3
3
  import jsonfile from 'jsonfile';
4
+
4
5
  import { IUser } from '@models/user-model';
5
6
 
6
7
 
7
8
  // **** Variables **** //
8
9
 
9
- const dbFilePath = 'src/repos/database.json';
10
+ const dbFileName = 'database.json';
10
11
 
11
12
 
12
13
  // **** Types **** //
@@ -22,14 +23,14 @@ interface IDb {
22
23
  * Fetch the json from the file.
23
24
  */
24
25
  function openDb(): Promise<IDb> {
25
- return jsonfile.readFile(dbFilePath);
26
+ return jsonfile.readFile(__dirname + '/' + dbFileName);
26
27
  }
27
28
 
28
29
  /**
29
30
  * Update the file.
30
31
  */
31
32
  function saveDb(db: IDb): Promise<void> {
32
- return jsonfile.writeFile(dbFilePath, db);
33
+ return jsonfile.writeFile((__dirname + '/' + dbFileName), db);
33
34
  }
34
35
 
35
36
 
@@ -1,7 +1,7 @@
1
1
  import StatusCodes from 'http-status-codes';
2
2
 
3
3
  import authService from '@services/auth-service';
4
- import envVars from 'src/shared/env-vars';
4
+ import envVars from '@shared/env-vars';
5
5
  import { IReq, IRes } from '@shared/types';
6
6
 
7
7
 
@@ -2,7 +2,7 @@ import StatusCodes from 'http-status-codes';
2
2
  import { Request, Response, NextFunction, RequestHandler } from 'express';
3
3
  import { JwtPayload } from 'jsonwebtoken';
4
4
 
5
- import envVars from 'src/shared/env-vars';
5
+ import envVars from '@shared/env-vars';
6
6
  import jwtUtil from '@util/jwt-util';
7
7
  import { IUser, UserRoles } from '@models/user-model';
8
8
  import { ParamInvalidError, ValidatorFnError } from '@shared/errors';
@@ -35,7 +35,7 @@ export interface ISessionUser extends JwtPayload {
35
35
  // **** Functions **** //
36
36
 
37
37
  /**
38
- * Middleware to verify if user logged in.
38
+ * Middleware to verify user logged in and is an an admin.
39
39
  */
40
40
  export async function adminMw(
41
41
  req: Request,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-generator-typescript",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
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",