-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
83 lines (57 loc) · 2.1 KB
/
index.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
75
76
77
78
79
80
81
82
83
const dotenv = require('dotenv')
dotenv.config(process.env.stripeApi)
const express = require('express')
const Sentry = require('@sentry/node')
const expressMongoDb = require('express-mongo-db')
const path = require('path')
const expressSession = require('cookie-session')
const cookieParser = require('cookie-parser')
const bodyParser = require('body-parser')
const logging = require('./modules/logging.js')
const passport = require('./modules/passport.js')
const app = express()
const port = 1406
// Load express middleware
app.use(expressMongoDb(process.env.dbURL))
app.use(express.json())
app.use(logging.pinoExpress)
app.use(bodyParser.urlencoded({ extended: true }))
app.use(express.urlencoded({ extended: true }))
app.use(expressSession(passport.session))
app.use(cookieParser())
app.use(passport.passport.initialize())
app.use(passport.passport.session())
passport.passport.serializeUser((user, done) => {
done(null, user)
})
passport.passport.deserializeUser((user, done) => {
done(null, user)
})
// Express routing
const coreInfoRoute = require('./routes/coreInfo')
const downloadRoute = require('./routes/download')
const depictionRoute = require('./routes/depictions')
const cyidaRoute = require('./routes/cyida')
const paymentHandlerRoute = require('./routes/paymentHandler')
const stripeRoute = require('./routes/stripe')
const authRoute = require('./routes/auth')
app.use('/', coreInfoRoute)
app.use('/', downloadRoute)
app.use('/', depictionRoute)
app.use('/', cyidaRoute)
app.use('/', paymentHandlerRoute)
app.use('/', stripeRoute)
app.use('/', authRoute)
app.use('/', express.static(path.join(__dirname, 'public')))
// Sentry setup
Sentry.init({ dsn: process.env.SENTRYDSN })
app.use(Sentry.Handlers.requestHandler())
// Open package manager when someone clicks "Add to package manager"
app.get('/cyidaRedirect', function mainHandler (req, res) {
res.set('location', 'cydia://url/https://cydia.saurik.com/api/share#?source=' +
process.env.URL)
res.status(302).send()
res.end()
})
app.use(Sentry.Handlers.errorHandler())
app.listen(port, () => logging.pino.info(`Listening on port ${port}`))