forked from cindymit/AJEC-recycle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
26 lines (21 loc) · 653 Bytes
/
Copy pathserver.js
File metadata and controls
26 lines (21 loc) · 653 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
import db from "./db/connection.js";
import routes from "./routes/index.js";
import express from "express";
import logger from "morgan";
import cors from "cors";
const app = express();
const PORT = process.env.PORT || 3001;
app.use(express.json());
app.use(cors());
app.use(logger("dev"));
app.use("/api", routes);
db.on("connected", () => {
console.log("Connected to MongoDB!");
app.listen(PORT, () =>
process.env.NODE_ENV === "production"
? console.log(`Express server running in production on port ${PORT}\n\n`)
: console.log(
`Express server running in development on: http://localhost:${PORT}`
)
);
});