Skip to content
This repository was archived by the owner on Dec 9, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app-client/appsync-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"apollo-client": "^2.0.2",
"apollo-client-preset": "^1.0.2",
"apollo-link": "^1.0.0",
"aws-amplify": "^0.1.30",
"aws-amplify-react": "^0.1.30",
"aws-appsync": "^1.0.1",
"aws-appsync-react": "^1.0.1",
"aws-sdk": "^2.158.0",
Expand Down
54 changes: 32 additions & 22 deletions app-client/appsync-client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,19 @@ import UserList from './components/UserList';
import logo from './logo.svg';
import './App.css';

import Amplify, { Auth } from 'aws-amplify';
import { withAuthenticator } from 'aws-amplify-react/dist/Auth';
import AWSAppSyncClient from 'aws-appsync';
import { Rehydrated } from 'aws-appsync-react';
import { AUTH_TYPE } from 'aws-appsync/lib/link/auth-link';
import { ApolloProvider } from 'react-apollo';
import * as AWS from 'aws-sdk';
import awsconfig from './aws-exports';

AWS.config.update({
region: awsconfig.REGION,
credentials: new AWS.Credentials({
accessKeyId: awsconfig.AWS_ACCESS_KEY_ID,
secretAccessKey: awsconfig.AWS_SECRET_ACCESS_KEY,
}),
});

const client = new AWSAppSyncClient({
url: process.env.REACT_APP_GRAPHQL_ENDPOINT,
region: 'us-east-1',
auth: { type: AUTH_TYPE.AWS_IAM, credentials: AWS.config.credentials },
Amplify.configure({
Auth: {
region: process.env.REACT_APP_AWS_AUTH_REGION, // REQUIRED - Amazon Cognito Region
userPoolId: process.env.REACT_APP_USER_POOL_ID, //OPTIONAL - Amazon Cognito User Pool ID
userPoolWebClientId: process.env.REACT_APP_CLIENT_APP_ID, //User Pool App Client ID
},
});

class App extends Component {
Expand All @@ -40,12 +34,28 @@ class App extends Component {
}
}

const WithProvider = () => (
<ApolloProvider client={client}>
<Rehydrated>
<App />
</Rehydrated>
</ApolloProvider>
);
class WithProvider extends React.Component {
render() {
if (this.props.authState !== 'signedIn') {
return null;
} else {
this.client = new AWSAppSyncClient({
url: process.env.REACT_APP_GRAPHQL_ENDPOINT,
region: process.env.REACT_APP_AWS_CLIENT_REGION,
auth: {
type: AUTH_TYPE.AMAZON_COGNITO_USER_POOLS,
jwtToken: this.props.authData.signInUserSession.idToken.jwtToken,
},
});

export default WithProvider;
return (
<ApolloProvider client={this.client}>
<Rehydrated>
<App authData={this.props.authData} />
</Rehydrated>
</ApolloProvider>
);
}
}
}
export default withAuthenticator(WithProvider, { includeGreetings: true });
9 changes: 0 additions & 9 deletions app-client/appsync-client/src/aws-exports.js

This file was deleted.

63 changes: 63 additions & 0 deletions app-client/appsync-client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ alphanum-sort@^1.0.1, alphanum-sort@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3"

amazon-cognito-identity-js@^1.19.0:
version "1.29.0"
resolved "https://registry.yarnpkg.com/amazon-cognito-identity-js/-/amazon-cognito-identity-js-1.29.0.tgz#bf1180a846b642e4aece3d970566d44e470c8162"
dependencies:
aws-sdk "^2.6.0"
js-cookie "^2.1.4"

amdefine@>=0.0.4:
version "1.0.1"
resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5"
Expand Down Expand Up @@ -412,6 +419,20 @@ autoprefixer@^6.3.1:
postcss "^5.2.16"
postcss-value-parser "^3.2.3"

aws-amplify-react@^0.1.30:
version "0.1.30"
resolved "https://registry.yarnpkg.com/aws-amplify-react/-/aws-amplify-react-0.1.30.tgz#03f75b614e1cd16549bbef17ad39f39c14b6e3a0"

aws-amplify@^0.1.30:
version "0.1.30"
resolved "https://registry.yarnpkg.com/aws-amplify/-/aws-amplify-0.1.30.tgz#ee2c934cc58eb487c38ffe66853c2ad5b3eb3f02"
dependencies:
amazon-cognito-identity-js "^1.19.0"
aws-sdk "^2.101.0"
aws-sdk-mobile-analytics "^0.9.2"
axios "^0.17.0"
querystring-browser "^1.0.4"

aws-appsync-react@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/aws-appsync-react/-/aws-appsync-react-1.0.1.tgz#51ad70daf8fd9b477845d10c46a67f4ea189e122"
Expand All @@ -436,6 +457,27 @@ aws-appsync@^1.0.0, aws-appsync@^1.0.1:
redux-thunk "^2.2.0"
url "^0.11.0"

aws-sdk-mobile-analytics@^0.9.2:
version "0.9.2"
resolved "https://registry.yarnpkg.com/aws-sdk-mobile-analytics/-/aws-sdk-mobile-analytics-0.9.2.tgz#b56a6e5206fc8c3975a19170b41536c53f6d5d91"
dependencies:
aws-sdk ">=2.2.37"

aws-sdk@>=2.2.37, aws-sdk@^2.101.0, aws-sdk@^2.6.0:
version "2.176.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.176.0.tgz#2723c14e1c623ac45c5b890a3fc736eee8085f67"
dependencies:
buffer "4.9.1"
crypto-browserify "1.0.9"
events "^1.1.1"
jmespath "0.15.0"
querystring "0.2.0"
sax "1.2.1"
url "0.10.3"
uuid "3.1.0"
xml2js "0.4.17"
xmlbuilder "4.2.1"

aws-sdk@^2.139.0:
version "2.158.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.158.0.tgz#56ec1e78770822fbc38ae62fed0f54e7a147bdeb"
Expand Down Expand Up @@ -474,6 +516,13 @@ aws4@^1.2.1:
version "1.6.0"
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e"

axios@^0.17.0:
version "0.17.1"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.17.1.tgz#2d8e3e5d0bdbd7327f91bc814f5c57660f81824d"
dependencies:
follow-redirects "^1.2.5"
is-buffer "^1.1.5"

axobject-query@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/axobject-query/-/axobject-query-0.1.0.tgz#62f59dbc59c9f9242759ca349960e7a2fe3c36c0"
Expand Down Expand Up @@ -2849,6 +2898,12 @@ flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"

follow-redirects@^1.2.5:
version "1.2.6"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.2.6.tgz#4dcdc7e4ab3dd6765a97ff89c3b4c258117c79bf"
dependencies:
debug "^3.1.0"

for-in@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
Expand Down Expand Up @@ -4012,6 +4067,10 @@ js-base64@^2.1.9:
version "2.3.2"
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.3.2.tgz#a79a923666372b580f8e27f51845c6f7e8fbfbaf"

js-cookie@^2.1.4:
version "2.2.0"
resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.0.tgz#1b2c279a6eece380a12168b92485265b35b1effb"

js-tokens@^3.0.0, js-tokens@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
Expand Down Expand Up @@ -5476,6 +5535,10 @@ query-string@^4.1.0:
object-assign "^4.1.0"
strict-uri-encode "^1.0.0"

querystring-browser@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/querystring-browser/-/querystring-browser-1.0.4.tgz#f2e35881840a819bc7b1bf597faf0979e6622dc6"

querystring-es3@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
Expand Down
6 changes: 5 additions & 1 deletion config/security.env.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
REACT_APP_GRAPHQL_ENDPOINT=http://localhost:4000/graphql
REACT_APP_HANDLE=LeoDiCaprio
REACT_APP_CONSUMER_KEY=N7vFfwCK4nM3DmzYZH4sTFKbS
REACT_APP_SECRET_KEY=HsrhKwC29Wtv6sJZEsU9UOtjnGpSn0a1PdjidvOQGKkNffJW7h
REACT_APP_SECRET_KEY=HsrhKwC29Wtv6sJZEsU9UOtjnGpSn0a1PdjidvOQGKkNffJW7h
REACT_APP_AWS_AUTH_REGION=us-east-1
REACT_APP_AWS_CLIENT_REGION=us-east-1
REACT_APP_USER_POOL_ID=xxx
REACT_APP_CLIENT_APP_ID=xxx
4 changes: 4 additions & 0 deletions config/security.env.prod
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ REACT_APP_CONSUMER_KEY=N7vFfwCK4nM3DmzYZH4sTFKbS
REACT_APP_SECRET_KEY=HsrhKwC29Wtv6sJZEsU9UOtjnGpSn0a1PdjidvOQGKkNffJW7h
DATABASE_URL="<your custom DB endpoint e.g. postgres://${username}:{password}@${endpoint):5432/${dbName}>"
DATABASE_TYPE="<pg || mysql>"
REACT_APP_AWS_AUTH_REGION=us-east-1
REACT_APP_AWS_CLIENT_REGION=us-east-1
REACT_APP_USER_POOL_ID=xxx
REACT_APP_CLIENT_APP_ID=xxx