This file contains 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
app.post('/documents/find', (req, res) => { | |
if (!req.body.type && !req.body.title) { | |
return res.json([]); | |
} | |
if (req.body.type === "evil projects") { // I don't want people to discover my evli projects, | |
// it would be a shame is 'client.js' contained a method show all the content of the collection here... | |
return res.json([]); | |
} |
This file contains 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'; | |
require('@vdeturckheim/exploic'); | |
const jwt = require('jsonwebtoken'); | |
const token = jwt.sign({ foo: 'bar'}, 'shhhhh'); | |
console.log(token); |
This file contains 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 Hook = require('compile-hook'); | |
const Acorn = require('acorn-jsx'); | |
const Falafel = require('falafel'); | |
const hijack = function (script) { | |
return Falafel(script, { parser: Acorn }, function (node) { | |
if (node.type === 'AssignmentExpression' && node.source().includes('module.exports')) { |
This file contains 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 Module = require('module'); | |
const originalCompile = Module.prototype._compile; | |
const nohook = function (content, filename, done) { | |
return done(content); | |
}; | |
let currentHook = nohook; |
This file contains 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 Bell = require('bell'); | |
const AuthBearer = require('hapi-auth-bearer-token'); | |
const AuthService = require('./lib/services/auth.service'); | |
const Routes = require('./lib').routes; | |
exports.register = function (server, options, next) { | |
if (!options.github){ |
This file contains 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 AuthController = require('./api/auth'); | |
const UserController = require('./api/user'); | |
module.exports.routes = [ | |
// auth | |
{ method: ['GET', 'POST'], path: '/login', config: AuthController.login }, | |
{ method: 'GET', path: '/logout', config: AuthController.logout }, |
This file contains 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 AuthService = require('../services/auth.service'); | |
// { method: ['GET', 'POST'], path: '/login', config: AuthController.login } | |
module.exports.login = { | |
description: 'Sign-in a user in the app', | |
tags: ['auth'], | |
auth: 'github', | |
handler: function (request, reply) { |
This file contains 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 User = require('../models/user.model'); | |
const Boom = require('boom'); | |
/** | |
* save anew user if no conflict occurs | |
* @param candidateUser | |
* @returns {Promise.<*>} | |
*/ | |
module.exports.save = function (candidateUser) { |
This file contains 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 Mongoose = require('mongoose'); | |
const Schema = Mongoose.Schema; | |
const userSchema = new Schema({ | |
githubid: { | |
type: String, | |
required: true, | |
select: false | |
}, |
This file contains 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
/** | |
* Transforms an object to an array (drop the Object's keys) | |
* ``` | |
* let x = { a: 1, b: 2}; | |
* x.mapToArray() is [1, 2]; | |
* ``` | |
* @returns {Array} | |
*/ | |
Object.prototype.mapToArray = function () { |