-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
29 lines (24 loc) · 863 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
const mongoose = require('mongoose');
const express = require('express');
const app = express();
const dotenv = require('dotenv');
const {transactionRouter} = require("./src/Routes/transactionRouter");
const {customerRouter} = require("./src/Routes/customerRouter");
app.use(express.json()) // for parsing application/json
app.use(express.urlencoded({ extended: true }))
app.use("/transaction", transactionRouter);
app.use("/customer", customerRouter);
main().then(response =>{
console.log("Connected to database!")
}).catch(err => {
console.log(err)
});
async function main() {
await mongoose.connect("mongodb://localhost:27017"); //connecting with (mongodb compass) database
}
app.listen(3030, function(err){
if(err)
console.log("Error in server setup")
else
console.log("Server listening on Port", 3030);
});