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
// make EE singelton, add .off method | |
let instance = null; | |
class EventEmitter { | |
constructor() { | |
// ensure we have only one instance (singelton pattern) | |
if (!instance) { | |
instance = this; | |
} |
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
// Simple Event emitter realization | |
class EventEmitter { | |
constructor() { | |
// store for handlers | |
this.events = {}; | |
} | |
// subscribe | |
on(name, fn) { | |
this.events[name] = this.events[name] || []; |
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
// koa-passport-authenticate.js | |
'use strict' | |
const _ = require('lodash') | |
const passport = require('koa-passport') | |
'use strict' | |
// Middleware wrapper for koa passport to have proper error handling on authenticate. |
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
export const RECEIVE_MESSAGE = 'RECEIVE_MESSAGE'; |
NewerOlder