refactor: remove Temp
This was a very old way of migrating the history and is no longer needed. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
committed by
Philip Molares
parent
3f50054609
commit
0749c31100
@@ -5,10 +5,6 @@ const Router = require('express').Router
|
||||
const errors = require('../errors')
|
||||
const realtime = require('../realtime')
|
||||
const config = require('../config')
|
||||
const models = require('../models')
|
||||
const logger = require('../logger')
|
||||
|
||||
const { urlencodedParser } = require('./utils')
|
||||
|
||||
const statusRouter = module.exports = Router()
|
||||
|
||||
@@ -36,71 +32,6 @@ statusRouter.get('/status', function (req, res, next) {
|
||||
res.send(data)
|
||||
})
|
||||
})
|
||||
// get status
|
||||
statusRouter.get('/temp', function (req, res) {
|
||||
const host = req.get('host')
|
||||
if (config.allowOrigin.indexOf(host) === -1) {
|
||||
errors.errorForbidden(res)
|
||||
} else {
|
||||
const tempid = req.query.tempid
|
||||
if (!tempid) {
|
||||
errors.errorForbidden(res)
|
||||
} else {
|
||||
models.Temp.findOne({
|
||||
where: {
|
||||
id: tempid
|
||||
}
|
||||
}).then(function (temp) {
|
||||
if (!temp) {
|
||||
errors.errorNotFound(res)
|
||||
} else {
|
||||
res.header('Access-Control-Allow-Origin', '*')
|
||||
res.send({
|
||||
temp: temp.data
|
||||
})
|
||||
temp.destroy().catch(function (err) {
|
||||
if (err) {
|
||||
logger.error('remove temp failed: ' + err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}).catch(function (err) {
|
||||
logger.error(err)
|
||||
return errors.errorInternalError(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
// post status
|
||||
statusRouter.post('/temp', urlencodedParser, function (req, res) {
|
||||
const host = req.get('host')
|
||||
if (config.allowOrigin.indexOf(host) === -1) {
|
||||
errors.errorForbidden(res)
|
||||
} else {
|
||||
const data = req.body.data
|
||||
if (!data) {
|
||||
errors.errorForbidden(res)
|
||||
} else {
|
||||
logger.debug(`SERVER received temp from [${host}]: ${req.body.data}`)
|
||||
models.Temp.create({
|
||||
data
|
||||
}).then(function (temp) {
|
||||
if (temp) {
|
||||
res.header('Access-Control-Allow-Origin', '*')
|
||||
res.send({
|
||||
status: 'ok',
|
||||
id: temp.id
|
||||
})
|
||||
} else {
|
||||
errors.errorInternalError(res)
|
||||
}
|
||||
}).catch(function (err) {
|
||||
logger.error(err)
|
||||
return errors.errorInternalError(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
statusRouter.get('/config', function (req, res) {
|
||||
const data = {
|
||||
|
||||
Reference in New Issue
Block a user