Skip to content

Commit

Permalink
refactor(remountable-routes): rename src/routes/accounts.js to `src…
Browse files Browse the repository at this point in the history
…/routes/user.js` to better match the route prefix
  • Loading branch information
julianlam committed Feb 11, 2021
1 parent bc68e99 commit 1f28713
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const helpers = require('./helpers');
const { setupPageRoute } = helpers;

const _mounts = {
account: require('./accounts'),
user: require('./user'),
meta: require('./meta'),
api: require('./api'),
admin: require('./admin'),
Expand Down Expand Up @@ -81,10 +81,10 @@ _mounts.category = (app, name, middleware, controllers) => {
setupPageRoute(app, `/${name}/:category_id/:slug?`, middleware, [], controllers.category.get);
};

_mounts.user = (app, middleware, controllers) => {
_mounts.users = (app, name, middleware, controllers) => {
const middlewares = [middleware.canViewUsers];

setupPageRoute(app, '/users', middleware, middlewares, controllers.users.index);
setupPageRoute(app, `/${name}`, middleware, middlewares, controllers.users.index);
};

_mounts.group = (app, middleware, controllers) => {
Expand Down Expand Up @@ -131,14 +131,12 @@ async function addCoreRoutes(app, router, middleware) {
_mounts.mod(router, middleware, controllers);
_mounts.globalMod(router, middleware, controllers);
_mounts.tag(router, middleware, controllers);
_mounts.user(router, middleware, controllers);
_mounts.group(router, middleware, controllers);

// Allow plugins/themes to mount some routes elsewhere
const remountable = ['admin', 'category', 'topic', 'post', 'account'];
const mountHash = { // some mounts are named differently for organizational purposes
account: 'user',
};
const remountable = ['admin', 'category', 'topic', 'post', 'users', 'user'];
const mountHash = {}; // if a mount is named differently for organizational purposes, add the change here

await Promise.all(remountable.map(async (mount) => {
const method = mount;
const original = mountHash[mount] || mount;
Expand Down
File renamed without changes.

0 comments on commit 1f28713

Please sign in to comment.