-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (27 loc) · 829 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
const express = require("express")
const connection = require("./config/db")
const {userRouter}=require("./routes/user.route")
const cityRouter=require("./routes/city.routes")
const redisClient=require("./helpers/redis")
const logger=require("./middlewares/logger")
require("dotenv").config()
const PORT = process.env.PORT||8880
const app=express()
app.use(express.json())
app.get("/",async(req,res)=>{
res.send(await redisClient.get("name"))
})
app,use("/api/user",userRouter)
app.use("/api/weather",cityRouter)
app.listen(PORT,async()=>{
try{
await connection()
console.log("connected to db")
logger.log("info","Db connect")
}
catch(err){
console.log(err.message)
logger.log("error","db connect fail")
}
console.log("server running @",PORT)
})