mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 06:34:39 -04:00
Move note actions to their own file.
Because of circular import problems, this commit also moves the error messages from response.js to errors.js Signed-off-by: David Mehren <dmehren1@gmail.com>
This commit is contained in:
parent
20a67e3446
commit
f78540c3fb
16 changed files with 410 additions and 390 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
const Router = require('express').Router
|
||||
|
||||
const response = require('../response')
|
||||
const errors = require('../errors')
|
||||
const realtime = require('../realtime')
|
||||
const config = require('../config')
|
||||
const models = require('../models')
|
||||
|
@ -27,11 +27,11 @@ statusRouter.get('/status', function (req, res, next) {
|
|||
statusRouter.get('/temp', function (req, res) {
|
||||
var host = req.get('host')
|
||||
if (config.allowOrigin.indexOf(host) === -1) {
|
||||
response.errorForbidden(res)
|
||||
errors.errorForbidden(res)
|
||||
} else {
|
||||
var tempid = req.query.tempid
|
||||
if (!tempid) {
|
||||
response.errorForbidden(res)
|
||||
errors.errorForbidden(res)
|
||||
} else {
|
||||
models.Temp.findOne({
|
||||
where: {
|
||||
|
@ -39,7 +39,7 @@ statusRouter.get('/temp', function (req, res) {
|
|||
}
|
||||
}).then(function (temp) {
|
||||
if (!temp) {
|
||||
response.errorNotFound(res)
|
||||
errors.errorNotFound(res)
|
||||
} else {
|
||||
res.header('Access-Control-Allow-Origin', '*')
|
||||
res.send({
|
||||
|
@ -53,7 +53,7 @@ statusRouter.get('/temp', function (req, res) {
|
|||
}
|
||||
}).catch(function (err) {
|
||||
logger.error(err)
|
||||
return response.errorInternalError(res)
|
||||
return errors.errorInternalError(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -62,11 +62,11 @@ statusRouter.get('/temp', function (req, res) {
|
|||
statusRouter.post('/temp', urlencodedParser, function (req, res) {
|
||||
var host = req.get('host')
|
||||
if (config.allowOrigin.indexOf(host) === -1) {
|
||||
response.errorForbidden(res)
|
||||
errors.errorForbidden(res)
|
||||
} else {
|
||||
var data = req.body.data
|
||||
if (!data) {
|
||||
response.errorForbidden(res)
|
||||
errors.errorForbidden(res)
|
||||
} else {
|
||||
logger.debug(`SERVER received temp from [${host}]: ${req.body.data}`)
|
||||
models.Temp.create({
|
||||
|
@ -79,11 +79,11 @@ statusRouter.post('/temp', urlencodedParser, function (req, res) {
|
|||
id: temp.id
|
||||
})
|
||||
} else {
|
||||
response.errorInternalError(res)
|
||||
errors.errorInternalError(res)
|
||||
}
|
||||
}).catch(function (err) {
|
||||
logger.error(err)
|
||||
return response.errorInternalError(res)
|
||||
return errors.errorInternalError(res)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue