-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
41 lines (31 loc) · 796 Bytes
/
server.js
File metadata and controls
41 lines (31 loc) · 796 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
import express from 'express'
import mongoose from 'mongoose';
import bodyParser from 'body-parser'
import router from './Routes/usser.js'
import contectRouter from './Routes/contectrout.js'
import { config } from 'dotenv';
const app=express();
app.use(bodyParser.json());
config({path:'.env'})
const port=process.env.PORT;
//Routes
app.get('/',(req,res)=>{
res.json({
name:'sunil',
msg:'hello this is sunil rawat'
})
})
//user router
app.use('/api/user',router)
//contect router
app.use('/api/contect',contectRouter)
mongoose.connect(
process.env.MONGO_URL,
{
dbName:'API_project',
}
).then(()=>console.log('mongodb is connected'))
.catch((err)=>console.log(err))
app.listen(port,()=>{
console.log(`port is runnuing at ${port}`);
})