express-generator-typescript 2.7.1 → 2.7.3
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/LICENSE +21 -21
- package/README-npm +20 -0
- package/README.md +85 -20
- package/lib/project-files/README.md +65 -65
- package/lib/project-files/config.ts +22 -22
- package/lib/project-files/eslint.config.ts +95 -95
- package/lib/project-files/package.json +58 -58
- package/lib/project-files/src/common/constants/ENV.ts +21 -21
- package/lib/project-files/src/common/constants/HttpStatusCodes.ts +391 -391
- package/lib/project-files/src/common/constants/Paths.ts +11 -11
- package/lib/project-files/src/common/constants/index.ts +11 -11
- package/lib/project-files/src/common/util/route-errors.ts +37 -37
- package/lib/project-files/src/common/util/validators.ts +22 -22
- package/lib/project-files/src/index.ts +17 -4
- package/lib/project-files/src/models/User.ts +4 -4
- package/lib/project-files/src/models/common/types/index.ts +5 -5
- package/lib/project-files/src/public/scripts/http.js +26 -26
- package/lib/project-files/src/public/scripts/users.js +141 -141
- package/lib/project-files/src/public/stylesheets/users.css +48 -48
- package/lib/project-files/src/repos/MockOrm.ts +62 -62
- package/lib/project-files/src/repos/database.json +1 -1
- package/lib/project-files/src/repos/database.test.json +1 -22
- package/lib/project-files/src/routes/common/types/index.ts +11 -11
- package/lib/project-files/src/routes/common/util/index.ts +18 -18
- package/lib/project-files/src/routes/index.ts +33 -33
- package/lib/project-files/src/services/UserService.ts +73 -73
- package/lib/project-files/src/views/users.html +132 -132
- package/lib/project-files/tests/common/Paths.ts +5 -5
- package/lib/project-files/tests/common/types/index.ts +16 -16
- package/lib/project-files/tests/common/util/index.ts +38 -38
- package/lib/project-files/tests/support/setup.ts +26 -26
- package/lib/project-files/tsconfig.json +1 -1
- package/lib/project-files/tsconfig.prod.json +30 -30
- package/lib/project-files/{vitest.config.ts → vitest.config.mts} +18 -18
- package/package.json +1 -1
- package/README-git +0 -95
|
@@ -1,132 +1,132 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<!-- Head -->
|
|
5
|
-
<head>
|
|
6
|
-
<meta charset="UTF-8">
|
|
7
|
-
<title>Users</title>
|
|
8
|
-
<link rel="stylesheet" type="text/css" href="/stylesheets/users.css" />
|
|
9
|
-
|
|
10
|
-
<!-- Handlebars -->
|
|
11
|
-
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.8/handlebars.min.js"></script>
|
|
12
|
-
|
|
13
|
-
<!-- Bootstrap -->
|
|
14
|
-
<link
|
|
15
|
-
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
|
16
|
-
rel="stylesheet"
|
|
17
|
-
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
|
18
|
-
crossorigin="anonymous"
|
|
19
|
-
/>
|
|
20
|
-
<script
|
|
21
|
-
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
|
22
|
-
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
|
23
|
-
crossorigin="anonymous"
|
|
24
|
-
></script>
|
|
25
|
-
</head>
|
|
26
|
-
|
|
27
|
-
<!-- Body -->
|
|
28
|
-
<body>
|
|
29
|
-
|
|
30
|
-
<!-- Add Users -->
|
|
31
|
-
<div class="users-column add-user-col">
|
|
32
|
-
<div class="column-header">
|
|
33
|
-
Add User:
|
|
34
|
-
</div>
|
|
35
|
-
<div>
|
|
36
|
-
<input
|
|
37
|
-
id="name-input"
|
|
38
|
-
type="text"
|
|
39
|
-
class="form-control"
|
|
40
|
-
placeholder="Name"
|
|
41
|
-
/>
|
|
42
|
-
</div>
|
|
43
|
-
<div>
|
|
44
|
-
<input
|
|
45
|
-
id="email-input"
|
|
46
|
-
type="email"
|
|
47
|
-
class="form-control"
|
|
48
|
-
placeholder="Email"
|
|
49
|
-
/>
|
|
50
|
-
</div>
|
|
51
|
-
<div>
|
|
52
|
-
<button
|
|
53
|
-
id="add-user-btn"
|
|
54
|
-
class="btn btn-success"
|
|
55
|
-
>
|
|
56
|
-
Add
|
|
57
|
-
</button>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
|
|
61
|
-
<!-- Display Users -->
|
|
62
|
-
<div class="users-column">
|
|
63
|
-
<div class="column-header">
|
|
64
|
-
Users:
|
|
65
|
-
</div>
|
|
66
|
-
|
|
67
|
-
<div id="all-users-anchor"></div>
|
|
68
|
-
<script
|
|
69
|
-
id="all-users-template"
|
|
70
|
-
type="text/x-handlebars-template"
|
|
71
|
-
>
|
|
72
|
-
{{#each users}}
|
|
73
|
-
<div class="user-display-ele">
|
|
74
|
-
<div class="normal-view">
|
|
75
|
-
<div><b>Name:</b> {{name}}</div>
|
|
76
|
-
<div><b>Email:</b> {{email}}</div>
|
|
77
|
-
<div><b>Created:</b> {{createdFormatted}}</div>
|
|
78
|
-
<button
|
|
79
|
-
type="button"
|
|
80
|
-
class="btn btn-primary edit-user-btn"
|
|
81
|
-
data-user-id="{{id}}"
|
|
82
|
-
>
|
|
83
|
-
Edit
|
|
84
|
-
</button>
|
|
85
|
-
<button
|
|
86
|
-
class="btn btn-danger delete-user-btn"
|
|
87
|
-
data-user-id="{{id}}"
|
|
88
|
-
>
|
|
89
|
-
Delete
|
|
90
|
-
</button>
|
|
91
|
-
</div>
|
|
92
|
-
|
|
93
|
-
<div class="edit-view">
|
|
94
|
-
<div>
|
|
95
|
-
Name:
|
|
96
|
-
<input
|
|
97
|
-
type="text"
|
|
98
|
-
class="form-control name-edit-input"
|
|
99
|
-
value="{{name}}"
|
|
100
|
-
/>
|
|
101
|
-
</div>
|
|
102
|
-
<div class="email-edit">
|
|
103
|
-
Email:
|
|
104
|
-
<input
|
|
105
|
-
type="email"
|
|
106
|
-
class="form-control email-edit-input"
|
|
107
|
-
value="{{email}}"
|
|
108
|
-
/>
|
|
109
|
-
</div>
|
|
110
|
-
<button
|
|
111
|
-
class="btn btn-primary submit-edit-btn"
|
|
112
|
-
data-user-id="{{id}}"
|
|
113
|
-
data-user-created="{{created}}"
|
|
114
|
-
>
|
|
115
|
-
Submit
|
|
116
|
-
</button>
|
|
117
|
-
<button
|
|
118
|
-
class="btn btn-secondary cancel-edit-btn"
|
|
119
|
-
data-user-id="{{id}}"
|
|
120
|
-
>
|
|
121
|
-
Cancel
|
|
122
|
-
</button>
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
125
|
-
{{/each}}
|
|
126
|
-
</script>
|
|
127
|
-
</div>
|
|
128
|
-
</body>
|
|
129
|
-
|
|
130
|
-
<script src="scripts/http.js"></script>
|
|
131
|
-
<script src="scripts/users.js"></script>
|
|
132
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<!-- Head -->
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="UTF-8">
|
|
7
|
+
<title>Users</title>
|
|
8
|
+
<link rel="stylesheet" type="text/css" href="/stylesheets/users.css" />
|
|
9
|
+
|
|
10
|
+
<!-- Handlebars -->
|
|
11
|
+
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.8/handlebars.min.js"></script>
|
|
12
|
+
|
|
13
|
+
<!-- Bootstrap -->
|
|
14
|
+
<link
|
|
15
|
+
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
|
|
16
|
+
rel="stylesheet"
|
|
17
|
+
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
|
|
18
|
+
crossorigin="anonymous"
|
|
19
|
+
/>
|
|
20
|
+
<script
|
|
21
|
+
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"
|
|
22
|
+
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"
|
|
23
|
+
crossorigin="anonymous"
|
|
24
|
+
></script>
|
|
25
|
+
</head>
|
|
26
|
+
|
|
27
|
+
<!-- Body -->
|
|
28
|
+
<body>
|
|
29
|
+
|
|
30
|
+
<!-- Add Users -->
|
|
31
|
+
<div class="users-column add-user-col">
|
|
32
|
+
<div class="column-header">
|
|
33
|
+
Add User:
|
|
34
|
+
</div>
|
|
35
|
+
<div>
|
|
36
|
+
<input
|
|
37
|
+
id="name-input"
|
|
38
|
+
type="text"
|
|
39
|
+
class="form-control"
|
|
40
|
+
placeholder="Name"
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
<div>
|
|
44
|
+
<input
|
|
45
|
+
id="email-input"
|
|
46
|
+
type="email"
|
|
47
|
+
class="form-control"
|
|
48
|
+
placeholder="Email"
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
<div>
|
|
52
|
+
<button
|
|
53
|
+
id="add-user-btn"
|
|
54
|
+
class="btn btn-success"
|
|
55
|
+
>
|
|
56
|
+
Add
|
|
57
|
+
</button>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<!-- Display Users -->
|
|
62
|
+
<div class="users-column">
|
|
63
|
+
<div class="column-header">
|
|
64
|
+
Users:
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div id="all-users-anchor"></div>
|
|
68
|
+
<script
|
|
69
|
+
id="all-users-template"
|
|
70
|
+
type="text/x-handlebars-template"
|
|
71
|
+
>
|
|
72
|
+
{{#each users}}
|
|
73
|
+
<div class="user-display-ele">
|
|
74
|
+
<div class="normal-view">
|
|
75
|
+
<div><b>Name:</b> {{name}}</div>
|
|
76
|
+
<div><b>Email:</b> {{email}}</div>
|
|
77
|
+
<div><b>Created:</b> {{createdFormatted}}</div>
|
|
78
|
+
<button
|
|
79
|
+
type="button"
|
|
80
|
+
class="btn btn-primary edit-user-btn"
|
|
81
|
+
data-user-id="{{id}}"
|
|
82
|
+
>
|
|
83
|
+
Edit
|
|
84
|
+
</button>
|
|
85
|
+
<button
|
|
86
|
+
class="btn btn-danger delete-user-btn"
|
|
87
|
+
data-user-id="{{id}}"
|
|
88
|
+
>
|
|
89
|
+
Delete
|
|
90
|
+
</button>
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<div class="edit-view">
|
|
94
|
+
<div>
|
|
95
|
+
Name:
|
|
96
|
+
<input
|
|
97
|
+
type="text"
|
|
98
|
+
class="form-control name-edit-input"
|
|
99
|
+
value="{{name}}"
|
|
100
|
+
/>
|
|
101
|
+
</div>
|
|
102
|
+
<div class="email-edit">
|
|
103
|
+
Email:
|
|
104
|
+
<input
|
|
105
|
+
type="email"
|
|
106
|
+
class="form-control email-edit-input"
|
|
107
|
+
value="{{email}}"
|
|
108
|
+
/>
|
|
109
|
+
</div>
|
|
110
|
+
<button
|
|
111
|
+
class="btn btn-primary submit-edit-btn"
|
|
112
|
+
data-user-id="{{id}}"
|
|
113
|
+
data-user-created="{{created}}"
|
|
114
|
+
>
|
|
115
|
+
Submit
|
|
116
|
+
</button>
|
|
117
|
+
<button
|
|
118
|
+
class="btn btn-secondary cancel-edit-btn"
|
|
119
|
+
data-user-id="{{id}}"
|
|
120
|
+
>
|
|
121
|
+
Cancel
|
|
122
|
+
</button>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
{{/each}}
|
|
126
|
+
</script>
|
|
127
|
+
</div>
|
|
128
|
+
</body>
|
|
129
|
+
|
|
130
|
+
<script src="scripts/http.js"></script>
|
|
131
|
+
<script src="scripts/users.js"></script>
|
|
132
|
+
</html>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import jetPaths from 'jet-paths';
|
|
2
|
-
import Paths from '@src/common/constants/Paths';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export default jetPaths(Paths);
|
|
1
|
+
import jetPaths from 'jet-paths';
|
|
2
|
+
import Paths from '@src/common/constants/Paths';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export default jetPaths(Paths);
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Response } from 'supertest';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
/******************************************************************************
|
|
5
|
-
Types
|
|
6
|
-
******************************************************************************/
|
|
7
|
-
|
|
8
|
-
// Use generics to add properties to 'body'
|
|
9
|
-
export type TRes<T = object> = Omit<Response, 'body'> & {
|
|
10
|
-
body: T & { error?: string | IErrObj },
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
interface IErrObj {
|
|
14
|
-
message: string;
|
|
15
|
-
[key: string]: unknown;
|
|
16
|
-
}
|
|
1
|
+
import { Response } from 'supertest';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/******************************************************************************
|
|
5
|
+
Types
|
|
6
|
+
******************************************************************************/
|
|
7
|
+
|
|
8
|
+
// Use generics to add properties to 'body'
|
|
9
|
+
export type TRes<T = object> = Omit<Response, 'body'> & {
|
|
10
|
+
body: T & { error?: string | IErrObj },
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
interface IErrObj {
|
|
14
|
+
message: string;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
import { Response } from 'supertest';
|
|
2
|
-
import { IParseObjectError, parseJson } from 'jet-validators/utils';
|
|
3
|
-
import { isString } from 'jet-validators';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/******************************************************************************
|
|
7
|
-
Types
|
|
8
|
-
******************************************************************************/
|
|
9
|
-
|
|
10
|
-
// Use generics to add properties to 'body'
|
|
11
|
-
export type TRes<T = object> = Omit<Response, 'body'> & {
|
|
12
|
-
body: T & { error?: string | IErrObj },
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
interface IErrObj {
|
|
16
|
-
message: string;
|
|
17
|
-
[key: string]: unknown;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface IValidationErr {
|
|
21
|
-
message: string;
|
|
22
|
-
errors: IParseObjectError[];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
/******************************************************************************
|
|
27
|
-
Functions
|
|
28
|
-
******************************************************************************/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* JSON parse a validation error.
|
|
32
|
-
*/
|
|
33
|
-
export function parseValidationErr(arg: unknown): IValidationErr {
|
|
34
|
-
if (!isString(arg)) {
|
|
35
|
-
throw new Error('Not a string');
|
|
36
|
-
}
|
|
37
|
-
return parseJson<IValidationErr>(arg);
|
|
38
|
-
}
|
|
1
|
+
import { Response } from 'supertest';
|
|
2
|
+
import { IParseObjectError, parseJson } from 'jet-validators/utils';
|
|
3
|
+
import { isString } from 'jet-validators';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/******************************************************************************
|
|
7
|
+
Types
|
|
8
|
+
******************************************************************************/
|
|
9
|
+
|
|
10
|
+
// Use generics to add properties to 'body'
|
|
11
|
+
export type TRes<T = object> = Omit<Response, 'body'> & {
|
|
12
|
+
body: T & { error?: string | IErrObj },
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
interface IErrObj {
|
|
16
|
+
message: string;
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface IValidationErr {
|
|
21
|
+
message: string;
|
|
22
|
+
errors: IParseObjectError[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
/******************************************************************************
|
|
27
|
+
Functions
|
|
28
|
+
******************************************************************************/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* JSON parse a validation error.
|
|
32
|
+
*/
|
|
33
|
+
export function parseValidationErr(arg: unknown): IValidationErr {
|
|
34
|
+
if (!isString(arg)) {
|
|
35
|
+
throw new Error('Not a string');
|
|
36
|
+
}
|
|
37
|
+
return parseJson<IValidationErr>(arg);
|
|
38
|
+
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
import { beforeAll } from 'vitest';
|
|
3
|
-
import supertest, { Test } from 'supertest';
|
|
4
|
-
import TestAgent from 'supertest/lib/agent';
|
|
5
|
-
|
|
6
|
-
import app from '@src/server';
|
|
7
|
-
import MockOrm from '@src/repos/MockOrm';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/******************************************************************************
|
|
11
|
-
Run
|
|
12
|
-
******************************************************************************/
|
|
13
|
-
|
|
14
|
-
let agent: TestAgent<Test>;
|
|
15
|
-
|
|
16
|
-
beforeAll(async () => {
|
|
17
|
-
agent = supertest.agent(app);
|
|
18
|
-
await MockOrm.cleanDb();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/******************************************************************************
|
|
23
|
-
Export
|
|
24
|
-
******************************************************************************/
|
|
25
|
-
|
|
26
|
-
export { agent };
|
|
1
|
+
|
|
2
|
+
import { beforeAll } from 'vitest';
|
|
3
|
+
import supertest, { Test } from 'supertest';
|
|
4
|
+
import TestAgent from 'supertest/lib/agent';
|
|
5
|
+
|
|
6
|
+
import app from '@src/server';
|
|
7
|
+
import MockOrm from '@src/repos/MockOrm';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
/******************************************************************************
|
|
11
|
+
Run
|
|
12
|
+
******************************************************************************/
|
|
13
|
+
|
|
14
|
+
let agent: TestAgent<Test>;
|
|
15
|
+
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
agent = supertest.agent(app);
|
|
18
|
+
await MockOrm.cleanDb();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
/******************************************************************************
|
|
23
|
+
Export
|
|
24
|
+
******************************************************************************/
|
|
25
|
+
|
|
26
|
+
export { agent };
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "CommonJS",
|
|
5
|
-
"lib": ["ES2020"],
|
|
6
|
-
"strict": true,
|
|
7
|
-
"baseUrl": "./",
|
|
8
|
-
"outDir": "temp",
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"paths": {
|
|
13
|
-
"@src/*": ["src/*"]
|
|
14
|
-
},
|
|
15
|
-
"useUnknownInCatchVariables": false,
|
|
16
|
-
"sourceMap": false,
|
|
17
|
-
"removeComments": true
|
|
18
|
-
},
|
|
19
|
-
"include": [
|
|
20
|
-
"src/**/*.ts",
|
|
21
|
-
"config.ts"
|
|
22
|
-
],
|
|
23
|
-
"exclude": [
|
|
24
|
-
"tests",
|
|
25
|
-
"src/public/",
|
|
26
|
-
"scripts",
|
|
27
|
-
"eslint.config.ts",
|
|
28
|
-
"vitest.config.js"
|
|
29
|
-
]
|
|
30
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"strict": true,
|
|
7
|
+
"baseUrl": "./",
|
|
8
|
+
"outDir": "temp",
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"paths": {
|
|
13
|
+
"@src/*": ["src/*"]
|
|
14
|
+
},
|
|
15
|
+
"useUnknownInCatchVariables": false,
|
|
16
|
+
"sourceMap": false,
|
|
17
|
+
"removeComments": true
|
|
18
|
+
},
|
|
19
|
+
"include": [
|
|
20
|
+
"src/**/*.ts",
|
|
21
|
+
"config.ts"
|
|
22
|
+
],
|
|
23
|
+
"exclude": [
|
|
24
|
+
"tests",
|
|
25
|
+
"src/public/",
|
|
26
|
+
"scripts",
|
|
27
|
+
"eslint.config.ts",
|
|
28
|
+
"vitest.config.js"
|
|
29
|
+
]
|
|
30
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
const config = defineConfig({
|
|
5
|
-
test: {
|
|
6
|
-
globals: true,
|
|
7
|
-
environment: 'node',
|
|
8
|
-
setupFiles: ['config.ts', './tests/support/setup.ts'],
|
|
9
|
-
isolate: true,
|
|
10
|
-
},
|
|
11
|
-
resolve: {
|
|
12
|
-
alias: {
|
|
13
|
-
'@src': path.resolve(__dirname, './src'),
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export default config;
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
const config = defineConfig({
|
|
5
|
+
test: {
|
|
6
|
+
globals: true,
|
|
7
|
+
environment: 'node',
|
|
8
|
+
setupFiles: ['config.ts', './tests/support/setup.ts'],
|
|
9
|
+
isolate: true,
|
|
10
|
+
},
|
|
11
|
+
resolve: {
|
|
12
|
+
alias: {
|
|
13
|
+
'@src': path.resolve(__dirname, './src'),
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
export default config;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
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",
|
package/README-git
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
<img alt='overnightjs' src='https://github.com/seanpmaxwell/express-generator-typescript/raw/master/express-typescript.png' border='0'>
|
|
2
|
-
|
|
3
|
-
[Express](https://www.npmjs.com/package/express) with [TypeScript's](https://www.npmjs.com/package/typescript) application generator.
|
|
4
|
-
|
|
5
|
-
<a href="https://www.npmjs.com/package/express-generator-typescript" target="_blank"><img src="https://img.shields.io/npm/v/express-generator-typescript.svg" alt="NPM Version" /></a>
|
|
6
|
-
<a href="https://www.npmjs.com/package/express-generator-typescript" target="_blank"><img src="https://img.shields.io/npm/l/express-generator-typescript.svg" alt="Package License" /></a>
|
|
7
|
-
<a href="https://www.npmjs.com/package/express-generator-typescript" target="_blank"><img src="https://img.shields.io/npm/dm/express-generator-typescript.svg" alt="NPM Downloads" /></a>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
## What is it?
|
|
11
|
-
|
|
12
|
-
Creates a new express application similar to the _express-generator_ module. Except this new application is configured to use TypeScript instead of plain JavaScript.
|
|
13
|
-
|
|
14
|
-
This project complies with Typescript best practices listed <a href="https://github.com/seanpmaxwell/Typescript-Best-Practices/blob/main/README.md">here</a>.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## Why express-generator-typescript?
|
|
18
|
-
|
|
19
|
-
NodeJS is great for the rapid development of web-projects, but is often neglected because of the lack of type safety. TypeScript solves this issue and (along with its linter file) can even make your code more robust than some other static languages like Java.
|
|
20
|
-
|
|
21
|
-
There are some other tools out there to generate express apps with TypeScript such as _express-generator-ts_, but these either haven't been updated in a while or install a lot of junk in your project (such as an ORM).
|
|
22
|
-
|
|
23
|
-
Due to the heavy use of single-page-applications, no view-engine is configured by default. Express is only setup with the minimal settings for calling APIs and serving an index.html file. All the tools you need to run for development (while restarting on changes), building, testing, and running for production are packaged with this library.
|
|
24
|
-
|
|
25
|
-
In addition, relative paths are also setup, so you don't have to go through the trouble of installing and configuring _tsconfig-paths_ and _module-alias_. Just make sure to update `paths` in _tsconfig.json_ and `_moduleAliases` in _preload.js_ if you want to add/edit the relative paths.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## Sample-project
|
|
29
|
-
|
|
30
|
-
When you run _express-generator-typescript_, it sets up a simple application with routes for adding, updating, deleting, and fetching user objects. This is just to demonstrate how routing is done with express.
|
|
31
|
-
|
|
32
|
-
### `--with-auth` option no longer available for version 2.5+
|
|
33
|
-
|
|
34
|
-
For the command-line, you used to be able to pass the `--with-auth` option to generate an app which required a login before using the routes; however, maintaining two separate projects became quite cumbersome. If you want an example of how to do authentication in expressjs with json-web-tokens you can refer to this sample project <a href="https://github.com/seanpmaxwell/express-jsonwebtoken-demo">here</a>.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
## Installation
|
|
38
|
-
|
|
39
|
-
```sh
|
|
40
|
-
$ Just use 'npx'
|
|
41
|
-
Or
|
|
42
|
-
$ npm install -g express-generator-typescript
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
## Quick Start
|
|
47
|
-
|
|
48
|
-
The quickest way to get started is use npx and pass in the name of the project you want to create. If you don't specify a project name, the default _express-gen-ts_ will be used instead. If you want to use `yarn` instead of `npm`, pass the option `--use-yarn`.
|
|
49
|
-
|
|
50
|
-
Create the app:<br/>
|
|
51
|
-
With no options: `$ npx express-generator-typescript`<br/>
|
|
52
|
-
With all options (order doesn't matter): `$ npx express-generator-typescript --use-yarn "project name"`
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
Start your express-generator-typescript app in development mode at `http://localhost:3000/`:
|
|
56
|
-
|
|
57
|
-
```bash
|
|
58
|
-
$ cd "project name" && npm run dev
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
## Available commands for the server.
|
|
63
|
-
|
|
64
|
-
- Run the server in development mode: `npm run dev` or `npm run dev:hot`.
|
|
65
|
-
- Run all unit-tests: `npm run test` or `npm run test:hot`.
|
|
66
|
-
- Run a single unit-test: `npm test -- --testFile="name of test file" (i.e. --testFile=Users)`.
|
|
67
|
-
- Check for linting errors: `npm run lint`.
|
|
68
|
-
- Build the project for production: `npm run build`.
|
|
69
|
-
- Run the production build: `npm start`.
|
|
70
|
-
- Check for typescript errors: `npm run type-check`.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
## Debugging
|
|
74
|
-
|
|
75
|
-
During development, _express-generator-typescript_ uses `nodemon` to restart the server when changes are detected. If you want to enable debugging for node, you'll need to modify the nodemon configurations. This is located under `nodemonConfig:` in `package.json` for the server and `./spec/nodemon.json` for unit-testing. For the `exec` property, replace `ts-node` with `node --inspect -r ts-node/register`.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## Note for VSCode users
|
|
79
|
-
|
|
80
|
-
In order to use eslint as a typescript file with VSCode, you need to add a setting to your eslint options. At the root of your project, add a `.vscode/settings.json` file (if you don't have one already) and add the option `unstable_ts_config`:
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
"eslint.options": {
|
|
84
|
-
"flags": ["unstable_ts_config"]
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
<br/>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
Happy web deving :)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
## License
|
|
94
|
-
|
|
95
|
-
[MIT](LICENSE)
|