This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // [GET] /category | |
| function list (request, reply) { | |
| this.model | |
| .scope({ | |
| method: ['user', request.auth.credentials.id] | |
| }) | |
| .findAndCountAll({ | |
| attributes: ['id', 'description'], | |
| order: 'description', | |
| offset: request.offset, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var Path = require('path'); | |
| var Request = require('request-promise'); | |
| var Webpack = require('webpack'); | |
| var _ = require('lodash'); | |
| var LIST_MODULES_URL = 'https://webtask.it.auth0.com/api/run/wt-tehsis-gmail_com-1?key=eyJhbGciOiJIUzI1NiIsImtpZCI6IjIifQ.eyJqdGkiOiJmZGZiOWU2MjQ0YjQ0YWYyYjc2YzAwNGU1NjgwOGIxNCIsImlhdCI6MTQzMDMyNjc4MiwiY2EiOlsiZDQ3ZDNiMzRkMmI3NGEwZDljYzgwOTg3OGQ3MWQ4Y2QiXSwiZGQiOjAsInVybCI6Imh0dHA6Ly90ZWhzaXMuZ2l0aHViLmlvL3dlYnRhc2tpby1jYW5pcmVxdWlyZS90YXNrcy9saXN0X21vZHVsZXMuanMiLCJ0ZW4iOiIvXnd0LXRlaHNpcy1nbWFpbF9jb20tWzAtMV0kLyJ9.MJqAB9mgs57tQTWtRuZRj6NCbzXxZcXCASYGISk3Q6c'; | |
| module.exports = Request.get(LIST_MODULES_URL, { json: true }).then(function (data) { | |
| var modules = data.modules; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| module.exports = (sequelize, DataType) => { | |
| let Category = sequelize.define('Category', { | |
| name: { | |
| type: DataType.STRING(100), | |
| allowNull: false | |
| }, | |
| description: { | |
| type: DataType.TEXT, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| module.exports = { up, down }; | |
| function up (db) { | |
| const User = require('../src/shared/user/model')(db.sequelize, db.Sequelize); | |
| return User.sync(); | |
| }; | |
| function down (db) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| console.log('lolololo'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getToken (user) { | |
| const secretKey = process.env.JWT || ‘stubJWT’; | |
| return jwt.sign({ id: user._id, roles: user.roles }, secretKey, {expiresIn: ‘18h’}); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const jwt = require('jsonwebtoken'); | |
| const Boom = require('boom'); | |
| function UserController (db) { | |
| this.database = db; | |
| this.model = db.User; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const Promise = require('bluebird'); | |
| const jwt = require('hapi-auth-jwt2'); | |
| const db = require('./database'); | |
| exports.register = (server, options, next) => { | |
| server.register(jwt, registerAuth); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| function TodoController (db) { | |
| this.database = db; | |
| this.model = db.Todo; | |
| } | |
| TodoController.prototype = { | |
| get, | |
| create |