-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.ts
39 lines (34 loc) · 1.09 KB
/
app.ts
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
import express, {Application} from 'express'
import {config} from 'dotenv'
import swaggerDocs from './docs/swagger'
import connectdb from './db/database'
import authRoutes from './routes/authroutes'
import profileRoutes from './routes/profileroutes'
import passport from 'passport'
import session from 'express-session'
const app: Application = express()
import './config/googlePassport.config'
app.use(
session({
secret: `process.env.SECRET`,
resave: false,
saveUninitialized: true,
}),
)
app.use(passport.initialize())
app.use(passport.session())
config()
//middleware section
app.use(express.json())
app.use(authRoutes)
app.use(profileRoutes)
console.log('Hello Team emma This backend API')
const PORT = process.env.PORT || 3000
app.get('/', (req, res) => res.send('Hello, use "/docs" to view the swagger docs'))
/*called the database connection below */
connectdb().then(() => {
app.listen(PORT, () => console.log(`Server started on port ${PORT}`))
swaggerDocs(app)
// change this to just port in case someone is listening from 127.0.0.1 instead of localhost
})
export default app