jcc-express-mvc 1.0.3 → 1.0.5
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/index.js +1 -1
- package/package.json +22 -22
- package/src/Auth/index.js +74 -74
- package/src/Auth/protectedRoute.js +30 -30
- package/src/Router/Router.js +42 -42
- package/src/Router/Routes.js +28 -28
- package/src/app/index.js +62 -62
- package/src/command-line-interface/commands.js +119 -119
- package/src/command-line-interface/dbCli.js +59 -59
- package/src/command-line-interface/getCommands.js +86 -86
- package/src/command-line-interface/getDbCliCommand.js +18 -18
- package/src/dbConnection/index.js +14 -14
- package/src/error/AppError.js +8 -8
- package/src/error/ErrorHandler.js +71 -71
- package/src/error/public/pageNotFound.html +28 -28
- package/src/files/controller.js +67 -67
- package/src/files/model.js +14 -14
- package/src/files/request.js +28 -28
- package/src/files/resoucesController.js +72 -72
- package/src/helpers.js +70 -70
- package/src/index.js +42 -42
- package/src/middlware/index.js +60 -60
- package/src/middlware/isLogin.js +19 -19
- package/src/passport/config.js +38 -38
- package/src/request/FormRequest.js +36 -35
- package/src/request/index.js +23 -23
- package/src/response/index.js +32 -32
- package/src/socket/index.js +18 -18
- package/src/utils/index.js +79 -79
- package/src/validation/index.js +71 -71
- package/src/validation/method.js +168 -168
- package/src/validation/rules.js +92 -92
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require("./src");
|
|
1
|
+
module.exports = require("./src");
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "jcc-express-mvc",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "express mvc structure",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/jammehabdou64/express-mvc.git"
|
|
12
|
-
},
|
|
13
|
-
"keywords": [
|
|
14
|
-
"library"
|
|
15
|
-
],
|
|
16
|
-
"author": "Abdou Jammeh",
|
|
17
|
-
"license": "ISC",
|
|
18
|
-
"bugs": {
|
|
19
|
-
"url": "https://github.com/jammehabdou64/express-mvc.git/issues"
|
|
20
|
-
},
|
|
21
|
-
"homepage": "https://github.com/jammehabdou64/express-mvc.git#readme"
|
|
22
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "jcc-express-mvc",
|
|
3
|
+
"version": "1.0.5",
|
|
4
|
+
"description": "express mvc structure",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/jammehabdou64/express-mvc.git"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"library"
|
|
15
|
+
],
|
|
16
|
+
"author": "Abdou Jammeh",
|
|
17
|
+
"license": "ISC",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/jammehabdou64/express-mvc.git/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/jammehabdou64/express-mvc.git#readme"
|
|
22
|
+
}
|
package/src/Auth/index.js
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
const passport = require("passport");
|
|
2
|
-
const { getModel, verifyHash } = require("../helpers");
|
|
3
|
-
const User = getModel("User");
|
|
4
|
-
|
|
5
|
-
class Auth {
|
|
6
|
-
async login(data = {}, password = "") {
|
|
7
|
-
try {
|
|
8
|
-
const user = await User.findOne(data).select("+password");
|
|
9
|
-
if (!user) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return (await verifyHash(password, user.password)) ? user : false;
|
|
14
|
-
} catch (error) {
|
|
15
|
-
return new Error(error.message);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async isAdmin(req, res, next) {
|
|
20
|
-
try {
|
|
21
|
-
const user = await User.findById(req.id);
|
|
22
|
-
if (!user) {
|
|
23
|
-
return res.json({ message: "Not authorize" }).status(403);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
user.role != "admin" ||
|
|
28
|
-
user.role != "Admin" ||
|
|
29
|
-
user.role != false ||
|
|
30
|
-
user.roleType != "admin" ||
|
|
31
|
-
user.roleType != "Admin" ||
|
|
32
|
-
user.roleType != false ||
|
|
33
|
-
user.isAdmin != "Admin" ||
|
|
34
|
-
user.isAdmin != "admin" ||
|
|
35
|
-
user.isAdmin != false
|
|
36
|
-
) {
|
|
37
|
-
return res.json({ message: "Not authorize" }).status(403);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
next();
|
|
41
|
-
} catch (error) {
|
|
42
|
-
next(error);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async verifyEmail(req, res, next) {
|
|
47
|
-
try {
|
|
48
|
-
const user = await User.findById(req.id);
|
|
49
|
-
if (!user) {
|
|
50
|
-
return res.json({ message: "Not authorize" }).status(403);
|
|
51
|
-
}
|
|
52
|
-
if (!user.verify_email || !user.verifyEmail) {
|
|
53
|
-
return res.json({ message: "please verify your email" }).status(403);
|
|
54
|
-
}
|
|
55
|
-
next();
|
|
56
|
-
} catch (err) {
|
|
57
|
-
next(err);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
attempt(req, res, next) {
|
|
62
|
-
try {
|
|
63
|
-
let redirectBack = req.previsiousUrls[1];
|
|
64
|
-
return passport.authenticate("local", {
|
|
65
|
-
successRedirect: "/home",
|
|
66
|
-
failureRedirect: `${redirectBack ? redirectBack : "/login"}`,
|
|
67
|
-
failureFlash: true,
|
|
68
|
-
})(req, res, next);
|
|
69
|
-
} catch (error) {
|
|
70
|
-
next(error);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
module.exports = new Auth();
|
|
1
|
+
const passport = require("passport");
|
|
2
|
+
const { getModel, verifyHash } = require("../helpers");
|
|
3
|
+
const User = getModel("User");
|
|
4
|
+
|
|
5
|
+
class Auth {
|
|
6
|
+
async login(data = {}, password = "") {
|
|
7
|
+
try {
|
|
8
|
+
const user = await User.findOne(data).select("+password");
|
|
9
|
+
if (!user) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return (await verifyHash(password, user.password)) ? user : false;
|
|
14
|
+
} catch (error) {
|
|
15
|
+
return new Error(error.message);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async isAdmin(req, res, next) {
|
|
20
|
+
try {
|
|
21
|
+
const user = await User.findById(req.id);
|
|
22
|
+
if (!user) {
|
|
23
|
+
return res.json({ message: "Not authorize" }).status(403);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (
|
|
27
|
+
user.role != "admin" ||
|
|
28
|
+
user.role != "Admin" ||
|
|
29
|
+
user.role != false ||
|
|
30
|
+
user.roleType != "admin" ||
|
|
31
|
+
user.roleType != "Admin" ||
|
|
32
|
+
user.roleType != false ||
|
|
33
|
+
user.isAdmin != "Admin" ||
|
|
34
|
+
user.isAdmin != "admin" ||
|
|
35
|
+
user.isAdmin != false
|
|
36
|
+
) {
|
|
37
|
+
return res.json({ message: "Not authorize" }).status(403);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
next();
|
|
41
|
+
} catch (error) {
|
|
42
|
+
next(error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
async verifyEmail(req, res, next) {
|
|
47
|
+
try {
|
|
48
|
+
const user = await User.findById(req.id);
|
|
49
|
+
if (!user) {
|
|
50
|
+
return res.json({ message: "Not authorize" }).status(403);
|
|
51
|
+
}
|
|
52
|
+
if (!user.verify_email || !user.verifyEmail) {
|
|
53
|
+
return res.json({ message: "please verify your email" }).status(403);
|
|
54
|
+
}
|
|
55
|
+
next();
|
|
56
|
+
} catch (err) {
|
|
57
|
+
next(err);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
attempt(req, res, next) {
|
|
62
|
+
try {
|
|
63
|
+
let redirectBack = req.previsiousUrls[1];
|
|
64
|
+
return passport.authenticate("local", {
|
|
65
|
+
successRedirect: "/home",
|
|
66
|
+
failureRedirect: `${redirectBack ? redirectBack : "/login"}`,
|
|
67
|
+
failureFlash: true,
|
|
68
|
+
})(req, res, next);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
next(error);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
module.exports = new Auth();
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
exports.authenticated = (req, res, next) =>
|
|
2
|
-
req.isAuthenticated() ? next() : res.redirect("/login");
|
|
3
|
-
|
|
4
|
-
// exports.isLogIn = (req, res, next) =>
|
|
5
|
-
// req.isAuthenticated() ? res.redirect("/home") : next();
|
|
6
|
-
|
|
7
|
-
// exports.isLogIn
|
|
8
|
-
|
|
9
|
-
exports.protectedApi = (request, response, next) => {
|
|
10
|
-
let token;
|
|
11
|
-
if (
|
|
12
|
-
request.headers.authorization &&
|
|
13
|
-
request.headers.authorization.startsWith("Bearer")
|
|
14
|
-
) {
|
|
15
|
-
token = request.headers.authorization.split(" ")[1];
|
|
16
|
-
} else if (request.cookies.token) {
|
|
17
|
-
token = request.cookies.token;
|
|
18
|
-
} else if (request.header("x-auth-token")) {
|
|
19
|
-
token = request.header("x-auth-token");
|
|
20
|
-
}
|
|
21
|
-
if (!token) {
|
|
22
|
-
return response.json({ message: "Not authorize" }).status(403);
|
|
23
|
-
}
|
|
24
|
-
try {
|
|
25
|
-
request.id = jwt.verify(token, process.env.JWT_SECRET);
|
|
26
|
-
next();
|
|
27
|
-
} catch (err) {
|
|
28
|
-
return response.json({ message: "Not authorize" }).status(403);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
1
|
+
exports.authenticated = (req, res, next) =>
|
|
2
|
+
req.isAuthenticated() ? next() : res.redirect("/login");
|
|
3
|
+
|
|
4
|
+
// exports.isLogIn = (req, res, next) =>
|
|
5
|
+
// req.isAuthenticated() ? res.redirect("/home") : next();
|
|
6
|
+
|
|
7
|
+
// exports.isLogIn
|
|
8
|
+
|
|
9
|
+
exports.protectedApi = (request, response, next) => {
|
|
10
|
+
let token;
|
|
11
|
+
if (
|
|
12
|
+
request.headers.authorization &&
|
|
13
|
+
request.headers.authorization.startsWith("Bearer")
|
|
14
|
+
) {
|
|
15
|
+
token = request.headers.authorization.split(" ")[1];
|
|
16
|
+
} else if (request.cookies.token) {
|
|
17
|
+
token = request.cookies.token;
|
|
18
|
+
} else if (request.header("x-auth-token")) {
|
|
19
|
+
token = request.header("x-auth-token");
|
|
20
|
+
}
|
|
21
|
+
if (!token) {
|
|
22
|
+
return response.json({ message: "Not authorize" }).status(403);
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
request.id = jwt.verify(token, process.env.JWT_SECRET);
|
|
26
|
+
next();
|
|
27
|
+
} catch (err) {
|
|
28
|
+
return response.json({ message: "Not authorize" }).status(403);
|
|
29
|
+
}
|
|
30
|
+
};
|
package/src/Router/Router.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
const Util = require("../utils");
|
|
2
|
-
|
|
3
|
-
class Router {
|
|
4
|
-
constructor(app, prefix, middlewares, classController) {
|
|
5
|
-
this.app = app;
|
|
6
|
-
this.prefixUrl = prefix;
|
|
7
|
-
this.middlewares = middlewares;
|
|
8
|
-
this.classController = classController;
|
|
9
|
-
|
|
10
|
-
this.util = new Util(app, prefix, middlewares, classController);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
middleware(middlewares) {
|
|
14
|
-
this.middlewares = middlewares;
|
|
15
|
-
this.util.setGroupMiddleware(middlewares);
|
|
16
|
-
return this;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
get(path, callback) {
|
|
20
|
-
this.util.routeHelper("get", path, callback);
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
post(path, callback) {
|
|
24
|
-
this.util.routeHelper("post", path, callback);
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
patch(path, callback) {
|
|
28
|
-
this.util.routeHelper("patch", path, callback);
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
put(path, callback) {
|
|
32
|
-
this.util.routeHelper("put", path, callback);
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
delete(path, callback) {
|
|
36
|
-
this.util.routeHelper("delete", path, callback);
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
|
-
all() {}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
module.exports = Router;
|
|
1
|
+
const Util = require("../utils");
|
|
2
|
+
|
|
3
|
+
class Router {
|
|
4
|
+
constructor(app, prefix, middlewares, classController) {
|
|
5
|
+
this.app = app;
|
|
6
|
+
this.prefixUrl = prefix;
|
|
7
|
+
this.middlewares = middlewares;
|
|
8
|
+
this.classController = classController;
|
|
9
|
+
|
|
10
|
+
this.util = new Util(app, prefix, middlewares, classController);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
middleware(middlewares) {
|
|
14
|
+
this.middlewares = middlewares;
|
|
15
|
+
this.util.setGroupMiddleware(middlewares);
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
get(path, callback) {
|
|
20
|
+
this.util.routeHelper("get", path, callback);
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
post(path, callback) {
|
|
24
|
+
this.util.routeHelper("post", path, callback);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
patch(path, callback) {
|
|
28
|
+
this.util.routeHelper("patch", path, callback);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
put(path, callback) {
|
|
32
|
+
this.util.routeHelper("put", path, callback);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
delete(path, callback) {
|
|
36
|
+
this.util.routeHelper("delete", path, callback);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
all() {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
module.exports = Router;
|
package/src/Router/Routes.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const Router = require("./Router");
|
|
2
|
-
class Routes extends Router {
|
|
3
|
-
constructor(app) {
|
|
4
|
-
super(app);
|
|
5
|
-
}
|
|
6
|
-
prefix(url) {
|
|
7
|
-
this.prefixUrl = url;
|
|
8
|
-
return this;
|
|
9
|
-
}
|
|
10
|
-
controller(controller) {
|
|
11
|
-
this.classController = controller;
|
|
12
|
-
this.util.setGroupController(controller);
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
group(callback) {
|
|
16
|
-
callback(
|
|
17
|
-
new Router(
|
|
18
|
-
this.app,
|
|
19
|
-
this.prefixUrl,
|
|
20
|
-
this.middlewares,
|
|
21
|
-
this.classController
|
|
22
|
-
)
|
|
23
|
-
);
|
|
24
|
-
return this;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
module.exports = Routes;
|
|
1
|
+
const Router = require("./Router");
|
|
2
|
+
class Routes extends Router {
|
|
3
|
+
constructor(app) {
|
|
4
|
+
super(app);
|
|
5
|
+
}
|
|
6
|
+
prefix(url) {
|
|
7
|
+
this.prefixUrl = url;
|
|
8
|
+
return this;
|
|
9
|
+
}
|
|
10
|
+
controller(controller) {
|
|
11
|
+
this.classController = controller;
|
|
12
|
+
this.util.setGroupController(controller);
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
group(callback) {
|
|
16
|
+
callback(
|
|
17
|
+
new Router(
|
|
18
|
+
this.app,
|
|
19
|
+
this.prefixUrl,
|
|
20
|
+
this.middlewares,
|
|
21
|
+
this.classController
|
|
22
|
+
)
|
|
23
|
+
);
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = Routes;
|
package/src/app/index.js
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
const http = require("http");
|
|
2
|
-
const express = require("express");
|
|
3
|
-
const dotenv = require("dotenv");
|
|
4
|
-
const Middleware = require("../middlware");
|
|
5
|
-
const Routes = require("../Router/Routes");
|
|
6
|
-
const { rootPath } = require("../helpers");
|
|
7
|
-
const dbConnection = require("../dbConnection");
|
|
8
|
-
const ErrorHandler = require("../error/ErrorHandler");
|
|
9
|
-
const SocketIo = require("../socket");
|
|
10
|
-
const getCommands = require("../command-line-interface/getCommands");
|
|
11
|
-
|
|
12
|
-
class App {
|
|
13
|
-
constructor() {
|
|
14
|
-
dotenv.config();
|
|
15
|
-
this.express = express;
|
|
16
|
-
this.app = express();
|
|
17
|
-
new Middleware(express, this.app);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
commandLineArgv(argv) {
|
|
21
|
-
return getCommands(argv.slice(2));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
webRoute() {
|
|
25
|
-
return new Routes(this.app);
|
|
26
|
-
}
|
|
27
|
-
apiRoute() {
|
|
28
|
-
return new Routes(this.app);
|
|
29
|
-
}
|
|
30
|
-
server() {
|
|
31
|
-
const app = this.app;
|
|
32
|
-
const PORT = process.env.PORT || process.env.NODE_ENV;
|
|
33
|
-
const server = http.Server(app);
|
|
34
|
-
const appError = new ErrorHandler(app);
|
|
35
|
-
new SocketIo(server);
|
|
36
|
-
return {
|
|
37
|
-
run() {
|
|
38
|
-
dbConnection();
|
|
39
|
-
rootPath("routes/index");
|
|
40
|
-
// rootPath("routes/api");
|
|
41
|
-
|
|
42
|
-
appError.errorRoutesHandler();
|
|
43
|
-
app.use(appError.handler);
|
|
44
|
-
|
|
45
|
-
app.listen(PORT, () => {
|
|
46
|
-
console.log(`Server running on port ${PORT}`);
|
|
47
|
-
if (process.send) {
|
|
48
|
-
process.send("online");
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
process.on("unhandledRejection", (err) => {
|
|
53
|
-
console.log({ unhandledRejection: err.message });
|
|
54
|
-
process.exit(1);
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
server,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
module.exports = App;
|
|
1
|
+
const http = require("http");
|
|
2
|
+
const express = require("express");
|
|
3
|
+
const dotenv = require("dotenv");
|
|
4
|
+
const Middleware = require("../middlware");
|
|
5
|
+
const Routes = require("../Router/Routes");
|
|
6
|
+
const { rootPath } = require("../helpers");
|
|
7
|
+
const dbConnection = require("../dbConnection");
|
|
8
|
+
const ErrorHandler = require("../error/ErrorHandler");
|
|
9
|
+
const SocketIo = require("../socket");
|
|
10
|
+
const getCommands = require("../command-line-interface/getCommands");
|
|
11
|
+
|
|
12
|
+
class App {
|
|
13
|
+
constructor() {
|
|
14
|
+
dotenv.config();
|
|
15
|
+
this.express = express;
|
|
16
|
+
this.app = express();
|
|
17
|
+
new Middleware(express, this.app);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
commandLineArgv(argv) {
|
|
21
|
+
return getCommands(argv.slice(2));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
webRoute() {
|
|
25
|
+
return new Routes(this.app);
|
|
26
|
+
}
|
|
27
|
+
apiRoute() {
|
|
28
|
+
return new Routes(this.app);
|
|
29
|
+
}
|
|
30
|
+
server() {
|
|
31
|
+
const app = this.app;
|
|
32
|
+
const PORT = process.env.PORT || process.env.NODE_ENV;
|
|
33
|
+
const server = http.Server(app);
|
|
34
|
+
const appError = new ErrorHandler(app);
|
|
35
|
+
new SocketIo(server);
|
|
36
|
+
return {
|
|
37
|
+
run() {
|
|
38
|
+
dbConnection();
|
|
39
|
+
rootPath("routes/index");
|
|
40
|
+
// rootPath("routes/api");
|
|
41
|
+
|
|
42
|
+
appError.errorRoutesHandler();
|
|
43
|
+
app.use(appError.handler);
|
|
44
|
+
|
|
45
|
+
app.listen(PORT, () => {
|
|
46
|
+
console.log(`Server running on port ${PORT}`);
|
|
47
|
+
if (process.send) {
|
|
48
|
+
process.send("online");
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
process.on("unhandledRejection", (err) => {
|
|
53
|
+
console.log({ unhandledRejection: err.message });
|
|
54
|
+
process.exit(1);
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
server,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = App;
|