Skip to content

Instantly share code, notes, and snippets.

View shsunmoonlee's full-sized avatar

Seunghun Sunmoon Lee shsunmoonlee

View GitHub Profile
@shsunmoonlee
shsunmoonlee / server-index.js
Created October 17, 2018 16:31
How to Social Login(Facebook, Google, etc…) with Realtime MongoDB Database, Feathersjs(node.js backend framework), React(frontend framework)
/* eslint consistent-return:0 */
// const express = require('express');
const logger = require('./logger');
const dotenv = require('dotenv');
const argv = require('./argv');
const port = require('./port');
const setup = require('./middlewares/frontendMiddleware');
const isDev = process.env.NODE_ENV !== 'production';
@shsunmoonlee
shsunmoonlee / gist:7e61aa6cd8a6b6a5d61953bcf3fcd7e2
Created October 5, 2018 12:00
feathers oauth2 social login
class CustomVerifier extends Verifier {
// The verify function has the exact same inputs and
// return values as a vanilla passport strategy
verify(req, accessToken, refreshToken, profile, done) {
// do your custom stuff. You can call internal Verifier methods
// and reference this.app and this.options. This method must be implemented.
console.log("===CustomVerifier done, this.app, profile,", done, this.app, profile)
// the 'user' variable can be any truthy value
// the 'payload' is the payload for the JWT access token that is generated after successful authentication
done(null, user, payload);
@shsunmoonlee
shsunmoonlee / feathers_oauth_social_login.js
Last active July 23, 2023 11:35
Oauth2 Social login(Facebook, Google) not work on Feathers API backend server, React frontend.
====================
/* backend */
/* app.js */
const path = require('path');
const favicon = require('serve-favicon');
const compress = require('compression');
const cors = require('cors');
const helmet = require('helmet');
const logger = require('winston');
// client
const GET_RECORDINGS = gql`{
recordings {
id
title
input
}
}`
const ADD_RECORDINGS = gql`
mutation($title: String!, $input: AudioInput! ) {
@shsunmoonlee
shsunmoonlee / actions.js
Created June 24, 2018 10:02
spotify player actions thunk version
import uniqBy from 'lodash';
/*
* SpotifyPage Actions
*
* Actions change things in your application
* Since this boilerplate uses a uni-directional data flow, specifically redux,
* we have these actions which are the only way your application interacts with
* your application state. This guarantees that your state is up to date and nobody
* messes it up weirdly somewhere.
*
@shsunmoonlee
shsunmoonlee / reducers.js
Created June 24, 2018 10:02
spotify player thunk version
/*
* HomeReducer
*
* The reducer takes care of our data. Using actions, we can change our
* application state.
* To add a new action, add it to the switch statement in the reducer function
*
* Example:
* case YOUR_ACTION_CONSTANT:
* return state.set('yourStateVariable', true);
@shsunmoonlee
shsunmoonlee / saga.js
Created June 24, 2018 09:59
spotify player saga
/**
* Gets the repositories of the user from Github
*/
import { delay } from 'redux-saga'
import { call, take, put, select, takeLatest, takeEvery } from 'redux-saga/effects';
// import { LOAD_REPOS, GET_LISTS, GET_LISTS_SUCCESS, GET_COMMENTS, GET_COMMENTS_SUCCESS, DELETE_COMMENTS, SEARCH_LISTS } from 'containers/App/constants';
import { fetchAlbumsSuccess, fetchAlbumsError, fetchArtistsError, fetchArtistSongsSuccess, fetchArtistSongsError, fetchCategoriesSuccess, fetchCategoriesError, fetchNewReleasesSuccess, fetchNewReleasesError, fetchFeaturedSuccess, fetchFeaturedError, fetchPlaylistMenuSuccess, fetchPlaylistMenuError, fetchPlaylistSongsError, fetchPlaylistSongsSuccess, fetchSongsError, fetchSongsSuccess, setArtistIds, searchSongsSuccess, fetchRecentlyPlayedPending, fetchRecentlyPlayedError, fetchUserError, fetchUserSuccess, addSongToLibraryError, addSongToLibrarySuccess } from './actions';
import faker from 'faker';
import axios from 'axios';
@shsunmoonlee
shsunmoonlee / reducers.js
Created June 24, 2018 09:58
spotify player reducers saga version
/*
* HomeReducer
*
* The reducer takes care of our data. Using actions, we can change our
* application state.
* To add a new action, add it to the switch statement in the reducer function
*
* Example:
* case YOUR_ACTION_CONSTANT:
* return state.set('yourStateVariable', true);
@shsunmoonlee
shsunmoonlee / actions.js
Created June 24, 2018 09:57
spotify player saga version
import uniqBy from 'lodash';
/*
* SpotifyPage Actions
*
* Actions change things in your application
* Since this boilerplate uses a uni-directional data flow, specifically redux,
* we have these actions which are the only way your application interacts with
* your application state. This guarantees that your state is up to date and nobody
* messes it up weirdly somewhere.
*
module.exports = {
valueAtBit: function(num, bit) {
return (num).toString(2) & (bit).toString(2)
},
base10: function(str) {
return (str).toString(2)
},
convertToBinary: function(num) {