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 simple Redux Middleware that will record Redux actions and state to FullStory. This data will be available in the | |
console view in FullStory's DevTools during session replay. | |
Learn more about DevTools here: https://help.fullstory.com/hc/en-us/articles/360020828313-Guide-to-Dev-Tools | |
Redux Middleware guide here: https://redux.js.org/tutorials/fundamentals/part-4-store#middleware | |
Please be careful to not record any sensitive information that may be in your Redux state. | |
*/ |
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
import { Cors, LambdaRestApi } from '@aws-cdk/aws-apigateway'; | |
import * as core from '@aws-cdk/core'; | |
import * as lambda from '@aws-cdk/aws-lambda'; | |
export class ReactshoppeApi extends core.Construct { | |
private _handler: lambda.Function; | |
constructor(scope: core.Construct, id: string) { | |
super(scope, id); | |
this._handler = new lambda.Function(this, 'ApiHandler', { |
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
"scripts": { | |
"build": "tsc && npm run build:webpack", | |
"build:webpack": "webpack --config packages/functions/webpack.config.js --display-error-details", | |
"cdk": "cdk", | |
"bootstrap": "lerna bootstrap", | |
"deploy": "npm run bootstrap && npm run build && cdk deploy" | |
} |
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 path = require('path'); | |
module.exports = { | |
target: 'node', | |
mode: 'production', | |
optimization: { | |
minimize: true, | |
sideEffects: false, | |
}, | |
context: path.resolve(__dirname), |
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
import { APIGatewayProxyEvent } from 'aws-lambda'; | |
import * as AWS from 'aws-sdk'; | |
import { v4 as uuidv4 } from 'uuid'; | |
import { TableNames } from '../reactshoppe-database'; | |
import { success, failure } from './response'; | |
export default async (event: APIGatewayProxyEvent) => { | |
const ddb = new AWS.DynamoDB.DocumentClient(); | |
let newOrder = {}; | |
// NOTE: in a real application, we’d do more to validate input |
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
import { APIGatewayProxyEvent } from 'aws-lambda'; | |
import ping from './ping'; | |
import checkout from './checkout'; | |
import { failure } from './response'; | |
exports.main = async (event: APIGatewayProxyEvent) => { | |
const notFound = () => failure(JSON.stringify({ message: 'not found' }), 404); | |
switch (event.path) { | |
case '/ping': | |
return ping(); |
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
import { Cors, LambdaRestApi } from '@aws-cdk/aws-apigateway'; | |
import * as core from '@aws-cdk/core'; | |
import * as lambda from '@aws-cdk/aws-lambda'; | |
export class ReactshoppeApi extends core.Construct { | |
private _handler: lambda.Function; | |
constructor(scope: core.Construct, id: string) { | |
super(scope, id); | |
this._handler = new lambda.Function(this, 'ApiHandler', { |
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
import * as cdk from '@aws-cdk/core'; | |
import { ReactshoppeDatabase } from './reactshoppe-database'; | |
import { ReactshoppeApi } from './reactshoppe-api'; | |
export class ReactshoppeApiStack extends cdk.Stack { | |
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { | |
super(scope, id, props); | |
// The code that defines your stack goes here | |
const api = new ReactshoppeApi(this, 'ReactshoppeApi'); |
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
import * as cdk from '@aws-cdk/core'; | |
import { ReactshoppeDatabase } from './reactshoppe-database'; | |
export class ReactshoppeApiStack extends cdk.Stack { | |
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { | |
super(scope, id, props); | |
// The code that defines your stack goes here | |
new ReactshoppeDatabase(this, 'ReactshoppeDatabase'); | |
} |
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
import * as core from '@aws-cdk/core'; | |
import * as iam from '@aws-cdk/aws-iam'; | |
import * as dynamodb from '@aws-cdk/aws-dynamodb'; | |
export class ReactshoppeDatabase extends core.Construct { | |
private orderTable: dynamodb.Table; | |
constructor(scope: core.Construct, id: string) { | |
super(scope, id); | |
this.orderTable = new dynamodb.Table(this, TableNames.Order, { |
NewerOlder