Skip to content

Instantly share code, notes, and snippets.

View PrincewillIroka's full-sized avatar

Princewill Iroka PrincewillIroka

View GitHub Profile
@PrincewillIroka
PrincewillIroka / index.js
Last active December 31, 2020 20:31
A simple Proxy Server
const express = require("express");
const bodyParser = require("body-parser");
const FormData = require("form-data");
const fetch = require("node-fetch");
const { client_id, redirect_uri, client_secret } = require("./config");
const config = require("./config");
const app = express();
import React, { useContext } from "react";
import { Redirect } from "react-router-dom";
import Styled from "styled-components";
import { AuthContext } from "../App";
export default function Home() {
const { state, dispatch } = useContext(AuthContext);
if (!state.isLoggedIn) {
import React, { useState, useEffect, useContext } from "react";
import { Redirect } from "react-router-dom";
import Styled from "styled-components";
import GithubIcon from "mdi-react/GithubIcon";
import { AuthContext } from "../App";
export default function Login() {
const { state, dispatch } = useContext(AuthContext);
const [data, setData] = useState({ errorMessage: "", isLoading: false });
@PrincewillIroka
PrincewillIroka / index.js
Last active December 31, 2020 20:34
index.js file in store
export const initialState = {
isLoggedIn: JSON.parse(localStorage.getItem("isLoggedIn")) || false,
user: JSON.parse(localStorage.getItem("user")) || null,
client_id: process.env.REACT_APP_CLIENT_ID,
redirect_uri: process.env.REACT_APP_REDIRECT_URI,
client_secret: process.env.REACT_APP_CLIENT_SECRET,
proxy_url: process.env.REACT_APP_PROXY_URL
};
export const reducer = (state, action) => {
import React, { createContext, useReducer } from 'react';
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import Home from "./components/Home";
import Login from "./components/Login";
import { initialState, reducer } from "./store/reducer";
export const AuthContext = createContext();
function App() {