forked from WilliamTuominiemi/NFT-Art-Platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
74 lines (57 loc) · 1.59 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const express = require('express')
const bodyParser = require('body-parser')
const mongoose = require('mongoose')
const multer = require('multer')
const dotenv = require('dotenv')
const passport = require('passport')
const session = require('express-session')
const MongoStore = require('connect-mongo')(session)
const fs = require('fs')
const path = require('path')
const Drawing = require('./models/image')
const auth = require('./routes/auth')
const index = require('./routes/index')
const trade = require('./routes/trade')
const settings = require('./routes/settings')
const connectDB = require('./config/db')
// Load config
dotenv.config({ path: './config/.env' })
// Passport config
require('./config/passport')(passport)
// Express app
const app = express()
// Port number
const port = process.env.PORT || '3000'
// Connect to MongoDB
connectDB()
// Register view engine
app.set('view engine', 'ejs')
app.use(express.static('public'))
// Sessions
app.use(
session({
secret: 'keyboard cat',
resave: false,
saveUninitialized: false,
store: new MongoStore({ mongooseConnection: mongoose.connection }),
})
)
// Passport and express middleware
app.use(passport.initialize())
app.use(passport.session())
app.use(express.urlencoded())
app.use(
bodyParser.urlencoded({
limit: '50mb',
extended: true,
})
)
app.use(bodyParser.json({ limit: '50mb' }))
app.use('/', index)
app.use('/auth', auth)
app.use('/trade', trade)
app.use('/settings', settings)
app.listen(port, (err) => {
if (err) throw err
console.log('Server listening on port', port)
})