Skip to content

Instantly share code, notes, and snippets.

View thebergamo's full-sized avatar
🤟

Marcos Bérgamo thebergamo

🤟
View GitHub Profile
// [GET] /category
function list (request, reply) {
this.model
.scope({
method: ['user', request.auth.credentials.id]
})
.findAndCountAll({
attributes: ['id', 'description'],
order: 'description',
offset: request.offset,
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;
'use strict';
module.exports = (sequelize, DataType) => {
let Category = sequelize.define('Category', {
name: {
type: DataType.STRING(100),
allowNull: false
},
description: {
type: DataType.TEXT,
'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) {
console.log('lolololo');
function getToken (user) {
const secretKey = process.env.JWT || ‘stubJWT’;
return jwt.sign({ id: user._id, roles: user.roles }, secretKey, {expiresIn: ‘18h’});
}
@thebergamo
thebergamo / todo-route.js
Created December 15, 2015 12:29
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);
@thebergamo
thebergamo / userController.js
Created December 11, 2015 02:22
Hapi + JWT controller
'use strict';
const jwt = require('jsonwebtoken');
const Boom = require('boom');
function UserController (db) {
this.database = db;
this.model = db.User;
}
@thebergamo
thebergamo / authJWT.js
Last active December 11, 2015 01:57
Hapi + Auth JWT
'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);
@thebergamo
thebergamo / controller.js
Last active December 9, 2015 12:57
Thin Controller
'use strict';
function TodoController (db) {
this.database = db;
this.model = db.Todo;
}
TodoController.prototype = {
get,
create