Skip to content

Instantly share code, notes, and snippets.


Perry Donham pdonham

View GitHub Profile
pdonham / UserWithCrypto.js
Last active November 24, 2020 06:16
Sample code for Using JWTs for Authentication in RESTful Applications (
View UserWithCrypto.js
For this version we'll add a register method to add a user to the database using proper
password encryption. It also demonstrates how to add and use a method on a schema.
const mongoose = require('mongoose')
const crypto = require('crypto')
//const findOrCreate = require('mongoose-findorcreate')
//Set up ES6 Promises
pdonham / oauthTwitterNoPassport.js
Last active December 2, 2017 16:34
Three-step OAuth with Twitter demonstrating both authentication and authorization
View oauthTwitterNoPassport.js
/* An example showing OAuth 1.0 against Twitter, based on a post at
Comments are mine - PCD
//Get a router instance
const express = require('express')
const router = express.Router()
pdonham / request-promises.js
Created July 12, 2017 01:08
Using async.waterfall to synchronize aggregation of results when using promises
View request-promises.js
Small demo to show chaining of API calls. We're using these APIs: for current weather in 3 cities, and<term> to search GitHub repos for
the 'hottest' city. For example, we'll grab weather for 3 cities, pick the hottest one,
then hit GitHub with a search for repos that have that city's name. A bit nonsensical
but I just wanted to demonstrate using the results of one API call to populate a second.
The problem we're trying to solve is that the API calls are asynch, and one of them
(getCityTemperatures) loops through several asynch calls (one for each city), and they