Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
fix: only expose error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKohler committed Oct 27, 2021
1 parent 1937f99 commit 2114b38
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 38 deletions.
6 changes: 3 additions & 3 deletions server/routes/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ router.get('/', (req, res) => {
} catch (error) {
debug('GET_LANGUAGES_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_LANGUAGES_ERROR' });
}
});

Expand All @@ -29,7 +29,7 @@ router.get('/missing', async (req, res) => {
} catch (error) {
debug('GET_MISSING_LANGUAGES_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_MISSING_LANGUAGES_ERROR' });
}
});

Expand All @@ -41,7 +41,7 @@ router.get('/additional', async (req, res) => {
} catch (error) {
debug('GET_ADDITIONAL_LANGUAGES_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_ADDITIONAL_LANGUAGES_ERROR' });
}
});

Expand Down
22 changes: 11 additions & 11 deletions server/routes/sentences.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ router.get('/review', async (req, res) => {
} catch (error) {
debug('GET_SENTENCES_FOR_REVIEW_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_SENTENCES_FOR_REVIEW_ERROR' });
}
});

Expand All @@ -33,7 +33,7 @@ router.get('/rejected', async (req, res) => {
.catch((error) => {
debug('GET_REJECTED_SENTENCES_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_REJECTED_SENTENCES_ERROR' });
});
});

Expand All @@ -45,7 +45,7 @@ router.get('/my', async (req, res) => {
.catch((error) => {
debug('GET_MY_SENTENCES_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_MY_SENTENCES_ERROR' });
});
});

Expand All @@ -58,7 +58,7 @@ router.post('/delete', async (req, res) => {
.catch((error) => {
debug('DELETE_SENTENCES_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'DELETE_SENTENCES_ERROR' });
});
});

Expand All @@ -73,7 +73,7 @@ router.put('/', async (req, res) => {
} catch (error) {
debug('CREATE_SENTENCES_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'CREATE_SENTENCES_ERROR' });
}
});

Expand All @@ -91,7 +91,7 @@ router.get('/:locale', async (req, res) => {
} catch (error) {
debug('GET_SENTENCES_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_SENTENCES_ERROR' });
}
});

Expand All @@ -107,7 +107,7 @@ router.get('/text/:locale', async (req, res) => {
} catch (error) {
debug('GET_SENTENCES_TEXT_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_SENTENCES_TEXT_ERROR' });
}
});

Expand All @@ -123,7 +123,7 @@ router.get('/text/approved/:locale', async (req, res) => {
} catch (error) {
debug('GET_APPROVED_SENTENCES_TEXT_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_APPROVED_SENTENCES_TEXT_ERROR' });
}
});

Expand All @@ -139,7 +139,7 @@ router.get('/text/undecided/:locale', async (req, res) => {
} catch (error) {
debug('GET_UNDECIDED_SENTENCES_TEXT_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_UNDECIDED_SENTENCES_TEXT_ERROR' });
}
});

Expand All @@ -155,7 +155,7 @@ router.get('/text/rejected/:locale', async (req, res) => {
} catch (error) {
debug('GET_UNDECIDED_SENTENCES_TEXT_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_UNDECIDED_SENTENCES_TEXT_ERROR' });
}
});

Expand All @@ -171,7 +171,7 @@ router.get('/sources/:locale', async (req, res) => {
} catch (error) {
debug('GET_SENTENCES_SOURCES_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_SENTENCES_SOURCES_ERROR' });
}
});

Expand Down
4 changes: 2 additions & 2 deletions server/routes/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ router.get('/', async (req, res) => {
} catch (error) {
debug('GET_STATS_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_STATS_ERROR' });
}
});

Expand All @@ -53,7 +53,7 @@ router.get('/general/:localeId', async (req, res) => {
} catch (error) {
debug('GET_STATS_FOR_LANGUAGE_ERROR', error);
res.status(STATUS_ERROR);
res.json({ message: error.message });
res.json({ message: 'GET_STATS_FOR_LANGUAGE_ERROR' });
}
});

Expand Down
6 changes: 3 additions & 3 deletions server/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ router.post('/settings', async (req, res) => {
res.json({});
} catch (error) {
res.status(500);
res.json({ message: error.message });
res.json({ message: 'UPDATE_SETTINGS_ERROR' });
}
});

Expand All @@ -63,7 +63,7 @@ router.put('/languages', async (req, res) => {
res.json(updatedLanguages);
} catch (error) {
res.status(500);
res.json({ message: error.message });
res.json({ message: 'ADD_LANGUAGE_ERROR' });
}
});

Expand All @@ -82,7 +82,7 @@ router.delete('/languages/:language', async (req, res) => {
res.json(updatedLanguages);
} catch (error) {
res.status(500);
res.json({ message: error.message });
res.json({ message: 'REMOVE_LANGUAGE_ERROR' });
}
});

Expand Down
6 changes: 3 additions & 3 deletions server/tests/routes/languages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test.serial('should pass on error message', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_LANGUAGES_ERROR',
});
});

Expand All @@ -64,7 +64,7 @@ test.serial('should pass on missing language error message', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_MISSING_LANGUAGES_ERROR',
});
});

Expand All @@ -84,6 +84,6 @@ test.serial('should pass on additional language error message', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_ADDITIONAL_LANGUAGES_ERROR',
});
});
22 changes: 11 additions & 11 deletions server/tests/routes/sentences.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test.serial('getting sentences should pass on error message', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_SENTENCES_ERROR',
});
});

Expand Down Expand Up @@ -130,7 +130,7 @@ test.serial('should pass error when getting sentences text only', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_SENTENCES_TEXT_ERROR',
});
});

Expand All @@ -151,7 +151,7 @@ test.serial('should pass error when getting approved sentences text only', async

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_APPROVED_SENTENCES_TEXT_ERROR',
});
});

Expand All @@ -172,7 +172,7 @@ test.serial('should pass error when getting undecided sentences text only', asyn

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_UNDECIDED_SENTENCES_TEXT_ERROR',
});
});

Expand All @@ -193,7 +193,7 @@ test.serial('should pass error when getting rejected sentences text only', async

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_UNDECIDED_SENTENCES_TEXT_ERROR',
});
});

Expand All @@ -214,7 +214,7 @@ test.serial('should pass error when getting list of sources', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_SENTENCES_SOURCES_ERROR',
});
});

Expand All @@ -235,7 +235,7 @@ test.serial('getting review sentences should pass on error message', async (t) =

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_SENTENCES_FOR_REVIEW_ERROR',
});
});

Expand All @@ -256,7 +256,7 @@ test.serial('getting rejected sentences should pass on error message', async (t)

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_REJECTED_SENTENCES_ERROR',
});
});

Expand All @@ -277,7 +277,7 @@ test.serial('getting my sentences should pass on error message', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_MY_SENTENCES_ERROR',
});
});

Expand All @@ -300,7 +300,7 @@ test.serial('deleting sentences should pass on error message', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'DELETE_SENTENCES_ERROR',
});
});

Expand All @@ -327,6 +327,6 @@ test.serial('adding sentences should pass on error message', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'CREATE_SENTENCES_ERROR',
});
});
4 changes: 2 additions & 2 deletions server/tests/routes/stats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ test.serial('should pass on error message', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_STATS_ERROR',
});
});

Expand All @@ -102,6 +102,6 @@ test.serial('should pass on error message when querying general stats', async (t

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'GET_STATS_FOR_LANGUAGE_ERROR',
});
});
6 changes: 3 additions & 3 deletions server/tests/routes/users.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ test.serial('updateSetting: should pass error', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'UPDATE_SETTINGS_ERROR',
});
});

Expand All @@ -63,7 +63,7 @@ test.serial('addLanguage: should pass error', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'ADD_LANGUAGE_ERROR',
});
});

Expand All @@ -84,6 +84,6 @@ test.serial('removeLanguage: should pass error', async (t) => {

t.is(response.status, 500);
t.deepEqual(response.body, {
message: 'nope',
message: 'REMOVE_LANGUAGE_ERROR',
});
});

0 comments on commit 2114b38

Please sign in to comment.