GithubHelp home page GithubHelp logo

anomalyinnovations / serverless-stack-demo-client Goto Github PK

View Code? Open in Web Editor NEW
637.0 25.0 204.0 4.96 MB

Source for the demo app client in the Serverless Stack Guide

Home Page: https://demo2.serverless-stack.com

License: MIT License

HTML 7.20% CSS 5.55% JavaScript 87.25%
react react-bootstrap aws-cognito react-router amplify

serverless-stack-demo-client's People

Contributors

dependabot[bot] avatar fwang avatar jayair avatar paulgalow avatar pavindulakshan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

serverless-stack-demo-client's Issues

Trying to get notes from localhost throws 403

Though I am logged in as a valid user, I can neither get nor create notes from localhost. I keep getting 403 { missing authorization token}. Can someone help with this?

Getting this error response

User: arn:aws:sts::abjkdbfjadfafd:assumed-role/notes-app-api-dev-CognitoAuthRole-hajfhdjkfhdf/CognitoIdentityCredentials is not authorized to perform: execute-api:Invoke on resource: arn:aws:execute-api:us-east-1:********7995:1nfaldncc5/dev/GET/notes

Is AuthenticatedRoute.js really needed?

Through app.js

async componentDidMount() {
    try {
      if (await Auth.currentSession()) {
        this.userHasAuthenticated(true);
      }
    }
    catch(e) {
      if (e !== 'No current user') {
        alert(e);
      }
      this.props.history.push("/");   // Simply add this line to protect all path
    }
    this.setState({ isAuthenticating: false });
  }

Why do you want to use AuthenticatedRoute.js ?

[question] how to manage the api gateway paths without define them one by one in Routes.js

Very thanks to create this demo that I can easily start a Cognito UI in 5 minutes (the only change is to replace src/config.js with my cognito details)

But when go through src/Routes.js, I realised that I need define api gateway paths individually

In this demo, you made paths Notes and Notes/{id} with backend serverless API

  create:
    handler: create.main
    events:
      - http:
          path: notes
          method: post
          cors: true
          authorizer: aws_iam

  get:
    handler: get.main
    events:
      - http:
          path: notes/{id}
          method: get
          cors: true
          authorizer: aws_iam

But I have a lot of paths in api gateway events, do I have to write routes for each path? I don't want to do that.

So how to manage the api gateway paths without define them one by one in src/Routes.js? After cognito login, it should redirects the access to backend API gateway, let API gateway takes over the rest.

NotAuthorizedException

Kept getting NotAuthorizedException response from registration/login
{ "__type":"NotAuthorizedException", "message":"Unable to verify secret hash for client ****************" }

The Redirection on login broken

The Redirection on login seems broken.

To reproduce

  1. get a link of notes like :
    http://localhost:3000/notes/1bbbcb50-5ca9-11e7-a06c-01d04c457710

  2. logout

  3. paste the link in browser and key in user name pass word to login.

  4. After login will see the message :

proxyConsole.js:56 Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the Notes component.

[feature] amazon-cognito-identity-js has been replaced by AWS Amplify

This demo gives a lot of help on how to use Cognito, but recently aws archived one sdk used in this demo: amazon-cognito-identity-js and move on with AWS Amplify.

https://github.com/aws/amazon-cognito-identity-js

Amazon Cognito Identity SDK for JavaScript

NOTE: We have discontinued developing this library as part of this GitHub repository. We will continue to develop it as part of the AWS Amplify GitHub repository. You can still reach us by creating an issue on the AWS Amplify GitHub repository or posting to the Amazon Cognito Identity forums. Versions 1.x will still be available via NPM. Future development will continue on the 2.x versions.

Would you please change the codes to use AWS Amplify?

Thanks.

Reload of app on RouteNavItem

Hello,
Thanks for a great tutorial.
For those who want to use the components in an application, I have noticed a small glitch on the RouteNavItem component:
The onclick is overriden without a preventDefault which leads to both a standard navigation on the link and get on the server as well as the history push. This causes the page to be loaded as well, loosing the AWS.config.credentials, leading to a retrieval of the credentials from storage and refresh of the token at every navigation from a navbar link plus aborted APIG calls as the page reloads while executing.
On the current app this effect is limited as navigations are mostly programmatic (e.g. login page redirect to home, note detail opening/editing) but can still be noted from a note, navigating to the home page.
For expanded apps with several menus with APIG initial loading, the effect will be far more noticeable with APIG

alert messages popping out and a luggish load of the containers (done twice).

I would suggest the following change on RouteNavItems.js (12):

    onClick={e => {e.preventDefault(); history.push(e.currentTarget.getAttribute("href"));}}

only the push is executed, removing issues of server back and forth and aborted APIG calls.
Hope it helps.
Cheers,
Charles

500 Error after ListAllNotes section

Hi,
So far everything has ran well and passed all the tests. I could upload my files as well and I see them in my DynamoDB. However, I am currently getting a 500 error when I load my page after implementing the renderNotesList function in Home.js. When inspecting and clicking on /prod url, it says ""error": "One or more parameter values were invalid: Condition parameter type does not match schema type"". I looked through the discourse and the only thing I could find was to check DynamoDB to make sure I have the correct attribute names, which I do. Any help is appreciated,
Thanks.

Exception in signOut

Hitting this in the Auth.signOut() call:

TypeError: Cannot read property 'clearCachedId' of null

I've actually wrapped the call in a try-catch, as it swallows the exception and does nothing otherwise.

Must be an aws-amplify issue, however.

Login.js Ln 58

how come this line is missing 0 as mentioned in the tutorial

this.props.history.push("/");

[Question] post deploy script

"postdeploy": "aws cloudfront create-invalidation --distribution-id E1KTCKT9SOAHBW --paths '/*' && aws cloudfront create-invalidation --distribution-id E3MQXGQ47VCJB0 --paths '/*'",

Why have 2 distribution ID?

TypeError: __WEBPACK_IMPORTED_MODULE_3__sigV4Client__.a.newClient(...).signRequest is not a function

Several people are getting this error, but have opened the issue under the wrong project:

sst/sst.dev#114

TypeError: WEBPACK_IMPORTED_MODULE_3__sigV4Client.a.newClient(...).signRequest is not a function

I've confirmed that my awsLib.js and sigV4Client.js are identical to the source in github. This issue seems to only occur upon login. If I reload the page (hard refresh) the homepage with items renders just fine. I'm guessing it has something to do with the proximity of the AWS call to Lambda, and the login/authentication?

I'm not finding a resolution - any ideas?

sourcemaps and debugging

Anyone found it hard to hit breakpoints or set them up in chrome with this version of create react app?

Ie see how some of these are greyed out

image

How to isolate login page?

    <UnauthenticatedRoute path="/login" exact component={Login} props={childProps} />
    <AuthenticatedRoute path="/settings" exact component={Settings} props={childProps} />

How to implement login page without Navbar ?
I want to show Navbar when I have logged in.

Same users on multiple windows stay signed in.

Hi team, The issue is with multiple sign-outs of the same user.

The other day I was experimenting a feature which is known as global sign out of the same user across devices and what I saw that I wasn't able to logout automatically from one screen/device and stayed signed in when I signed out from the other screen/device with the same user signed in both the screens/devices.

What could be done to mitigate this issue?

How to use cognito groups

I want to create admin and user permissions to get different menu by using cognito groups(Admin, User).
how to determine which current user's identity is admin or user ?
how to add a user into groups after signup?

SyntaxError: Unexpected end of JSON input

What is happening:

When posting a new note on /notes/new a alert error is displayed 'SyntaxError: Unexpected end of JSON input'.
No note is posted to AWS

What is expected to happen:

Note is posted to AWS without error

Steps to reproduce

In ./src/libs/awsLib.js -> Function invokeApi
If the return has results.json() on the end the error will display. Removing .json() will post the note.

However, if .json() is remove when displaying the default route (./src/containers/Home.js) then the web app fails with error 'Unhandled Rejection (TypeError): Cannot read property 'trim' of undefined'

Concern for a possible memory leak and performance issue.

In your new updated version of RouteNavItem.js you have put a lambda in the render method.

The problem with these types methods is that they can not be referenced a second time causing them to be recreated in memory. Depending on how often this is being rendered this can cause a significant memory leak and performance hit.

I recommend assigning the method's memory address to a container.
const clickHandler = (e) => { ... }

Login as home page?

I've tried a few different ways to make the login page the default home page, but can't seem to get it to work without causing weird issues with being unauth'd or having the URL not land.

What's the proper way to setup the route so the login page is the home page, and also the fallback for logout and 404?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.