I hereby claim:
- I am jsruvi on github.
- I am ruvi (https://keybase.io/ruvi) on keybase.
- I have a public key ASCAR5JoIuq3PoAWhWG6xXTD4My1WY3X_LIOGKzh1c5Cxgo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:
var Article = require('../../../models/article');
Those suck for maintenance and they're ugly.
// Restify Server CheatSheet. | |
// More about the API: http://mcavage.me/node-restify/#server-api | |
// Install restify with npm install restify | |
// 1.1. Creating a Server. | |
// http://mcavage.me/node-restify/#Creating-a-Server | |
var restify = require('restify'); |
public.post('/custom', function*(next) { | |
var ctx = this | |
yield passport.authenticate('local', function*(err, user, info) { | |
if (err) throw err | |
if (user === false) { | |
ctx.status = 401 | |
ctx.body = { success: false } | |
} else { | |
yield ctx.login(user) | |
ctx.body = { success: true } |
'use strict'; | |
const passport = require('koa-passport'); | |
const LocalStrategy = require('passport-local').Strategy; | |
const FacebookStrategy = require('passport-facebook').Strategy; | |
const BearerStrategy = require('passport-http-bearer').Strategy; | |
const StripeStrategy = require('passport-stripe').Strategy; | |
const query = require('./query'); | |
const validatePw = require('./validatePassword'); | |
const genHash = require('./genHash'); |
// set-up a connection between the client and the server | |
var socket = io.connect(); | |
// let's assume that the client page, once rendered, knows what room it wants to join | |
var room = "abc123"; | |
socket.on('connect', function() { | |
// Connected, let's sign-up for to receive messages for this room | |
socket.emit('room', room); | |
}); |