-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.js
48 lines (40 loc) · 1.3 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require('dotenv').config();
// Express
const express = require('express')
const path = require('path')
const bodyParser = require('body-parser')
const logger = require('morgan')
var cors = require('cors')
// Auth
const passport = require('passport')
const passportSetup = require('./config/passport-setup')
const cookieSession = require('cookie-session')
const cookieParser = require('cookie-parser')
// Routers
const authRouter = require('./src/routes/auth')
const usersRouter = require('./src/routes/users')
const postsRouter = require('./src/routes/posts')
const tagsRouter = require('./src/routes/tags')
const posts_tagsRouter = require('./src/routes/posts_tags')
const tags_postsRouter = require('./src/routes/tags_posts')
const post_idRouter = require('./src/routes/post_id')
// Express
var app = express()
app.use(express.json())
app.use(bodyParser.json())
app.use(express.static(path.join(__dirname, 'public')))
// cors headers
app.use(cors())
app.use(logger('dev'))
app.use(cookieParser())
app.use(passport.initialize())
app.use(passport.session())
// Routes
app.use('/auth', authRouter)
app.use('/users', usersRouter)
app.use('/posts', postsRouter)
app.use('/tags', tagsRouter)
app.use('/posts_tags', posts_tagsRouter)
app.use('/tags_posts', tags_postsRouter)
app.use('/post_id', post_idRouter)
module.exports = app