forked from worknenjoy/gitpay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
64 lines (52 loc) · 1.61 KB
/
server.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
const express = require('express')
const sslRedirect = require('heroku-ssl-redirect')
const app = express()
const session = require('express-session')
const compression = require('compression')
const bodyParser = require('body-parser')
require('./models')
const passport = require('passport')
require('./config/passport')
const load = require('./modules/app')
const i18n = require('i18n')
const xFrameOptions = require('x-frame-options')
const { dailyJob } = require('./cron')
if (process.env.NODE_ENV !== 'production') {
const cors = require('cors')
app.use(cors())
} else {
app.use(sslRedirect())
}
app.use(xFrameOptions())
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(session({
secret: process.env.SECRET_PHRASE,
saveUninitialized: true,
resave: true
}))
i18n.configure({
directory: process.env.NODE_ENV !== 'production' ? `${__dirname}/locales` : `${__dirname}/locales/result`,
locales: process.env.NODE_ENV !== 'production' ? ['en'] : ['en', 'br'],
defaultLocale: 'en',
updateFiles: false
})
app.use(i18n.init)
dailyJob.start()
// weeklyJob.start()
// weeklyJobLatest.start()
// weeklyJobBountiesClosedNotPaid.start();
app.use(passport.initialize())
app.use(passport.session())
app.set('port', (process.env.PORT || 3000))
app.use(compression())
app.use(express.static(`${__dirname}/frontend/public/`))
app.get('/recruitment', (req, res) => {
res.redirect('https://gitpay.me/#/recruitment')
})
load.init(app)
app.listen(app.get('port'), () => {
// eslint-disable-next-line no-console
console.log('Node app is running on port', app.get('port'))
})
module.exports = app