Skip to content

Instantly share code, notes, and snippets.

View funador's full-sized avatar

Jesse Heaslip funador

View GitHub Profile
arr.reduce(callback(accumulator, currentValue[, index[, array]]), [, initialValue])
import React, { Component } from 'react'
import io from 'socket.io-client'
import jwtDecode from 'jwt-decode'
import { notify } from 'react-notify-toast'
import OAuth from './OAuth'
import Loading from './Loading'
import Header from './Header'
import Footer from './Footer'
import api from './api'
import { API_URL } from './config'
require('dotenv').config()
const express = require('express')
const path = require('path')
const fs = require('fs')
const https = require('https')
const http = require('http')
const passport = require('passport')
const session = require('express-session')
const cors = require('cors')
const socketio = require('socket.io')
module.exports = profile => {
const { provider } = profile
switch(provider) {
case 'twitter':
return {
name: profile.username,
photo: profile.photos[0].value.replace(/_normal/, '')
}
const express = require('express')
const router = express.Router()
const passport = require('passport')
const authController = require('./auth.controller')
// Setting up the passport middleware for each of the OAuth providers
const twitterAuth = passport.authenticate('twitter')
const googleAuth = passport.authenticate('google', { scope: ['profile', 'email'] })
const facebookAuth = passport.authenticate('facebook')
const githubAuth = passport.authenticate('github')
const jwt = require('jsonwebtoken')
const User = require('./user.model')
const { providers, JWT_EXPIRY, JWT_SECRET } = require('../config')
const createAuthToken = user =>
jwt.sign({user}, JWT_SECRET, {
subject: user.email,
expiresIn: JWT_EXPIRY,
algorithm: 'HS256'
})
const passport = require('passport')
const { Strategy: TwitterStrategy } = require('passport-twitter')
const { OAuth2Strategy: GoogleStrategy } = require('passport-google-oauth')
const { Strategy: FacebookStrategy } = require('passport-facebook')
const { Strategy: GithubStrategy} = require('passport-github')
const { Strategy: JwtStrategy } = require('passport-jwt')
const User = require('./user.model')
const normalizeProfileData = require('./normalize.profile.data')
const {
TWITTER_CONFIG, GOOGLE_CONFIG, FACEBOOK_CONFIG, GITHUB_CONFIG, JWT_CONFIG
const mongoose = require('mongoose')
const Schema = mongoose.Schema
const { providers } = require('../config')
//
const providerFields = providers.reduce((obj, provider) => {
obj[provider] = {
name: {
type: String
},
const render = (() => {
const _todoHTML = todo => {
const { editing, text, done, id } = todo
const todoText = editing
? `<form>
<input value='${text}' data-id='${id}'>
</form>`
: `<div class='text ${done}'>${text}</div>`
const store = (() => {
const todos = []
function addToStore(todo) {
todo.editing = false
this.todos = [todo, ...this.todos]
}
function deleteFromStore(id) {