This file contains hidden or 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
// let's define our expiration date | |
const today = new Date(); | |
let expDate = new Date(); | |
expDate.setDate(today.getDate() + 30); // 30 days expiration | |
// a searches user does in your app on the first visit, we collect them to save to localStorage | |
const userRecentlocations = [ | |
{ city: "New York", country: "US", id: "2390230" }, | |
{ city: "Athens", country: "GR", id: "304802" }, | |
{ city: "Kyiv", country: "UA", id: "1239488" } |
This file contains hidden or 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 fruits = { | |
apples: 3, | |
bananas: 4, | |
pears: 1, | |
blackberries: 8 | |
} | |
// always check if Storage is available | |
if (typeof(Storage)) { | |
// saving the object (or JSON) to localStorage |
This file contains hidden or 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
import AWS from 'aws-sdk'; | |
import { CognitoUserPool, AuthenticationDetails, CognitoUser } from 'amazon-cognito-identity-js'; | |
export default function signinHandler(body) { | |
const authData = JSON.parse(body); | |
AWS.config.region = 'us-east-1'; | |
const authenticationDetails = { | |
Username: authData.username, | |
Password: authData.password, | |
}; |
This file contains hidden or 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
// after all babel and webpack configs | |
import AWS from 'aws-sdk'; | |
import { CognitoUserPool } from 'amazon-cognito-identity-js'; | |
export default function signupHandler(body) { | |
const userData = JSON.parse(body); | |
AWS.config.region = 'us-east-1'; | |
const poolData = { |
This file contains hidden or 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
// modules.js | |
export function drive(props) { | |
return props.gas | |
} | |
export function fly(props) { | |
return props.miles | |
} | |
// main.js |
This file contains hidden or 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
import reducer from './getPostReducer'; | |
import * as actions from '../actions/posts/getPost'; | |
import { UPDATE_POST_SUCCESS } from '../actions/posts/updatePost'; | |
import expect from 'expect'; | |
import getPostMock from '../mocks/getPostMock'; | |
describe('post reducer', () => { | |
it('should return the initial state', () => { | |
expect(reducer(undefined, {})).toEqual({}); | |
}); |
This file contains hidden or 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
import reducer from './getPostsReducer'; | |
import * as types from '../actions/posts/getPostsReduxAction'; | |
import expect from 'expect'; | |
describe('team reducer', () => { | |
it('should return the initial state'); | |
it('should handle GET_POST_SUCCESS'); | |
it('should handle UPDATE_POST_SUCCESS'); | |
it('should handle GET_POST_FAIL'); | |
it('should handle GET_POST_START'); |
This file contains hidden or 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
import configureMockStore from 'redux-mock-store'; | |
import thunk from 'redux-thunk'; | |
import moxios from 'moxios'; | |
import expect from 'expect'; | |
import * as actions from './getPosts'; | |
import getPostsMock from '../../mocks/getPostsMock'; | |
const middlewares = [thunk]; | |
const mockStore = configureMockStore(middlewares); |
This file contains hidden or 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
import axios from 'axios'; | |
export const GET_POSTS_START = 'GET_POSTS_START'; | |
export const GET_POSTS_SUCCESS = 'GET_POSTS_SUCCESS'; | |
export const GET_POSTS_FAIL = 'GET_POSTS_FAIL'; | |
const getPostsStart = () => ({ | |
type: GET_POSTS_START, | |
}); |
This file contains hidden or 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
import React, { Component } from 'react'; | |
import axios from 'axios'; | |
class uploadMyFile extends Component { | |
handleUploadFile = (event) => { | |
const data = new FormData(); | |
data.append('file', event.target.files[0]); | |
data.append('name', 'some value user types'); | |
data.append('description', 'some value user types'); | |
// '/files' is your node.js route that triggers our middleware |
NewerOlder