-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
46 lines (34 loc) · 1017 Bytes
/
server.js
File metadata and controls
46 lines (34 loc) · 1017 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
44
45
46
const express = require('express')
const cors = require('cors')
const PORT = process.env.PORT || 3001
const AppRouter = require('./routes/appRouter')
const db = require('./db')
const logger = require('morgan')
const session = require('express-session')
const cookieParser = require('cookie-parser')
const path = require('path')
const passport = require('passport')
const app = express()
app.use(cors({
origin: 'http://localhost:5173'
}))
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.use(cookieParser())
app.use(express.static(path.join(__dirname, 'public')))
app.use(session({
secret: process.env.SECRET,
resave: false,
saveUninitialized: true
}))
app.use(passport.initialize())
app.use(passport.session())
app.use(function (req, res, next) {
res.locals.user = req.user
next()
})
app.get('/', (req, res) => {
res.send(`Hello world`)
})
app.use('/api', AppRouter)
app.listen(PORT, () => console.log(`Server running on ${PORT}`))