-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
33 lines (28 loc) · 756 Bytes
/
server.js
File metadata and controls
33 lines (28 loc) · 756 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
import express from "express";
import "dotenv/config";
import bodyParser from "body-parser";
import mongoose from "mongoose";
import index from "./src/Routes/index";
import product from "./src/Routes/ProductRoutes";
import cors from "cors"
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.use("/api",index);
app.use("/",product);
//DATABASE CONFIGURATION
const database = process.env.DATABASE;
mongoose
.connect(database, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
console.log("Database connected successfully!");
});
//server configuration
const port = process.env.PORT || 3001;
app.listen(port, () => {
console.log(`server is running on port ${port}`);
});
export default app;