Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl committed Mar 12, 2019
2 parents 3495bcf + 89d60d1 commit 3d1083f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
1 change: 1 addition & 0 deletions app/api/settings/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default (app) => {
_id: Joi.string(),
key: Joi.string(),
label: Joi.string(),
rtl: Joi.boolean(),
default: Joi.boolean()
})
),
Expand Down
12 changes: 12 additions & 0 deletions app/api/settings/specs/__snapshots__/routes.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ Object {
],
"type": "string",
},
"rtl": Object {
"falsy": Array [
false,
],
"flags": Object {
"insensitive": true,
},
"truthy": Array [
true,
],
"type": "boolean",
},
},
"type": "object",
},
Expand Down
38 changes: 22 additions & 16 deletions app/react/ServerRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { I18NUtils, t, Translate } from 'app/I18N';
import JSONUtils from 'shared/JSONUtils';
import RouteHandler from 'app/App/RouteHandler';
import api from 'app/utils/api';
import settingsModel from 'api/settings';
import fs from 'fs';

import { getPropsFromRoute } from './utils';
Expand All @@ -20,7 +21,6 @@ import createStore from './store';
import translationsApi from '../api/i18n/translations';
import handleError from '../api/utils/handleError';


let assets = {};

function renderComponentWithRoot(Component, componentProps, initialData, user, isRedux = false, language) {
Expand Down Expand Up @@ -211,23 +211,29 @@ const allowedRoute = (user = {}, url) => {
};

function routeMatch(req, res, location, languages) {
createStore({ user: req.user });
settingsModel.get()
.then((settings) => {
createStore({
user: req.user,
settings: { collection: settings },
});

match({ routes: Routes, location }, (error, redirectLocation, renderProps) => {
if (redirectLocation) {
return handleRedirect(res, redirectLocation);
}
if (renderProps && renderProps.params.lang && !languages.includes(renderProps.params.lang)) {
return handle404(res);
}
if (error) {
return respondError(res, error);
}
if (renderProps) {
return handleRoute(res, renderProps, req);
}
match({ routes: Routes, location }, (error, redirectLocation, renderProps) => {
if (redirectLocation) {
return handleRedirect(res, redirectLocation);
}
if (renderProps && renderProps.params.lang && !languages.includes(renderProps.params.lang)) {
return handle404(res);
}
if (error) {
return respondError(res, error);
}
if (renderProps) {
return handleRoute(res, renderProps, req);
}

return handle404(res);
return handle404(res);
});
});
}

Expand Down

0 comments on commit 3d1083f

Please sign in to comment.