diff --git a/src/api/index.js b/src/api/index.js index 06d961e..0fcfe04 100755 --- a/src/api/index.js +++ b/src/api/index.js @@ -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() diff --git a/src/copy/en.js b/src/copy/en.js new file mode 100644 index 0000000..d20da49 --- /dev/null +++ b/src/copy/en.js @@ -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.' + } +}