-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
35 lines (29 loc) · 856 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
import express from "express";
import dotenv from 'dotenv';
import bodyParser from "body-parser";
import cors from 'cors';
import mongoose from "mongoose";
import userRoutes from "./routers/userResistrationRoutes/useroutes.js"
import paymentgatewayroutes from "./routers/paymentgateway/paymentgateway.js"
const app=express();
app.use(bodyParser.json());
app.use(cors());
dotenv.config();
const connect=async()=>{
try {
await mongoose.connect(process.env.MONGO)
console.log("connected to Database")
} catch (error) {
console.log(error)
}
}
mongoose.connection.on("disconnect",()=>{
console.log("MongoDB disconnected")
})
// all routes here
app.use("/v1/api/user/",userRoutes)
app.use("/v1/api/paymentgateway/",paymentgatewayroutes)
app.listen(9005,()=>{
connect()
console.log("Connected to Backend");
})