GithubHelp home page GithubHelp logo

benrady / learnjs Goto Github PK

View Code? Open in Web Editor NEW
167.0 12.0 1.7K 1.33 MB

Prepared Workspace for "Serverless Single Page Apps" @ Pragprog

Home Page: https://pragprog.com/book/brapps

Shell 8.10% JavaScript 89.73% HTML 1.47% Makefile 0.47% Python 0.23%

learnjs's Introduction

Change Log

Beta 3 Changes

  • Compensating for AWSCLI timing issues when creating roles

Beta 2 Changes

  • Now using 'admin' profile instead of default profile
  • Added create_service action to sspa
  • deploy_bucket can now take a config path

MIT License

Note: The license below applies only to the contents of this git repository, not the Pragmatic Bookshelf title "Serverless Single Page Apps", or any other related content.

Copyright (c) 2015 Ben Rady [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Creative Commons Attributions

  • HeroImage.jpg is licensed from popularwoodworking.com under the Creative Commons Attribution License (CC BY 3.0 US).

learnjs's People

Contributors

8bit-pixies avatar benrady avatar hwine avatar jrsacks avatar junichim 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

learnjs's Issues

admin hardcoded in sspa script

On lines 182 and 184 the sspa script has --profile admin instead of --profile $profile.
Also, would you consider covering more about python and boto3 ?
Thanks for writing the book.

Failed test once switched the ‘problemView’ implementation to use a template

Two tests failed once I switched the 'problemView' implementation to use a template. In particular, they are:

it('can show a problem view', function() {
  learnjs.showView('#problem-1');
  expect($('.markup .problem-view').length).toEqual(1);
});

and

it('has a title that include the problem number', function() {
  var view = learnjs.problemView('1');
  expect(view.text()).toEqual("Problem #1 coming soon!")
})

The before and after code of problemView() are:

Chapter 2 'Loading the Application' page 39

learnjs.problemView = function(problemNumber) {
  var title = 'Problem #' + problemNumber + ' Coming soon!';
  return $('<div class="problem-view">').text(title);
}

Chapter 3 'Essentials of Single Page Apps' page 50

 learnjs.problemView = function(problemNumber) {
   var view = $('.templates .problem-view').clone();
   view.find('.title').text('Problem #' + problemNumber);
   return view;
}

The app functions as intended. The problem seems to be the template based views were not put in the 'markup' div properly. Does it happen to other people too?

sspa script fails on function creation

As posted on the pragprog forums, the sspa script can sometimes fail when creating a Lambda function because the aws command line tool returns a zero return code even though the specific profile does not yet exist.

I'm hoping to find a way to detect this condition in another way, but in the meantime, I'm changing the sspa script to sleep for 5 seconds after creating the profile.

sspa server command does not work with Python 3+

Having Python 3.5.2 I cannot run the follwing command

learnjs $ ​​./sspa​​ ​​server​

I get python.exe: No module named SimpleHTTPServer

I guess for Python 3+

python -m http.server

should be used instead.
Adding simple check to sspa script would be sufficient.

Completed Code

Can we please have the completed code for this book by chapter?

getting error while coding along in DynamoDB chapter

So in chapter 5 I added all the code shown, but now on localhost I get:

vendor.js:5 POST https://cognito-identity.us-east-1.amazonaws.com/ 400

error. it seems to be originating in:

learnjs.awsRefresh = function () {
  var deferred = new $.Deferred();
  AWS.config.credentials.refresh(function (err) {
    if (err) {
      deferred.reject(err);
    } else {
      deferred.resolve(AWS.config.credentials.identityId);
    }
  });
  return deferred.promise();
}

function googleSignIn(googleUser) {
  var id_token = googleUser.getAuthResponse().id_token;
  AWS.config.update({
    region: 'us-east-1',
    credentials: new AWS.CognitoIdentityCredentials({
      IdentityPoolId: learnjs.poolId,
      Logins: {
        'accounts.google.com': id_token
      }
    })
  })
  function refresh() {
    return gapi.auth2.getAuthInstance().signIn({
      prompt: 'login'
    }).then(function (userUpdate) {
      var creds = AWS.config.credentials;
      var newToken = userUpdate.getAuthResponse().id_token;
      creds.params.Logins['accounts.google.com'] = newToken;
      return learnjs.awsRefresh();
    });
  }
  learnjs.awsRefresh().then(function (id) {
    learnjs.identity.resolve({
      id: id,
      email: googleUser.getBasicProfile().getEmail(),
      refresh: refresh
    });
  });
} 
  1. What does this error mean and how do I fix it?

Many thanks!

Error when running ./sspa create_bucket learnjs.amblet.net

When I run the command ./sspa create_bucket learnjs.amblet.net I get the following error.

./sspa create_bucket learnjs.amblet.net
make_bucket failed: s3://learnjs.amblet.net/ A client error (SignatureDoesNotMatch) occurred when calling the CreateBucket operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.

./sspa: line 53: conf/s3/learnjs.amblet.net/endpoint.txt: No such file or directory
Website endpoint is: http://learnjs.amblet.net.s3-website-eu-west-1.amazonaws.com

A client error (SignatureDoesNotMatch) occurred when calling the PutBucketWebsite operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.

Any idea on what might be the root cause?

can't see my uploaded lambda function

Hi Ben,
I had to change the run time to node4.3 to get rid of an exception. Then after I run:
$ ./sspa create_service conf/lambda/functions/echo
The function does not appear in my aws web console.
any idea?

SSPA fails on an EC2 instance running the Amazon AMI

I can't use my work laptop with your script.
I have pre-existing development environments that are managed with Puppet and cannot be changed.
I cannot install npm, Python or Pip as required by your sspa script.

I have launched an EC2 instance with the Amazon AMI for this reason.

I could take a look at making changes to the SSPA script to accommodate individuals in a similar situation but wanted to check if I'm on the right track first.

Thanks.

sspa ... command not found

I am trying to your learnjs example on Windows 7
I have cygwin installed

Currently I get the following error when I run ./sspa server

./sspa: line 2: $'\r': command not found
./sspa: line 8: $'\r': command not found
./sspa: line 9: syntax error near unexpected token '$'{\r''
./sspa: line 9: 'function check_python() {

Do I also have to have python installed for this script to run?

Thanks

Handle EU S3 endpoints

The current sspa script does not handle generating S3 Web host URL endpoints for EU regions

./sspa server issue

I used git clone to copy to my local machine (ubuntu 14.04).
I am at learnjs root (young@young-PC:~/repository/js/learnjs in my machine) but I cannot start up sspa server.

young@young-PC:~/repository/js/learnjs$ ./sspa server
: No such file or directory

Authorization header is invalid

error when trying to create s3 bucket.

"when calling the PutBucketWebsite operation: Authorization header is invalid -- one and only one ' ' (space) required".

The error message also speaks of some endpoint.txt file that is missing.

./sspa server requires AWS

Currently the code, in master (66ff4a7), and the book, version B1.0, don't line up. You're told to run ./sspa server before you've set up your AWS config, but sspa now calls check_aws before it runs the server command, even though it doesn't really need it for the server command to succeed.

Timing issues with aws cli

The AWS CLI can return before certain operations are complete. For example, when creating a DynamoDB table, you can get a response where the TableDescription.TableStatus field is "CREATING".

This can make the sspa script fail, if the resource being created isn't ready by the time the script needs to use it. This has already been resolved once for IAM roles, but it is likely there are other places where this can occur.

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.