Skip to content

Instantly share code, notes, and snippets.

View vdeturckheim's full-sized avatar
😇
Living the JS life

Vladimir de Turckheim vdeturckheim

😇
Living the JS life
View GitHub Profile
/**
* 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 () {
'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) {
'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) {
'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 },
'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){
'use strict';
const Mongoose = require('mongoose');
const Schema = Mongoose.Schema;
const userSchema = new Schema({
githubid: {
type: String,
required: true,
select: false
},
'use strict';
require('@vdeturckheim/exploic');
const jwt = require('jsonwebtoken');
const token = jwt.sign({ foo: 'bar'}, 'shhhhh');
console.log(token);
'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')) {
'use strict';
const Module = require('module');
const originalCompile = Module.prototype._compile;
const nohook = function (content, filename, done) {
return done(content);
};
let currentHook = nohook;
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([]);
}