-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (28 loc) · 808 Bytes
/
app.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
import express from 'express'
import cors from 'cors'
import cookieParser from 'cookie-parser'
import 'dotenv/config'
import { router as userRouter } from './routes/user.js'
import { router as auth } from './routes/auth.js'
import { connect } from './database/db.js'
const port = process.env.PORT
const app = express()
app.use(express.json())
app.use(cookieParser())
app.use(cors())
app.use(express.urlencoded({ extended: true }))
app.use('/user', userRouter)
app.use('/auth', auth)
app.get('/',(req,res)=>{
res.json("server")
})
;(async function () {
try {
await connect(process.env.MONGO_URI)
console.log('DB connected')
var port = process.env.PORT || 3001
app.listen(port, () => console.log(`Server started on port ${port}`))
} catch (err) {
console.log(err.message)
}
})()