How to use the @aws-amplify/core.configure function in @aws-amplify/core

To help you get started, we’ve selected a few @aws-amplify/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yhenni1989 / Plush / src / components / Feed.js View on Github external
// Config imports
import config from '../aws-exports'
import keys from '../keys'

// GraphQL mutations and queries
import CreatePicture from '../graphQL/CreatePicture'
import DeletePicture from '../graphQL/DeletePicture'
import listPictures from '../graphQL/listPictures'
import CreateLikePicture from '../graphQL/CreateLikePicture'
import DeleteLikePicture from '../graphQL/DeleteLikePicture'
import CreateFlagPicture from '../graphQL/CreateFlagPicture'

// Apollo components
import { graphql, compose } from 'react-apollo'

Amplify.configure(config)

class Feed extends React.Component {
  state = {
    optionsVisible: false,
    pictures: [],
    pictureOwnerId: '',
    likeOwnerId: '',
    pictureOwnerUsername: '',
    likeOwnerUsername: '',
    refreshing: false
  }

  componentDidMount = async () => {
    await Auth.currentAuthenticatedUser()
      .then(user => {
        this.setState(
github yhenni1989 / Zopher / src / components / Posts.js View on Github external
import API, { graphqlOperation } from '@aws-amplify/api'
import Auth from '@aws-amplify/auth'
import Amplify from '@aws-amplify/core'

import { Card, Icon, Text } from 'native-base'

import config from '../aws-exports'
import { 
  createPost, 
  deletePost, 
  listPosts, 
  createLike, 
  deleteLike } from '../GraphQL/GraphQL'

// configure the app with Amplify 
Amplify.configure(config)

export default class Upload extends React.Component {
  state = { 
    posts: [],
    postsUser: '',
    postContent: '',
    postOwnerId: '',
    postOwnerUsername: '',
    modalVisible: false,
    likeOwnerUsername: '',
    likeOwnerId: '',
  }

  componentDidMount = async () => {
    await Auth.currentAuthenticatedUser()
    .then(user => {
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Authenticator.tsx View on Github external
componentDidMount() {
		const config = this.props.amplifyConfig;
		if (config) {
			Amplify.configure(config);
		}
		this._isMounted = true;
		// the workaround for Cognito Hosted UI
		// don't check the user immediately if redirected back from Hosted UI
		// instead waiting for the hub event sent from Auth module
		// the item in the localStorage is a mark to indicate whether
		// the app is redirected back from Hosted UI or not
		const byHostedUI = localStorage.getItem(
			Constants.SIGNING_IN_WITH_HOSTEDUI_KEY
		);
		localStorage.removeItem(Constants.SIGNING_IN_WITH_HOSTEDUI_KEY);
		if (byHostedUI !== 'true') this.checkUser();
	}
github systemaccounting / mxfactorial / react / src / index.js View on Github external
import React from 'react'
import ReactDOM from 'react-dom'
import { BrowserRouter } from 'react-router-dom'
import Amplify from '@aws-amplify/core' // https://github.com/aws-amplify/amplify-js/issues/3484

import Providers from 'providers'

import App from './App'
import './index.css'

Amplify.configure({
  Auth: {
    userPoolId: process.env.REACT_APP_POOL_ID || 'us-east-1_unit-test',
    userPoolWebClientId: process.env.REACT_APP_CLIENT_ID || 'unit-test'
  }
})

ReactDOM.render(
  
    
      
    
  ,
  document.getElementById('root')
)
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / Authenticator.jsx View on Github external
componentDidMount() {
        const config = this.props.amplifyConfig;
        if (config) {
            Amplify.configure(config);
        }
        this._isMounted = true;
        // the workaround for Cognito Hosted UI
        // don't check the user immediately if redirected back from Hosted UI
        // instead waiting for the hub event sent from Auth module
        // the item in the localStorage is a mark to indicate whether
        // the app is redirected back from Hosted UI or not
        const byHostedUI = localStorage.getItem(Constants.SIGN_IN_WITH_HOSTEDUI_KEY);
        localStorage.removeItem(Constants.SIGN_IN_WITH_HOSTEDUI_KEY);
        if (!byHostedUI) this.checkUser();
    }
github aws-amplify / amplify-js / packages / aws-amplify-angular / src / providers / auth.decorator.ts View on Github external
function listen(authState: Subject) {
	const config = Amplify.configure(null);
	if (_.has(config, 'Auth.oauth')) {
		Hub.listen(
			'auth',
			{
				onHubCapsule: capsule => {
					const { channel, payload } = capsule;
					if (channel === 'auth') {
						const { username } = payload.data;
						logger.debug('authentication oauth event', payload);
						authState.next({ state: payload.event, user: { username } });
					}
				},
			},
			'angularAuthListener'
		);
	}
github aws-amplify / amplify-js / packages / aws-amplify-react / src / Auth / AuthStateWrapper.tsx View on Github external
componentWillMount() {
		const config = this.props.amplifyConfig;
		if (config) {
			Amplify.configure(config);
		}
	}
github kneekey23 / ByteConf / ml-javascript / src / App.js View on Github external
import React, { Component } from 'react';
import './App.css';
import { Switch, Route } from 'react-router-dom'
import Polly from './components/Polly';
import Transcribe from './components/Transcribe';
import Main from './components/Main';
import Comprehend from './components/Comprehend';
import Rekognition from './components/Rekognition';
import Translate from './components/Translate';
import Amplify from '@aws-amplify/core';
import { AmazonAIPredictionsProvider } from '@aws-amplify/predictions';
import awsconfig from './aws-exports';

Amplify.configure(awsconfig);
Amplify.addPluggable(new AmazonAIPredictionsProvider());


class App extends Component {

  render() {
    return (
    )
  }
github sebsto / amplify-datastore-js-e2e / src / App.js View on Github external
import React, { useEffect, useState } from "react";
import logo from "./logo.svg";
import "./App.css";

import Amplify from "@aws-amplify/core";
import { DataStore, Predicates } from "@aws-amplify/datastore";

import { Post, PostStatus } from "./models";

import awsConfig from "./aws-exports";
Amplify.configure(awsConfig);

function onCreate() {
  DataStore.save(
    new Post({
      title: `New title ${Date.now()}`,
      rating: (function getRandomInt(min, max) {
        min = Math.ceil(min);
        max = Math.floor(max);
        return Math.floor(Math.random() * (max - min)) + min; //The maximum is exclusive and the minimum is inclusive
      })(1, 7),
      status: PostStatus.ACTIVE
    })
  );
}

function onDeleteAll() {
github awslabs / aws-full-stack-template / assets / src / index.tsx View on Github external
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter as Router } from "react-router-dom";
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import Amplify from "@aws-amplify/core";
import config from "./config";

import 'bootstrap/dist/css/bootstrap.css';

Amplify.configure({
  Auth: {
    mandatorySignIn: true,
    region: config.cognito.REGION,
    userPoolId: config.cognito.USER_POOL_ID,
    identityPoolId: config.cognito.IDENTITY_POOL_ID,
    userPoolWebClientId: config.cognito.APP_CLIENT_ID
  },
  API: {
    endpoints: [
      {
        name: "goals",
        endpoint: config.apiGateway.API_URL,
        region: config.apiGateway.REGION
      },
    ]
  }