express-generator-typescript 1.8.8 → 1.9.1
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/README.md +1 -1
- package/lib/auth-proj/.eslintignore +1 -0
- package/lib/auth-proj/.eslintrc.json +35 -0
- package/lib/auth-proj/package.json +1 -35
- package/lib/auth-proj/src/index.ts +5 -5
- package/lib/auth-proj/src/public/scripts/users.js +22 -13
- package/lib/auth-proj/src/routes/user-router.ts +1 -1
- package/lib/auth-proj/src/shared/env-vars.ts +6 -6
- package/lib/express-generator-typescript.js +2 -2
- package/lib/project-files/.eslintignore +1 -0
- package/lib/project-files/.eslintrc.json +35 -0
- package/lib/project-files/package.json +1 -35
- package/lib/project-files/src/index.ts +5 -4
- package/lib/project-files/src/public/scripts/index.js +22 -12
- package/lib/project-files/src/routes/user-router.ts +1 -1
- package/lib/project-files/src/server.ts +5 -4
- package/lib/project-files/src/shared/env-vars.ts +4 -0
- package/lib/socket-io/.eslintignore +1 -0
- package/lib/socket-io/.eslintrc.json +35 -0
- package/lib/socket-io/package.json +1 -75
- package/lib/socket-io/src/index.ts +5 -4
- package/lib/socket-io/src/public/scripts/users.js +23 -16
- package/lib/socket-io/src/routes/auth-router.ts +1 -1
- package/lib/socket-io/src/routes/chat-router.ts +1 -1
- package/lib/socket-io/src/routes/user-router.ts +1 -1
- package/lib/socket-io/src/shared/env-vars.ts +6 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -88,7 +88,7 @@ $ cd "project name" && npm run start:dev
|
|
|
88
88
|
|
|
89
89
|
## Available commands for the server.
|
|
90
90
|
|
|
91
|
-
- Run the server in development mode: `npm run
|
|
91
|
+
- Run the server in development mode: `npm run dev`.
|
|
92
92
|
- Run all unit-tests with hot-reloading: `npm test`.
|
|
93
93
|
- Run a single unit-test: `npm test -- --testFile="name of test file" (i.e. --testFile=Users)`.
|
|
94
94
|
- Run all unit-tests without hot-reloading: `npm run test:no-reloading`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src/public/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parser": "@typescript-eslint/parser",
|
|
3
|
+
"plugins": [
|
|
4
|
+
"@typescript-eslint"
|
|
5
|
+
],
|
|
6
|
+
"extends": [
|
|
7
|
+
"eslint:recommended",
|
|
8
|
+
"plugin:@typescript-eslint/recommended",
|
|
9
|
+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
|
10
|
+
],
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"project": "./tsconfig.json"
|
|
13
|
+
},
|
|
14
|
+
"rules": {
|
|
15
|
+
"max-len": [
|
|
16
|
+
"error",
|
|
17
|
+
{
|
|
18
|
+
"code": 100
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"no-console": 1,
|
|
22
|
+
"no-extra-boolean-cast": 0,
|
|
23
|
+
"semi": 1,
|
|
24
|
+
"@typescript-eslint/restrict-plus-operands": 0,
|
|
25
|
+
"@typescript-eslint/explicit-module-boundary-types": 0,
|
|
26
|
+
"@typescript-eslint/no-explicit-any": 0,
|
|
27
|
+
"@typescript-eslint/no-floating-promises": 0,
|
|
28
|
+
"@typescript-eslint/no-unsafe-member-access": 0,
|
|
29
|
+
"@typescript-eslint/no-unsafe-assignment": 0,
|
|
30
|
+
"@typescript-eslint/no-misused-promises": 0,
|
|
31
|
+
"@typescript-eslint/no-unsafe-argument": 0,
|
|
32
|
+
"@typescript-eslint/no-unsafe-return": 0,
|
|
33
|
+
"@typescript-eslint/no-unsafe-call": 0
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"build": "npx ts-node build.ts",
|
|
6
6
|
"lint": "eslint . --ext .ts",
|
|
7
7
|
"start": "node -r module-alias/register ./dist --env=production",
|
|
8
|
-
"
|
|
8
|
+
"dev": "nodemon",
|
|
9
9
|
"test": "nodemon --config ./spec/nodemon.json",
|
|
10
10
|
"test:no-reloading": "npx ts-node --files -r tsconfig-paths/register ./spec"
|
|
11
11
|
},
|
|
@@ -28,40 +28,6 @@
|
|
|
28
28
|
"@routes": "dist/routes",
|
|
29
29
|
"@util": "dist/util"
|
|
30
30
|
},
|
|
31
|
-
"eslintConfig": {
|
|
32
|
-
"parser": "@typescript-eslint/parser",
|
|
33
|
-
"plugins": [
|
|
34
|
-
"@typescript-eslint"
|
|
35
|
-
],
|
|
36
|
-
"extends": [
|
|
37
|
-
"eslint:recommended",
|
|
38
|
-
"plugin:@typescript-eslint/recommended",
|
|
39
|
-
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
|
40
|
-
],
|
|
41
|
-
"parserOptions": {
|
|
42
|
-
"project": "./tsconfig.json"
|
|
43
|
-
},
|
|
44
|
-
"rules": {
|
|
45
|
-
"max-len": [
|
|
46
|
-
"error",
|
|
47
|
-
{
|
|
48
|
-
"code": 100
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
"no-console": 1,
|
|
52
|
-
"no-extra-boolean-cast": 0,
|
|
53
|
-
"@typescript-eslint/restrict-plus-operands": 0,
|
|
54
|
-
"@typescript-eslint/explicit-module-boundary-types": 0,
|
|
55
|
-
"@typescript-eslint/no-explicit-any": 0,
|
|
56
|
-
"@typescript-eslint/no-floating-promises": 0,
|
|
57
|
-
"@typescript-eslint/no-unsafe-member-access": 0,
|
|
58
|
-
"@typescript-eslint/no-unsafe-assignment": 0
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"eslintIgnore": [
|
|
62
|
-
"src/public/",
|
|
63
|
-
"build.ts"
|
|
64
|
-
],
|
|
65
31
|
"dependencies": {
|
|
66
32
|
},
|
|
67
33
|
"devDependencies": {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import './pre-start'; // Must be the first import
|
|
2
|
-
import envVars from './shared/env-vars';
|
|
3
2
|
import logger from 'jet-logger';
|
|
3
|
+
|
|
4
|
+
import envVars from '@shared/env-vars';
|
|
4
5
|
import server from './server';
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
// Constants
|
|
8
|
-
const serverStartMsg = 'Express server started on port: '
|
|
9
|
-
port = (envVars.port || 3000);
|
|
9
|
+
const serverStartMsg = 'Express server started on port: ';
|
|
10
10
|
|
|
11
11
|
// Start server
|
|
12
|
-
server.listen(port, () => {
|
|
13
|
-
logger.info(serverStartMsg + port);
|
|
12
|
+
server.listen(envVars.port, () => {
|
|
13
|
+
logger.info(serverStartMsg + envVars.port);
|
|
14
14
|
});
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
+
// ***** Start **** //
|
|
2
|
+
|
|
3
|
+
displayUsers();
|
|
4
|
+
|
|
5
|
+
|
|
1
6
|
// ***** Fetch and display users **** //
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
allUsersAnchor.innerHTML
|
|
8
|
+
/**
|
|
9
|
+
* Call api
|
|
10
|
+
*/
|
|
11
|
+
function displayUsers() {
|
|
12
|
+
Http
|
|
13
|
+
.get('/api/users/all')
|
|
14
|
+
.then(resp => resp.json())
|
|
15
|
+
.then((resp) => {
|
|
16
|
+
var allUsers = resp.users;
|
|
17
|
+
// Empty the anchor
|
|
18
|
+
var allUsersAnchor = document.getElementById('all-users-anchor');
|
|
19
|
+
allUsersAnchor.innerHTML = '';
|
|
20
|
+
// Append users to anchor
|
|
21
|
+
allUsers.forEach((user) => {
|
|
22
|
+
allUsersAnchor.innerHTML += getUserDisplayEle(user);
|
|
23
|
+
});
|
|
15
24
|
});
|
|
16
|
-
|
|
25
|
+
}
|
|
17
26
|
|
|
18
27
|
/**
|
|
19
28
|
* Get user display element
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
nodeEnv: process.env.NODE_ENV ?? '',
|
|
3
|
-
port: process.env.PORT ?? 0,
|
|
2
|
+
nodeEnv: (process.env.NODE_ENV ?? ''),
|
|
3
|
+
port: (process.env.PORT ?? 0),
|
|
4
4
|
cookieProps: {
|
|
5
5
|
key: 'ExpressGeneratorTs',
|
|
6
|
-
secret: process.env.COOKIE_SECRET ?? '',
|
|
6
|
+
secret: (process.env.COOKIE_SECRET ?? ''),
|
|
7
7
|
options: {
|
|
8
8
|
httpOnly: true,
|
|
9
9
|
signed: true,
|
|
@@ -14,7 +14,7 @@ export default {
|
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
jwt: {
|
|
17
|
-
secret: process.env.JWT_SECRET ?? '',
|
|
18
|
-
exp: process.env.COOKIE_EXP ?? '', // exp at the same time as the cookie
|
|
17
|
+
secret: (process.env.JWT_SECRET ?? ''),
|
|
18
|
+
exp: (process.env.COOKIE_EXP ?? ''), // exp at the same time as the cookie
|
|
19
19
|
},
|
|
20
|
-
};
|
|
20
|
+
} as const;
|
|
@@ -10,7 +10,6 @@ const childProcess = require('child_process');
|
|
|
10
10
|
const ncp = require('ncp').ncp;
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
14
13
|
/**
|
|
15
14
|
* Entry point
|
|
16
15
|
*/
|
|
@@ -102,5 +101,6 @@ function downloadNodeModules(destination, depStrings, useYarn) {
|
|
|
102
101
|
}
|
|
103
102
|
|
|
104
103
|
|
|
105
|
-
// Export entry point
|
|
104
|
+
// **** Export entry point **** //
|
|
105
|
+
|
|
106
106
|
module.exports = expressGenTs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src/public/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parser": "@typescript-eslint/parser",
|
|
3
|
+
"plugins": [
|
|
4
|
+
"@typescript-eslint"
|
|
5
|
+
],
|
|
6
|
+
"extends": [
|
|
7
|
+
"eslint:recommended",
|
|
8
|
+
"plugin:@typescript-eslint/recommended",
|
|
9
|
+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
|
10
|
+
],
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"project": "./tsconfig.json"
|
|
13
|
+
},
|
|
14
|
+
"rules": {
|
|
15
|
+
"max-len": [
|
|
16
|
+
"error",
|
|
17
|
+
{
|
|
18
|
+
"code": 100
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"no-console": 1,
|
|
22
|
+
"no-extra-boolean-cast": 0,
|
|
23
|
+
"semi": 1,
|
|
24
|
+
"@typescript-eslint/restrict-plus-operands": 0,
|
|
25
|
+
"@typescript-eslint/explicit-module-boundary-types": 0,
|
|
26
|
+
"@typescript-eslint/no-explicit-any": 0,
|
|
27
|
+
"@typescript-eslint/no-floating-promises": 0,
|
|
28
|
+
"@typescript-eslint/no-unsafe-member-access": 0,
|
|
29
|
+
"@typescript-eslint/no-unsafe-assignment": 0,
|
|
30
|
+
"@typescript-eslint/no-misused-promises": 0,
|
|
31
|
+
"@typescript-eslint/no-unsafe-argument": 0,
|
|
32
|
+
"@typescript-eslint/no-unsafe-return": 0,
|
|
33
|
+
"@typescript-eslint/no-unsafe-call": 0
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"build": "npx ts-node build.ts",
|
|
6
6
|
"lint": "eslint . --ext .ts",
|
|
7
7
|
"start": "node -r module-alias/register ./dist --env=production",
|
|
8
|
-
"
|
|
8
|
+
"dev": "nodemon",
|
|
9
9
|
"test": "nodemon --config ./spec/nodemon.json",
|
|
10
10
|
"test:no-reloading": "npx ts-node -r tsconfig-paths/register ./spec"
|
|
11
11
|
},
|
|
@@ -27,40 +27,6 @@
|
|
|
27
27
|
"@server": "dist/server",
|
|
28
28
|
"@routes": "dist/routes"
|
|
29
29
|
},
|
|
30
|
-
"eslintConfig": {
|
|
31
|
-
"parser": "@typescript-eslint/parser",
|
|
32
|
-
"plugins": [
|
|
33
|
-
"@typescript-eslint"
|
|
34
|
-
],
|
|
35
|
-
"extends": [
|
|
36
|
-
"eslint:recommended",
|
|
37
|
-
"plugin:@typescript-eslint/recommended",
|
|
38
|
-
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
|
39
|
-
],
|
|
40
|
-
"parserOptions": {
|
|
41
|
-
"project": "./tsconfig.json"
|
|
42
|
-
},
|
|
43
|
-
"rules": {
|
|
44
|
-
"max-len": [
|
|
45
|
-
"error",
|
|
46
|
-
{
|
|
47
|
-
"code": 100
|
|
48
|
-
}
|
|
49
|
-
],
|
|
50
|
-
"no-console": 1,
|
|
51
|
-
"no-extra-boolean-cast": 0,
|
|
52
|
-
"@typescript-eslint/restrict-plus-operands": 0,
|
|
53
|
-
"@typescript-eslint/explicit-module-boundary-types": 0,
|
|
54
|
-
"@typescript-eslint/no-explicit-any": 0,
|
|
55
|
-
"@typescript-eslint/no-floating-promises": 0,
|
|
56
|
-
"@typescript-eslint/no-unsafe-member-access": 0,
|
|
57
|
-
"@typescript-eslint/no-unsafe-assignment": 0
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
"eslintIgnore": [
|
|
61
|
-
"src/public/",
|
|
62
|
-
"build.ts"
|
|
63
|
-
],
|
|
64
30
|
"dependencies": {
|
|
65
31
|
},
|
|
66
32
|
"devDependencies": {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import './pre-start'; // Must be the first import
|
|
2
2
|
import logger from 'jet-logger';
|
|
3
|
+
|
|
4
|
+
import envVars from '@shared/env-vars';
|
|
3
5
|
import server from './server';
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
// Constants
|
|
7
|
-
const serverStartMsg = 'Express server started on port: '
|
|
8
|
-
port = (process.env.PORT || 3000);
|
|
9
|
+
const serverStartMsg = 'Express server started on port: ';
|
|
9
10
|
|
|
10
11
|
// Start server
|
|
11
|
-
server.listen(port, () => {
|
|
12
|
-
logger.info(serverStartMsg + port);
|
|
12
|
+
server.listen(envVars.port, () => {
|
|
13
|
+
logger.info(serverStartMsg + envVars.port);
|
|
13
14
|
});
|
|
@@ -1,18 +1,28 @@
|
|
|
1
|
+
// ***** Start **** //
|
|
2
|
+
|
|
3
|
+
displayUsers();
|
|
4
|
+
|
|
5
|
+
|
|
1
6
|
// **** Fetch and display users **** //
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
allUsersAnchor
|
|
8
|
+
/**
|
|
9
|
+
* Call api
|
|
10
|
+
*/
|
|
11
|
+
function displayUsers() {
|
|
12
|
+
Http
|
|
13
|
+
.get('/api/users/all')
|
|
14
|
+
.then(resp => resp.json())
|
|
15
|
+
.then((resp) => {
|
|
16
|
+
var allUsers = resp.users;
|
|
17
|
+
// Empty the anchor
|
|
18
|
+
var allUsersAnchor = document.getElementById('all-users-anchor');
|
|
19
|
+
allUsersAnchor.innerHTML = '';
|
|
20
|
+
// Append users to anchor
|
|
21
|
+
allUsers.forEach((user) => {
|
|
22
|
+
allUsersAnchor.innerHTML += getUserDisplayEle(user);
|
|
23
|
+
});
|
|
14
24
|
});
|
|
15
|
-
|
|
25
|
+
}
|
|
16
26
|
|
|
17
27
|
/**
|
|
18
28
|
* Get the user display element
|
|
@@ -2,13 +2,14 @@ import cookieParser from 'cookie-parser';
|
|
|
2
2
|
import morgan from 'morgan';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import helmet from 'helmet';
|
|
5
|
+
import logger from 'jet-logger';
|
|
5
6
|
|
|
6
7
|
import express, { NextFunction, Request, Response } from 'express';
|
|
7
8
|
import StatusCodes from 'http-status-codes';
|
|
8
9
|
import 'express-async-errors';
|
|
9
10
|
|
|
10
|
-
import apiRouter from '
|
|
11
|
-
import
|
|
11
|
+
import apiRouter from '@routes/api';
|
|
12
|
+
import envVars from '@shared/env-vars';
|
|
12
13
|
import { CustomError } from '@shared/errors';
|
|
13
14
|
|
|
14
15
|
|
|
@@ -25,12 +26,12 @@ app.use(express.urlencoded({extended: true}));
|
|
|
25
26
|
app.use(cookieParser());
|
|
26
27
|
|
|
27
28
|
// Show routes called in console during development
|
|
28
|
-
if (
|
|
29
|
+
if (envVars.nodeEnv === 'development') {
|
|
29
30
|
app.use(morgan('dev'));
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
// Security (helmet recommended in express docs)
|
|
33
|
-
if (
|
|
34
|
+
if (envVars.nodeEnv === 'production') {
|
|
34
35
|
app.use(helmet());
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src/public/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"parser": "@typescript-eslint/parser",
|
|
3
|
+
"plugins": [
|
|
4
|
+
"@typescript-eslint"
|
|
5
|
+
],
|
|
6
|
+
"extends": [
|
|
7
|
+
"eslint:recommended",
|
|
8
|
+
"plugin:@typescript-eslint/recommended",
|
|
9
|
+
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
|
10
|
+
],
|
|
11
|
+
"parserOptions": {
|
|
12
|
+
"project": "./tsconfig.json"
|
|
13
|
+
},
|
|
14
|
+
"rules": {
|
|
15
|
+
"max-len": [
|
|
16
|
+
"error",
|
|
17
|
+
{
|
|
18
|
+
"code": 100
|
|
19
|
+
}
|
|
20
|
+
],
|
|
21
|
+
"no-console": 1,
|
|
22
|
+
"no-extra-boolean-cast": 0,
|
|
23
|
+
"semi": 1,
|
|
24
|
+
"@typescript-eslint/restrict-plus-operands": 0,
|
|
25
|
+
"@typescript-eslint/explicit-module-boundary-types": 0,
|
|
26
|
+
"@typescript-eslint/no-explicit-any": 0,
|
|
27
|
+
"@typescript-eslint/no-floating-promises": 0,
|
|
28
|
+
"@typescript-eslint/no-unsafe-member-access": 0,
|
|
29
|
+
"@typescript-eslint/no-unsafe-assignment": 0,
|
|
30
|
+
"@typescript-eslint/no-misused-promises": 0,
|
|
31
|
+
"@typescript-eslint/no-unsafe-argument": 0,
|
|
32
|
+
"@typescript-eslint/no-unsafe-return": 0,
|
|
33
|
+
"@typescript-eslint/no-unsafe-call": 0
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"build": "npx ts-node build.ts",
|
|
6
6
|
"lint": "eslint . --ext .ts",
|
|
7
7
|
"start": "node -r module-alias/register ./dist --env=production",
|
|
8
|
-
"
|
|
8
|
+
"dev": "nodemon",
|
|
9
9
|
"test": "nodemon --config ./spec/nodemon.json",
|
|
10
10
|
"test:no-reloading": "npx ts-node --files -r tsconfig-paths/register ./spec"
|
|
11
11
|
},
|
|
@@ -28,82 +28,8 @@
|
|
|
28
28
|
"@routes": "dist/routes",
|
|
29
29
|
"@util": "dist/util"
|
|
30
30
|
},
|
|
31
|
-
"eslintConfig": {
|
|
32
|
-
"parser": "@typescript-eslint/parser",
|
|
33
|
-
"plugins": [
|
|
34
|
-
"@typescript-eslint"
|
|
35
|
-
],
|
|
36
|
-
"extends": [
|
|
37
|
-
"eslint:recommended",
|
|
38
|
-
"plugin:@typescript-eslint/recommended",
|
|
39
|
-
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
|
40
|
-
],
|
|
41
|
-
"parserOptions": {
|
|
42
|
-
"project": "./tsconfig.json"
|
|
43
|
-
},
|
|
44
|
-
"rules": {
|
|
45
|
-
"max-len": [
|
|
46
|
-
"error",
|
|
47
|
-
{
|
|
48
|
-
"code": 100
|
|
49
|
-
}
|
|
50
|
-
],
|
|
51
|
-
"no-console": 1,
|
|
52
|
-
"no-extra-boolean-cast": 0,
|
|
53
|
-
"@typescript-eslint/restrict-plus-operands": 0,
|
|
54
|
-
"@typescript-eslint/explicit-module-boundary-types": 0,
|
|
55
|
-
"@typescript-eslint/no-explicit-any": 0,
|
|
56
|
-
"@typescript-eslint/no-floating-promises": 0,
|
|
57
|
-
"@typescript-eslint/no-unsafe-member-access": 0,
|
|
58
|
-
"@typescript-eslint/no-unsafe-assignment": 0
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
"eslintIgnore": [
|
|
62
|
-
"src/public/",
|
|
63
|
-
"build.ts"
|
|
64
|
-
],
|
|
65
31
|
"dependencies": {
|
|
66
|
-
"bcrypt": "^5.0.1",
|
|
67
|
-
"command-line-args": "^5.2.1",
|
|
68
|
-
"cookie-parser": "^1.4.6",
|
|
69
|
-
"dotenv": "^16.0.0",
|
|
70
|
-
"express": "^4.17.2",
|
|
71
|
-
"express-async-errors": "^3.1.1",
|
|
72
|
-
"helmet": "^5.0.2",
|
|
73
|
-
"http-status-codes": "^2.2.0",
|
|
74
|
-
"jet-logger": "^1.1.5",
|
|
75
|
-
"jsonfile": "^6.1.0",
|
|
76
|
-
"jsonwebtoken": "^8.5.1",
|
|
77
|
-
"module-alias": "^2.2.2",
|
|
78
|
-
"morgan": "^1.10.0",
|
|
79
|
-
"randomstring": "^1.2.2",
|
|
80
|
-
"socket.io": "^4.4.1"
|
|
81
32
|
},
|
|
82
33
|
"devDependencies": {
|
|
83
|
-
"@types/bcrypt": "^5.0.0",
|
|
84
|
-
"@types/command-line-args": "^5.2.0",
|
|
85
|
-
"@types/cookie-parser": "^1.4.2",
|
|
86
|
-
"@types/express": "^4.17.13",
|
|
87
|
-
"@types/find": "^0.2.1",
|
|
88
|
-
"@types/fs-extra": "^9.0.13",
|
|
89
|
-
"@types/jasmine": "^3.10.3",
|
|
90
|
-
"@types/jsonfile": "^6.0.1",
|
|
91
|
-
"@types/jsonwebtoken": "^8.5.8",
|
|
92
|
-
"@types/morgan": "^1.9.3",
|
|
93
|
-
"@types/node": "^17.0.15",
|
|
94
|
-
"@types/randomstring": "^1.1.8",
|
|
95
|
-
"@types/supertest": "^2.0.11",
|
|
96
|
-
"@typescript-eslint/eslint-plugin": "^5.10.2",
|
|
97
|
-
"@typescript-eslint/parser": "^5.10.2",
|
|
98
|
-
"eslint": "^8.8.0",
|
|
99
|
-
"find": "^0.3.0",
|
|
100
|
-
"fs-extra": "^10.0.0",
|
|
101
|
-
"jasmine": "^4.0.2",
|
|
102
|
-
"nodemon": "^2.0.15",
|
|
103
|
-
"socket.io-client": "^4.4.1",
|
|
104
|
-
"supertest": "^6.2.2",
|
|
105
|
-
"ts-node": "^10.4.0",
|
|
106
|
-
"tsconfig-paths": "^3.12.0",
|
|
107
|
-
"typescript": "^4.5.5"
|
|
108
34
|
}
|
|
109
35
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import './pre-start'; // Must be the first import
|
|
2
2
|
import logger from 'jet-logger';
|
|
3
|
+
|
|
3
4
|
import server from './server';
|
|
5
|
+
import envVars from '@shared/env-vars';
|
|
4
6
|
|
|
5
7
|
|
|
6
8
|
// Constants
|
|
7
|
-
const serverStartMsg = 'Express server started on port: '
|
|
8
|
-
port = (process.env.PORT || 3000);
|
|
9
|
+
const serverStartMsg = 'Express server started on port: ';
|
|
9
10
|
|
|
10
11
|
// Start server
|
|
11
|
-
server.listen(port, () => {
|
|
12
|
-
logger.info(serverStartMsg + port);
|
|
12
|
+
server.listen(envVars.port, () => {
|
|
13
|
+
logger.info(serverStartMsg + envVars.port);
|
|
13
14
|
});
|
|
@@ -1,19 +1,28 @@
|
|
|
1
|
+
// ***** Start **** //
|
|
2
|
+
|
|
3
|
+
displayUsers();
|
|
4
|
+
|
|
5
|
+
|
|
1
6
|
// **** Fetch and display users **** //
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
allUsersAnchor.innerHTML
|
|
8
|
+
/**
|
|
9
|
+
* Call api
|
|
10
|
+
*/
|
|
11
|
+
function displayUsers() {
|
|
12
|
+
Http
|
|
13
|
+
.get('/api/users/all')
|
|
14
|
+
.then(resp => resp.json())
|
|
15
|
+
.then((resp) => {
|
|
16
|
+
var allUsers = resp.users;
|
|
17
|
+
// Empty the anchor
|
|
18
|
+
var allUsersAnchor = document.getElementById('all-users-anchor');
|
|
19
|
+
allUsersAnchor.innerHTML = '';
|
|
20
|
+
// Append users to anchor
|
|
21
|
+
allUsers.forEach((user) => {
|
|
22
|
+
allUsersAnchor.innerHTML += getUserDisplayEle(user);
|
|
23
|
+
});
|
|
15
24
|
});
|
|
16
|
-
|
|
25
|
+
}
|
|
17
26
|
|
|
18
27
|
/**
|
|
19
28
|
* Get user display element.
|
|
@@ -125,9 +134,7 @@ function submitEdit(ele) {
|
|
|
125
134
|
};
|
|
126
135
|
Http
|
|
127
136
|
.put('/api/users/update', data)
|
|
128
|
-
.then(() =>
|
|
129
|
-
displayUsers();
|
|
130
|
-
});
|
|
137
|
+
.then(() => displayUsers());
|
|
131
138
|
}
|
|
132
139
|
|
|
133
140
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
nodeEnv: process.env.NODE_ENV ?? '',
|
|
3
|
-
port: process.env.PORT ?? 0,
|
|
2
|
+
nodeEnv: (process.env.NODE_ENV ?? ''),
|
|
3
|
+
port: (process.env.PORT ?? 0),
|
|
4
4
|
cookieProps: {
|
|
5
5
|
key: 'ExpressGeneratorTs',
|
|
6
|
-
secret: process.env.COOKIE_SECRET ?? '',
|
|
6
|
+
secret: (process.env.COOKIE_SECRET ?? ''),
|
|
7
7
|
options: {
|
|
8
8
|
httpOnly: true,
|
|
9
9
|
signed: true,
|
|
@@ -14,7 +14,7 @@ export default {
|
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
jwt: {
|
|
17
|
-
secret: process.env.JWT_SECRET ?? '',
|
|
18
|
-
exp: process.env.COOKIE_EXP ?? '', // exp at the same time as the cookie
|
|
17
|
+
secret: (process.env.JWT_SECRET ?? ''),
|
|
18
|
+
exp: (process.env.COOKIE_EXP ?? ''), // exp at the same time as the cookie
|
|
19
19
|
},
|
|
20
|
-
};
|
|
20
|
+
} as const;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
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",
|