Skip to content

Instantly share code, notes, and snippets.

View divyanshu013's full-sized avatar
:shipit:
Ship it

Divyanshu Maithani divyanshu013

:shipit:
Ship it
View GitHub Profile
@divyanshu013
divyanshu013 / todoApp.js
Last active October 25, 2017 17:59
Parent component for TodoMVC Auth Client
// Based on: https://github.com/tastejs/todomvc/blob/gh-pages/examples/react/js/app.jsx
import React, { Component } from "react";
import {
ReactiveBase,
ReactiveList,
TextField,
DataController
} from "@appbaseio/reactivesearch";
@divyanshu013
divyanshu013 / Callback.js
Created October 11, 2017 09:30
Callback component for TodoMVC Auth Client
import React from 'react';
const Callback = () => (
<div className="loading">
<h4>Loading...</h4>
</div>
);
export default Callback;
@divyanshu013
divyanshu013 / auth.js
Last active October 11, 2017 08:32
Authentication service for TodoMVC Auth Client
import auth0 from 'auth0-js';
import history from './history';
export default class Auth {
// Please use your own credentials here
auth0 = new auth0.WebAuth({
domain: 'divyanshu.auth0.com',
clientID: 'gnXmrO24CGNBuYtfGgblgOHM2GESYQ5N',
redirectUri: process.env.NODE_ENV === 'development' ? 'http://localhost:8001/callback' : 'https://appbaseio-apps.github.io/todomvc-auth-client/callback',
@divyanshu013
divyanshu013 / history.js
Created October 11, 2017 08:28
History service for TodoMVC Auth Client
import createHistory from 'history/createBrowserHistory';
export default createHistory({
basename: process.env.NODE_ENV === 'development' ? '/' : '/todomvc-auth-client'
});
@divyanshu013
divyanshu013 / index.js
Last active October 11, 2017 10:10
TodoMVC Auth Server example
const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const morgan = require('morgan');
const jwt = require('express-jwt');
const jwksRsa = require('jwks-rsa');
const Appbase = require('appbase-js');
// middlewares
const app = express();
@divyanshu013
divyanshu013 / todoItem.js
Created October 11, 2017 06:45
Updated todoItem with user info
import React, { Component } from "react";
import ReactDOM from "react-dom";
import classNames from "classnames";
import ReactTooltip from 'react-tooltip';
import { TextField } from "@appbaseio/reactivesearch";
const ESCAPE_KEY = 27;
const ENTER_KEY = 13;
class TodoItem extends Component {
@divyanshu013
divyanshu013 / index.js
Created September 20, 2017 11:18
Updated index.js file after adding Routes
import React from 'react';
import ReactDOM from 'react-dom';
import '@appbaseio/reactivesearch/dist/css/style.min.css';
import './index.css';
import Routes from './Routes';
import registerServiceWorker from './registerServiceWorker';
ReactDOM.render(<Routes />, document.getElementById('root'));
registerServiceWorker();
@divyanshu013
divyanshu013 / history.js
Last active September 22, 2017 13:54
Contains the browser history service
import createHistory from 'history/createBrowserHistory';
export default createHistory({
basename: process.env.NODE_ENV === 'development' ? '' : '/reactivesearch-auth0-example'
});
@divyanshu013
divyanshu013 / Routes.js
Last active September 20, 2017 11:18
Adding routes for the app
import React from 'react';
import { Route, Router } from 'react-router-dom';
import Home from './Home';
import Callback from './Callback';
import Auth from './auth';
import history from './history';
const auth = new Auth();
const handleAuthentication = (nextState, replace) => {
@divyanshu013
divyanshu013 / Callback.js
Created September 14, 2017 11:21
Callback component to display while the user session is getting created
import React from 'react';
const Callback = () => (
<div className="container">
<h4>Loading...</h4>
</div>
);
export default Callback;