Skip to content

Commit

Permalink
Merge pull request #377 from ParsePlatform/nlutsenko.router.roles
Browse files Browse the repository at this point in the history
Refactor and deduplicate RolesRouter, fix missing query on /roles.
  • Loading branch information
nlutsenko committed Feb 12, 2016
2 parents 6c6021a + 62e671d commit 9dfc013
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 49 deletions.
43 changes: 43 additions & 0 deletions src/Routers/RolesRouter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

import ClassesRouter from './ClassesRouter';
import PromiseRouter from '../PromiseRouter';
import rest from '../rest';

export class RolesRouter extends ClassesRouter {
handleFind(req) {
req.params.className = '_Role';
return super.handleFind(req);
}

handleGet(req) {
req.params.className = '_Role';
return super.handleGet(req);
}

handleCreate(req) {
req.params.className = '_Role';
return super.handleCreate(req);
}

handleUpdate(req) {
req.params.className = '_Role';
return super.handleUpdate(req);
}

handleDelete(req) {
req.params.className = '_Role';
return super.handleDelete(req);
}

getExpressRouter() {
let router = new PromiseRouter();
router.route('GET','/roles', req => { return this.handleFind(req); });
router.route('GET','/roles/:objectId', req => { return this.handleGet(req); });
router.route('POST','/roles', req => { return this.handleCreate(req); });
router.route('PUT','/roles/:objectId', req => { return this.handleUpdate(req); });
router.route('DELETE','/roles/:objectId', req => { return this.handleDelete(req); });
return router;
}
}

export default RolesRouter;
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { ClassesRouter } from './Routers/ClassesRouter';
import { InstallationsRouter } from './Routers/InstallationsRouter';
import { UsersRouter } from './Routers/UsersRouter';
import { SessionsRouter } from './Routers/SessionsRouter';
import { RolesRouter } from './Routers/RolesRouter';

// Mutate the Parse object to add the Cloud Code handlers
addParseCloud();
Expand Down Expand Up @@ -133,7 +134,7 @@ function ParseServer(args) {
new ClassesRouter().getExpressRouter(),
new UsersRouter().getExpressRouter(),
new SessionsRouter().getExpressRouter(),
require('./roles'),
new RolesRouter().getExpressRouter(),
require('./analytics'),
new InstallationsRouter().getExpressRouter(),
require('./functions'),
Expand Down
48 changes: 0 additions & 48 deletions src/roles.js

This file was deleted.

0 comments on commit 9dfc013

Please sign in to comment.