Add transaction versioning, tx cancellation (#79)

This commit is contained in:
Josh Harvey 2017-08-29 16:08:06 +03:00 committed by GitHub
parent 4a97535dec
commit 500edcf279
15 changed files with 2223 additions and 1468 deletions

View file

@ -15,6 +15,7 @@ const plugins = require('./plugins')
const helpers = require('./route-helpers')
const poller = require('./poller')
const Tx = require('./tx')
const E = require('./error')
const argv = require('minimist')(process.argv.slice(2))
@ -108,6 +109,10 @@ function postTx (req, res, next) {
return res.json(tx)
})
.catch(err => {
if (err instanceof E.StaleTxError) return res.status(404).json({})
throw err
})
.catch(next)
}
@ -270,7 +275,11 @@ app.get('/tx/:id', getTx)
app.get('/tx', getPhoneTx)
app.use(errorHandler)
app.use((req, res) => res.status(404).json({error: 'No such route'}))
app.use((req, res) => {
console.log('DEBUG98')
console.log(req.route)
res.status(404).json({error: 'No such route'})
})
localApp.get('/pid', (req, res) => {
const deviceId = req.query.device_id