tornado-relayer/src/server.js

37 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-09-28 04:28:34 +02:00
const express = require('express')
const status = require('./status')
const controller = require('./controller')
2020-09-28 04:28:34 +02:00
const { port } = require('../config')
const { version } = require('../package.json')
const app = express()
app.use(express.json())
// Log error to console but don't send it to the client to avoid leaking data
app.use((err, req, res, next) => {
if (err) {
console.error(err)
return res.sendStatus(500)
}
next()
})
// Add CORS headers
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', '*')
res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept')
next()
})
app.get('/', status.index)
app.get('/v1/status', status.status)
2020-10-01 15:08:33 +02:00
app.get('/v1/jobs/:id', status.getJob)
2020-09-28 04:28:34 +02:00
app.post('/v1/tornadoWithdraw', controller.tornadoWithdraw)
app.get('/status', status.status)
app.post('/relay', controller.tornadoWithdraw)
2020-10-01 08:30:50 +02:00
app.post('/v1/miningReward', controller.miningReward)
app.post('/v1/miningWithdraw', controller.miningWithdraw)
2020-09-28 04:28:34 +02:00
2020-10-01 06:01:02 +02:00
app.listen(port)
console.log(`Relayer ${version} started on port ${port}`)