-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (29 loc) · 917 Bytes
/
Copy pathindex.js
File metadata and controls
34 lines (29 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// import environmental variables from our variables.env file
require("dotenv").config();
const app = require("./app");
const db = require("./models/connection");
// this matches all routes and all methods
app.use((req, res, next) => {
res.status(404).send({
status: 404,
error: "Not found",
});
});
// error handler middleware
app.use((error, req, res, next) => {
res.status(error.status || 500).send({
error: {
status: error.status || 500,
message: error.message || "Internal Server Error",
},
});
});
// db.sequelize.sync({}).then(() => {func}).catch((err) => console.log(`Connection failed: ${err}`));
app.set("port", process.env.PORT || 8600);
const server = app.listen(app.get("port"), () => {
console.debug(
`Connected & Express is Serving on → PORT http://127.0.0.1:${
server.address().port
}`
);
});