mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-12 21:38:32 +03:00
404s for only source, only tab, and bad resource
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { version } from '../../package.json'
|
import { version } from '../../package.json'
|
||||||
import { Router } from 'express'
|
import { Router } from 'express'
|
||||||
|
import copy from '../copy/en'
|
||||||
|
|
||||||
export default ({ config, controller }) => {
|
export default ({ config, controller }) => {
|
||||||
let api = Router()
|
let api = Router()
|
||||||
@@ -30,11 +31,21 @@ export default ({ config, controller }) => {
|
|||||||
.retrieve(req.params.source, req.params.tab, req.params.resource)
|
.retrieve(req.params.source, req.params.tab, req.params.resource)
|
||||||
.then(data => res.json(data))
|
.then(data => res.json(data))
|
||||||
.catch(err =>
|
.catch(err =>
|
||||||
res.status(err.status || 501)
|
res.status(err.status || 404)
|
||||||
.send()
|
.send({ error: err })
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
api.get('/:source', (req, res) => {
|
||||||
|
res.status(404)
|
||||||
|
.send({ error: copy.errors.onlySource })
|
||||||
|
})
|
||||||
|
|
||||||
|
api.get('/:source/:tab', (req, res) => {
|
||||||
|
res.status(404)
|
||||||
|
.send({ error: copy.errors.onlyTab })
|
||||||
|
})
|
||||||
|
|
||||||
api.get('/update', (req, res) => {
|
api.get('/update', (req, res) => {
|
||||||
controller
|
controller
|
||||||
.update()
|
.update()
|
||||||
|
|||||||
6
src/copy/en.js
Normal file
6
src/copy/en.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
export default {
|
||||||
|
errors: {
|
||||||
|
onlySource: 'You cannot query a source directly. The URL needs to be in the format /:source/:tab/:resource.',
|
||||||
|
onlyTab: 'You cannot query a tab directly. The URL needs to be in the format /:source/:tab/:resource.'
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user