Skip to content

Instantly share code, notes, and snippets.

@thebergamo
Created December 15, 2015 12:29
Show Gist options
  • Save thebergamo/a4815c768e5fe9149fb4 to your computer and use it in GitHub Desktop.
Save thebergamo/a4815c768e5fe9149fb4 to your computer and use it in GitHub Desktop.
Scoped Todo.js
'use strict';
const Controller = require('../controllers/todo');
const Validator = require('../validators/todo');
exports.register = (server, options, next) => {
// instantiate controller
const controller = new Controller(options.database);
server.bind(controller);
server.route([
{
method: 'GET',
path: '/todo/{id}',
config: {
handler: controller.get,
validate: Validator.get,
auth: {
scopes: ['admin', 'owner', 'friend']
}
}
},
{
method: 'PUT',
path: '/todo',
config: {
handler: controller.update,
validate: Validator.update,
auth: {
scopes: ['owner']
}
}
}
]);
next();
};
exports.register.attributes = {
name: 'todo-route',
version: '1.0.1'
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment