Serverless Applications with Node.js

Book description

Serverless Applications with Node.js walks you through building serverless apps on AWS using JavaScript. Inside, you'll discover what Claudia.js brings to the table as you build and deploy a scalable event-based serverless application, based around a pizzeria that’s fully integrated with AWS services, including Lambda and API Gateway. Each chapter is filled with exercises, examples, tips, and more to make sure you’re ready to bring what you’ve learned into your own work.



About the Technology

The benefits of cloud-hosted serverless web apps are undeniable: lower complexity, quicker time to market, and easier scalability than traditional, server-dependent designs. And thanks to JavaScript support in AWS Lambda and powerful new serverless API tools like the Claudia.js library, you can build and deploy serverless apps end to end without learning a new language.



About the Book

Serverless Applications with Node.js teaches you to design and build serverless web apps on AWS using JavaScript, Node, and Claudia.js. You’ll master the basics of writing AWS Lambda functions, along with core serverless patterns like API Gateway. Along the way, you’ll practice your new skills by building a working chatbot and a voice assistant with Amazon Alexa. You’ll also discover techniques for migrating existing apps to a serverless platform.



What's Inside

  • Authentication and database storage
  • Asynchronous functions
  • Interesting real-world examples
  • Developing serverless microservices


About the Reader

For web developers comfortable with JavaScript and Node.js.



About the Authors

Slobodan Stojanović and Aleksandar Simović are AWS Serverless Heroes and core contributors to the Claudia.js project. They are also coauthors of Desolé, an open source serverless errortracking tool, and the lead developers of Claudia Bot Builder.



Quotes
Teaches you how to get simple stuff done in AWS Lambda quickly, without trying to change the way you structure or run projects.
- From the Foreword by Gojko Adzic, Neuri Consulting

A top-notch and hands-on resource written by world-renowned experts who will get you up to speed in no time with AWS Lambda using Claudia.js.
- Valentin Crettaz, Consulthys

One of the most comprehensive books published on the topic; contains a wealth of resources that you will not find online.
- Damian Esteban, BetterPT

Table of contents

  1. Titlepage
  2. Copyright
  3. preface
  4. acknowledgments
  5. about this book
    1. Who should read this book
    2. How this book is organized
    3. About the code
    4. Book forum
    5. Online resources
  6. about the authors
  7. about the cover illustration
  8. Part 1: Serverless pizzeria
    1. Chapter 1: Introduction to serverless with Claudia
      1. 1.1 Servers and washing machines
      2. 1.2 The core concepts
      3. 1.3 How does serverless work?
      4. 1.4 Serverless in practice
        1. 1.4.1 Aunt Maria’s serverless pizzeria
        2. 1.4.2 A common approach
        3. 1.4.3 Serverless approach
      5. 1.5 Serverless infrastructure — AWS
      6. 1.6 What is Claudia, and how does it fit?
      7. 1.7 When and where you should use it
      8. Summary
    2. Chapter 2: Building your first serverless API
      1. 2.1 Assembling pizza ingredients: building the API
        1. 2.1.1 Which pizza can I GET?
        2. 2.1.2 Structuring your API
        3. 2.1.3 POSTing an order
      2. 2.2 How Claudia deploys your API
      3. 2.3 Traffic control: How API Gateway works
      4. 2.4 When a serverless API is not the solution
      5. 2.5 Taste it!
        1. 2.5.1 Exercise
        2. 2.5.2 Solution
      6. Summary
    3. Chapter 3: Asynchronous work is easy, we Promise()
      1. 3.1 Storing the orders
      2. 3.2 Promising to deliver in less than 30 minutes!
      3. 3.3 Trying out your API
      4. 3.4 Getting orders from the database
      5. 3.5 Taste it!
        1. 3.5.1 Exercise
        2. 3.5.2 Solution
      6. Summary
    4. Chapter 4: Pizza delivery: Connecting an external service
      1. 4.1 Connecting to an external service
      2. 4.2 Connecting to the delivery API
        1. 4.2.1 The Some Like It Hot Delivery API
        2. 4.2.2 Creating your first delivery request
      3. 4.3 Potential issues with async communication
        1. 4.3.1 Forgetting to return a promise
        2. 4.3.2 Not passing the value from the promise
        3. 4.3.3 Not wrapping the external service in a promise
        4. 4.3.4 Timeout issues with long async operations
      4. 4.4 Taste it!
        1. 4.4.1 Exercise
        2. 4.4.2 Solution
      5. Summary
    5. Chapter 5: Houston, we have a problem!
      1. 5.1 Debugging a serverless app
      2. 5.2 Debugging your Lambda function
      3. 5.3 X-Ray your app
      4. 5.4 Taste it!
        1. 5.4.1 Exercise
        2. 5.4.2 Solution
      5. Summary
    6. Chapter 6: Level up your API
      1. 6.1 Serverless authentication and authorization
      2. 6.2 Creating user and identity pools
        1. 6.2.1 Controlling API access with Cognito
      3. 6.3 Taste it!
        1. 6.3.1 Exercise
        2. 6.3.2 Solution
      4. Summary
    7. Chapter 7: Working with files
      1. 7.1 Storing static files in a serverless application
      2. 7.2 Generating thumbnails
        1. 7.2.1 Deploying your S3 function
      3. 7.3 Taste it!
        1. 7.3.1 Exercise
        2. 7.3.2 Solution
      4. 7.4 End of part 1: Special exercise
        1. 7.4.1 Advanced task
      5. Summary
  9. Part 2: Let’s talk
    1. Chapter 8: When pizza is one message away: Chatbots
      1. 8.1 Pizza ordering beyond the browser
      2. 8.2 Hello from Facebook Messenger
      3. 8.3 What kinds of pizzas do you have?
      4. 8.4 Speeding up the deployment
      5. 8.5 Messenger templates
      6. 8.6 How does Claudia Bot Builder work?
      7. 8.7 Taste it!
        1. 8.7.1 Exercise
        2. 8.7.2 Solution
      8. Summary
    2. Chapter 9: Typing... Async and delayed responses
      1. 9.1 Making chatbots interactive
        1. 9.1.1 Tap to order: answering a postback
      2. 9.2 Making the chatbot structure more scalable
      3. 9.3 Connecting your chatbot to the DynamoDB database
      4. 9.4 Getting the user’s location from the chatbot
      5. 9.5 Scheduling a delivery
      6. 9.6 Small talk: Integrating simple NLP
      7. 9.7 Taste it!
        1. 9.7.1 Exercise
        2. 9.7.2 Solution
        3. 9.7.3 Advanced exercise
      8. Summary
    3. Chapter 10: Jarvis, I mean Alexa, order me a pizza
      1. 10.1 Can’t talk right now: sending an SMS with Twilio
        1. 10.1.1 An SMS pizza list
        2. 10.1.2 Ordering a pizza
      2. 10.2 Hey Alexa!
        1. Anatomy of an Alexa skill
        2. 10.2.1 Preparing the skill
        3. 10.2.2 Ordering pizza with Alexa
      3. 10.3 Taste it!
        1. 10.3.1 Exercise
        2. 10.3.2 Solution
      4. 10.4 End of part 2: special exercise
      5. Summary
  10. Part 3: Next steps
    1. Chapter 11: Testing, Testing, 1, 2, 3
      1. 11.1 Testing server-hosted and serverless applications
      2. 11.2 How to approach testing serverless applications
      3. 11.3 Preparation
      4. 11.4 Unit tests
      5. 11.5 Mocking your serverless functions
      6. 11.6 Integration tests
      7. 11.7 Other types of automated testing
      8. 11.8 A step beyond: Writing testable serverless functions
      9. 11.9 Taste it!
        1. 11.9.1 Exercise
        2. 11.9.2 Solution
      10. Summary
    2. Chapter 12: Paying for pizza
      1. 12.1 Payment transactions
        1. 12.1.1 Implementing an online payment
      2. 12.2 Implementing your payment service
      3. 12.3 Could someone hack your payment service?
        1. 12.3.1 Standards
        2. 12.3.2 Competence
      4. 12.4 Taste it!
        1. 12.4.1 Exercise
        2. 12.4.2 Solution
      5. Summary
    3. Chapter 13: Migrating your existing Express.js app to AWS Lambda
      1. 13.1 Uncle Roberto’s taxi application
      2. 13.2 Running an Express.js application in AWS Lambda
        1. 13.2.1 Proxy integration
        2. 13.2.2 How serverless-express works
      3. 13.3 Serving static content
      4. 13.4 Connecting to MongoDB
        1. 13.4.1 Using a managed MongoDB database with your serverless Express.js app
      5. 13.5 Limitations of serverless Express.js applications
      6. 13.6 Taste it!
        1. 13.6.1 Exercise
        2. 13.6.2 Solution
      7. Summary
    4. Chapter 14: Migrating to serverless
      1. 14.1 Analyzing your current serverless application
      2. 14.2 Migrating your existing application to serverless
      3. 14.3 Embrace the platform
        1. 14.3.1 Serving static files
        2. 14.3.2 Storing state
        3. 14.3.3 Logs
        4. 14.3.4 Continuous integration
        5. 14.3.5 Managing environments: production and development
        6. 14.3.6 Sharing secrets
        7. 14.3.7 VPC (Virtual Private Cloud)
      4. 14.4 Optimizing your application
        1. 14.4.1 Bundled or single-purpose functions
        2. 14.4.2 Choosing the right memory size for your Lambda function
      5. 14.5 Facing the challenges
        1. 14.5.1 Handling timeouts
        2. 14.5.2 Cold starts
        3. 14.5.3 DDoS attacks
        4. 14.5.4 Vendor lock-in
      6. 14.6 Taste it!
      7. Summary
    5. Chapter 15: Real-world case studies
      1. 15.1 CodePen
        1. 15.1.1 Before serverless
        2. 15.1.2 Serverless migration
        3. 15.1.3 Cost of the infrastructure
        4. 15.1.4 Testing and challenges
      2. 15.2 MindMup
        1. 15.2.1 Before serverless
        2. 15.2.2 Serverless migration
        3. 15.2.3 Cost of the infrastructure
        4. 15.2.4 Testing, logs, and challenges
      3. Summary
  11. Appendix A: Installation and configuration
    1. Installing Claudia
      1. Configuring Claudia prerequisites
      2. Creating an AWS profile and getting the keys
      3. Installing Claudia API Builder
      4. Installing Claudia Bot Builder
    2. Installing the AWS CLI
  12. Appendix B: Facebook Messenger, Twilio, and Alexa configuration
    1. Facebook Messenger setup
      1. Creating a Facebook page
      2. Creating a Facebook app
      3. Creating a Facebook Messenger chatbot using Claudia Bot Builder
      4. Enabling built-in NLP
    2. Twilio setup
      1. Creating a Twilio account
      2. Getting a Twilio number
      3. Setting up your Twilio Programmable SMS service
    3. Alexa skill setup
  13. Appendix C: Stripe and MongoDB setup
    1. Setting up your Stripe account and retrieving Stripe API keys
      1. Creating a Stripe account
      2. Getting your Stripe API keys
    2. Installing and configuring MongoDB
      1. Creating an account
      2. Configuring your cluster
  14. Appendix D: The pizza recipe
  15. Index
  16. List of Figures
  17. List of Tables
  18. List of Listings

Product information

  • Title: Serverless Applications with Node.js
  • Author(s): Aleksandar Simovic, Slobodan Stojanovic
  • Release date: March 2019
  • Publisher(s): Manning Publications
  • ISBN: 9781617294723