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 express from 'express'; | |
import axios from 'axios'; | |
import multer from 'multer'; | |
const app = express(); | |
/** | |
... express.js boilerplate | |
routes, middlewares, helpers, loggers, etc | |
**/ |
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
actions: { | |
sendContactForm() { | |
// Getting input values. | |
// TODO: add validation before trying to save the values. | |
const submittedForm = { | |
name: this.get('name'), | |
email: this.get('email'), | |
company: this.get('company'), | |
phone: this.get('phone'), | |
message: this.get('message'), |
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 Ember from 'ember'; | |
// because it's loading through browserify, we're preficing it with npm: | |
import AWS from 'npm:aws-sdk' | |
// It's recommended to keep all your API keys in the environment.js file | |
// and pass them through environment variables | |
import config from '../config/environment'; | |
const ses = new AWS.SES({ | |
apiVersion: '2010-12-01', | |
accessKeyId: config.aws.accessKeyId, |
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'; | |
import cloudinary from 'cloudinary'; | |
export default function fileUploadMiddleware(req, res) { | |
cloudinary.uploader.upload_stream((result) => { | |
axios({ | |
url: '/api/upload', //API endpoint that needs file URL from CDN | |
method: 'post', | |
data: { | |
url: result.secure_url, |
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 multer from 'multer'; | |
import cloudinary from 'cloudinary'; | |
import fileUploadMiddleware from './fileUploadMiddleware'; | |
/* your servrer init and express code here */ | |
cloudinary.config({ | |
cloud_name: 'xxx', | |
api_key: 'xxxx', | |
api_secret: 'xxxxx', |
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 |
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 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 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 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({}); | |
}); |