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
var AWS = require('aws-sdk') | |
var gm = require('gm').subClass({ imageMagick: true }) | |
var s3 = new AWS.S3() | |
exports.handler = function(event, context, callback) { | |
var prefix = 'resized-' | |
var srcBucket = event.Records[0].s3.bucket.name | |
var dstBucket = prefix + srcBucket | |
var srcKey = decodeURIComponent(event.Records[0].s3.object.key.replace(/\+/g, " ")) | |
var dstKey = prefix + srcKey |
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 from 'react' | |
import renderer from 'react-test-renderer' | |
import shallowRenderer from 'react-test-renderer/shallow' | |
import App from './App' | |
describe('Test app component', () => { | |
it('shallow snapshot', () => { | |
const renderer = new shallowRenderer | |
const snapshot = renderer.render(<App />) | |
expect(snapshot).toMatchSnapshot() |
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
Show hidden characters
import React, { Component } from 'react' | |
import Loading from './Loading' | |
class CommentList extends Component { | |
render() { | |
const { isLoading, comments } = this.props | |
if (isLoading) return <Loading /> | |
return ( | |
<ul> |
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 withLoading from '../hocs/withLoading' | |
class CommentList extends Component { | |
render() { | |
return ( | |
<ul> | |
{ | |
this.props.comments.map(({ id, body }) => <li key={id}>{body}</li>) | |
} |
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 Loading from '../components/Loading' | |
const withLoading = (WrappedComponent) => { | |
return class ComponentWithLoading extends Component { | |
render() { | |
const { isLoading } = this.props | |
if (isLoading) return <Loading /> | |
return <WrappedComponent {...this.props} /> |
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 express = require('express') | |
const app = express() | |
app.get('/', (req, res) => { | |
res.send('Hello World') | |
}) | |
app.listen(3000, () => { | |
console.log('Start server at port 3000.') | |
}) |
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
[ | |
{ | |
"id": "1", | |
"name": "Game of thrones" | |
}, | |
{ | |
"id": "2", | |
"name": "Clash of kings" | |
} | |
] |
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 books = require('./db') | |
app.get('/books', (req, res) => { | |
res.json(books) | |
}) |
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 books = require('./db') | |
app.get('/books', (req, res) => { | |
res.json(books) | |
}) |
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
app.get('/books/:id', (req, res) => { | |
res.json(books.find(book => book.id === req.params.id)) | |
}) |
OlderNewer