forked from mahdiyari/steemauto-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
82 lines (67 loc) · 2.79 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const express = require('express')
// const cors = require('cors')
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const hpp = require('hpp')
const app = express()
const helmet = require('helmet')
const isAuth = require('./middlewares/is_auth')
const curationTrail = require('./api/v1/dashboard/curation_trail')
const fanbase = require('./api/v1/dashboard/fanbase')
const schedulePost = require('./api/v1/dashboard/schedule_post')
const commentUpvote = require('./api/v1/dashboard/comment_upvote')
const claimReward = require('./api/v1/dashboard/claim_reward')
const loginMethod = require('./api/v1/login')
const logoutMethod = require('./api/v1/logout')
const dashboardFront = require('./api/v1.1/dashboard')
const curationTrailFront = require('./api/v1.1/curation-trail')
const publicCurationTrail = require('./api/public/curation-trail')
// Processing backend processes (private api)
const v2Function = require('./api/v2/function')
// Settings imports
const curationTrailSettings = require('./api/v1.1/settings/curation-trail')
// support json encoded bodies and encoded bodies
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: true }))
app.use(cookieParser())
// console.log('1');
app.use(function (req, res, next) {
/** TODO: add ENV var for development mode */
const dev = 1
res.header('Access-Control-Allow-Origin', 'http://localhost')
res.header('Access-Control-Allow-Credentials', true)
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, access_key')
next()
})
// console.log('2');
// var corsOptions = {
// origin: 'https://auto.steemdb.online',
// optionsSuccessStatus: 200, // some legacy browsers (IE11, various SmartTVs) choke on 204,
// methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
// credentials: true,
// preflightContinue: false,
// }
// app.use(cors(corsOptions))
app.use(helmet())
// more info: www.npmjs.com/package/hpp
app.use(hpp())
//hello
app.use('/api/v1/dashboard/curation-trail', curationTrail)
app.use('/api/v1/dashboard/fanbase', fanbase)
app.use('/api/v1/dashboard/schedule_post', schedulePost)
app.use('/api/v1/dashboard/comment_upvote', commentUpvote)
app.use('/api/v1/dashboard/claim_reward', claimReward)
app.use('/api/v1/login', loginMethod)
app.use('/api/v1/logout', logoutMethod)
app.use('/api/v1.1/dashboard', dashboardFront)
app.use('/api/v1.1/curation-trail', isAuth)
app.use('/api/v1.1/curation-trail', curationTrailFront)
app.use('/api/v2/function', v2Function)
app.use('/api/public/curation-trail', publicCurationTrail)
// All settings APIs
app.use('/api/v1.1/settings/curation-trail', curationTrailSettings)
const port = process.env.PORT || 3001
const host = process.env.HOST || '127.0.0.1'
app.listen(port, host, () => {
console.log(`Application started on ${host}:${port}`)
})