This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a reducer, same as Redux's | |
const reducer = (state, action) => { | |
switch(action.type) { | |
case 'FETCHING_TWEETS': | |
return {...state, fetchingTweets: true}; | |
break; | |
case 'TWEETS_RECEIVED': | |
return { ...state, | |
fetchingTweets: false, | |
tweets: action.tweets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
constructor(reducer, initialState = {}) { | |
this.store = [ initialState ]; | |
this.reducer = reducer; | |
this.subscribers = []; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const store = createStore( | |
reducer, | |
initialState | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cheerio = require('cheerio'); | |
const google = require('google'); | |
const request = require('superagent'); | |
const util = require('util'); | |
const misconfiguredCORS = require('./plugins/misconfiguredCORS'); | |
google.resultsPerPage = 100; | |
const g = util.promisify(google); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = async function misconfiguredCORS(url, test) { | |
let headers = null; | |
try { | |
const result = await request | |
.get(url) | |
.set('Access-Control-Allow-Origin', test) | |
.timeout(5000) | |
if('access-control-allow-origin' in result.headers) { | |
headers = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function fetchedUserFromApi(data) { | |
return { | |
type: FETCHED_USER_FROM_API, | |
data: { | |
isLoading: false, | |
isError: false, | |
...data | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Actions | |
*/ | |
export const FETCHING_USER_FROM_API = 'FETCHING_USER_FROM_API'; | |
export const FETCHED_USER_FROM_API = 'FETCHED_USER_FROM_API'; | |
export const FETCHED_USER_ERROR = 'FETCHED_USER_ERROR'; | |
/* | |
* Action creators | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "web", | |
"version": "0.1.0", | |
"private": true, | |
"proxy": "http://localhost:3001", | |
"dependencies": { | |
"enzyme-to-json": "^3.1.2", | |
"fetch-mock": "^5.13.1", | |
"prop-types": "^15.6.0", | |
"react": "^16.0.0", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome — remote-debugging-port=9222 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<path to chrome>/chrome.exe --remote-debugging-port=9222 |