-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
35 lines (30 loc) · 954 Bytes
/
index.js
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
35
//imports
require("dotenv").config();
const express = require("express");
const app = express();
const cors = require("cors");
const mongoose = require("mongoose");
mongoose.set("strictQuery", false);
//connecting to database
const connect = async () => {
return mongoose.connect(process.env.DB_URL);
};
//use
app.use(express.json());
app.use(cors());
//routes imports
const productRoutes = require("./src/features/Products/productRoute");
const userRoutes = require("./src/features/Users/userRoute");
const orderRoutes = require("./src/features/Orders/orderRoute");
const cartRoutes = require("./src/features/Carts/cartRoute");
//routes
app.use("/product", productRoutes);
app.use("/user", userRoutes);
app.use("/order", orderRoutes);
app.use("/cart", cartRoutes);
//listening
app.listen(process.env.PORT, async () => {
await connect();
console.log(`listening on http://localhost:${process.env.PORT}`);
console.log(process.env.DB_URL);
});