moving developer-only strings to api/common messages (#10258)

* move translatable string to apiMessages

* use apiMessages instead of res.t for groupIdRequired / keepOrRemove

* move pageMustBeNumber to apiMessages

* change apimessages

* move missingKeyParam to apiMessages

* move more strings to apiMessages

* fix lint

* revert lodash imports to fix tests

* fix webhook test

* fix test

* rollback key change of `keepOrRemove`

* remove unneeded `req.language` param

*  extract more messages from i18n

* add missing `missingTypeParam` message

* Split api- and commonMessages

* fix test

* fix sanity

* merge messages to an object, rename commonMessage to errorMessage

* apiMessages -> apiError, commonMessages -> errorMessage, extract messages to separate objects

* fix test

* module.exports
This commit is contained in:
negue
2018-05-04 23:00:19 +02:00
committed by Sabe Jones
parent f226b5da07
commit c26696a9eb
65 changed files with 254 additions and 185 deletions

View File

@@ -8,8 +8,7 @@ import {
import {
BadRequest,
} from '../../../libs/errors';
const i18n = shared.i18n;
import apiError from '../../../libs/apiError';
let api = {};
@@ -54,8 +53,8 @@ api.checkoutSuccess = {
let gift = req.session.gift ? JSON.parse(req.session.gift) : undefined;
delete req.session.gift;
if (!paymentId) throw new BadRequest(i18n.t('missingPaymentId'));
if (!customerId) throw new BadRequest(i18n.t('missingCustomerId'));
if (!paymentId) throw new BadRequest(apiError('missingPaymentId'));
if (!customerId) throw new BadRequest(apiError('missingCustomerId'));
await paypalPayments.checkoutSuccess({user, gift, paymentId, customerId});
@@ -78,7 +77,7 @@ api.subscribe = {
url: '/paypal/subscribe',
middlewares: [authWithUrl],
async handler (req, res) {
if (!req.query.sub) throw new BadRequest(i18n.t('missingSubKey'));
if (!req.query.sub) throw new BadRequest(apiError('missingSubKey'));
let sub = shared.content.subscriptionBlocks[req.query.sub];
let coupon = req.query.coupon;
@@ -109,7 +108,7 @@ api.subscribeSuccess = {
async handler (req, res) {
let user = res.locals.user;
if (!req.session.paypalBlock) throw new BadRequest(i18n.t('missingPaypalBlock'));
if (!req.session.paypalBlock) throw new BadRequest(apiError('missingPaypalBlock'));
let block = shared.content.subscriptionBlocks[req.session.paypalBlock];
let groupId = req.session.groupId;