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.
- package/lib/project-files/build.ts +0 -2
- package/lib/project-files/{src/pre-start/env → env}/development.env +1 -1
- package/lib/project-files/{src/pre-start/env → env}/production.env +0 -0
- package/lib/project-files/{src/pre-start/env → env}/test.env +0 -0
- package/lib/project-files/package.json +1 -1
- package/lib/project-files/src/{pre-start/index.ts → pre-start.ts} +6 -3
- package/lib/project-files/src/repos/mock-orm.ts +4 -3
- package/lib/project-files/src/routes/auth-routes.ts +1 -1
- package/lib/project-files/src/routes/middleware.ts +2 -2
- package/package.json +1 -1
|
@@ -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) {
|
|
File without changes
|
|
File without changes
|
|
@@ -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
|
-
|
|
23
|
+
|
|
24
|
+
// **** Set the env file **** //
|
|
25
|
+
|
|
23
26
|
const result2 = dotenv.config({
|
|
24
|
-
path: path.join(__dirname,
|
|
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
|
|
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(
|
|
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(
|
|
33
|
+
return jsonfile.writeFile((__dirname + '/' + dbFileName), db);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
|
|
@@ -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 '
|
|
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
|
|
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.
|
|
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",
|