express-generator-typescript 2.4.22 → 2.4.23
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/src/routes/UserRoutes.ts +4 -4
- package/lib/project-files/src/server.ts +3 -8
- package/lib/project-files-auth/src/routes/AuthRoutes.ts +2 -2
- package/lib/project-files-auth/src/routes/UserRoutes.ts +4 -4
- package/lib/project-files-auth/src/server.ts +3 -8
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
54
|
+
return next(err);
|
|
60
55
|
});
|
|
61
56
|
|
|
62
57
|
|
|
@@ -22,7 +22,7 @@ async function login(req: IReq, res: IRes) {
|
|
|
22
22
|
role: user.role,
|
|
23
23
|
});
|
|
24
24
|
// Return
|
|
25
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
44
|
+
res.status(HttpStatusCodes.OK).end();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
|
|
@@ -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
|
|
59
|
+
return next(err);
|
|
65
60
|
});
|
|
66
61
|
|
|
67
62
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "express-generator-typescript",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.23",
|
|
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",
|