-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
23 lines (20 loc) · 709 Bytes
/
index.js
File metadata and controls
23 lines (20 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import app from "./config/express-conf.mjs";
import config from "./config/env/index.mjs";
import mongoose from "mongoose";
import bodyParser from "body-parser";
mongoose.connect(config.default.db);
mongoose.connection.on("error", () => {
throw new Error(`unable to connect to database: ${config.default.db}`);
});
mongoose.connection.on("connected", () => {
console.log(`Connected to database: ${config.default.db}`);
});
if (config.env === "development") {
mongoose.set("debug", true);
}
app.listen(config.default.port, () => {
console.log(
`API Server started and listening on port ${config.default.port} with a ${process.env.NODE_ENV} environment`
);
});
export default app;