-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (25 loc) · 895 Bytes
/
index.js
File metadata and controls
43 lines (25 loc) · 895 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
34
35
36
37
38
39
40
41
42
43
const express = require('express');
const noteRout = require('./routes/noteRoute');
const userRoutes = require('./routes/userRoutes');
const mongoose = require('mongoose');
const { json } = require('body-parser');
const auth = require('./Middleware/auth');
const cors = require('cors')
const dotenv = require('dotenv')
const dbURL ='mongodb+srv://indra16:9826391787@cluster0.3vigtan.mongodb.net/?retryWrites=true&w=majority';
const app= express();
app.use(cors());
app.use(json());
dotenv.config();
app.use("/user",userRoutes);
app.use("/notes",noteRout);
const PORT = process.env.PORT || 5000;
mongoose.connect(dbURL).then(()=>{
// after connection start the app
app.listen(PORT,()=>{
console.log('lisen'+" "+PORT);
});
})
.catch((error) => {
console.log(error);
})