mirror of
https://github.com/bellingcat/datasheet-server.git
synced 2026-06-10 12:28:34 +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 { Router } from 'express'
|
||||
import copy from '../copy/en'
|
||||
|
||||
export default ({ config, controller }) => {
|
||||
let api = Router()
|
||||
@@ -30,11 +31,21 @@ export default ({ config, controller }) => {
|
||||
.retrieve(req.params.source, req.params.tab, req.params.resource)
|
||||
.then(data => res.json(data))
|
||||
.catch(err =>
|
||||
res.status(err.status || 501)
|
||||
.send()
|
||||
res.status(err.status || 404)
|
||||
.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) => {
|
||||
controller
|
||||
.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