Serverless Apps with Node and Claudia.js
Slobodan Stojanović and Aleksandar Simović
  • MEAP began October 2017
  • Publication in June 2018 (estimated)
  • ISBN 9781617294723
  • 385 pages (estimated)
  • printed in black & white

First the buzzwords: Serverless computing. AWS Lambda. API Gateway. Node.js. Microservices. Cloud-hosted functions. That's an impressive-sounding list, but what's the point? Beyond the buzzwords are real benefits like fast design-to-deployment times, low hosting costs, and efficient scaling and application management, along with real technologies that deliver them.

Serverless Apps with Node and Claudia.js walks you through building serverless apps on AWS using JavaScript. Inside, you'll create a full project designed to help you understand and apply general serverless design principles and concepts. Along the way, you'll also discover what Claudia brings to the table as you build and deploy a scalable event-based serverless application that is fully integrated with AWS services including Lambda and API Gateway. You'll learn to simplify the design and development process so you can focus on getting your application deployed as fast as possible without sacrificing quality. Plus, you'll learn how to migrate your existing Express apps to serverless!

"A compelling introduction to serverless deployments using Claudia.js."

~ Jasba Simpson

"This book is really great for any newbie to the serverless paradigm."

~ Luca Mezzalira

"The concepts of Serverless Architecture are presented clearly and realistically, also giving guidance when Serverless might not be the correct solutions."

~ Kaj Strom

Table of Contents detailed table of contents

Part 1: Serverless Pizzeria

1 Introduction to serverless with Claudia

1.1 Servers and washing machines

1.2 The core concepts

1.3 How does serverless work?

1.4 Serverless in practice

1.4.1 Aunt Maria’s serverless pizzeria

1.4.2 A common approach

1.4.3 Serverless approach

1.5 Serverless infrastructure — AWS

1.6 What is Claudia, and how does it fit?

1.7 When and where should you use it?

1.8 Summary

2 Building your first serverless API

2.1 Assembling pizza ingredients: Building the API

2.1.1 Which pizza can I GET?

2.1.2 Structuring your API

2.1.3 POSTing an order

2.2 How Claudia deploys your API

2.3 Traffic control: How API Gateway works

2.4 When a serverless API is not the solution

2.5 Taste it!

2.5.1 Exercise

2.5.2 Solution

2.6 Summary

3 Asynchronous work is easy, we Promise()

3.1 Storing the orders

3.2 Promising to deliver in less than 30 minutes!

3.3 Trying out your API

3.4 Getting orders from the database

3.5 Taste it!

3.5.1 Exercise

3.5.2 Solution

3.6 Summary

4 Pizza delivery: Connecting an external service

4.1 Connecting to an external service

4.2 Connecting to the delivery API

4.2.1 The Some Like It Hot Delivery API

4.2.2 Creating your first delivery request

4.3 Potential issues with async communication

4.3.1 Forgetting to return a promise

4.3.2 Not passing the value from the promise

4.3.3 Not wrapping the external service in a promise

4.3.4 Timeout issues with long async operations

4.4 Taste it!

4.4.1 Exercise

4.4.2 Solution

4.5 Summary

5 Houston, we have a problem!

5.1 Debugging a serverless app

5.2 Debugging your Lambda function

5.3 X-Ray your app

5.4 Taste it!

5.4.1 Exercise

5.4.2 Solution

5.5 Summary

6 Level up your API

6.1 Serverless authentication and authorization

6.2 Creating user and identity pools

6.2.1 Controlling API access with Cognito

6.3 Taste it!

6.3.1 Exercise

6.3.2 Solution

6.4 Summary

7 Working with files

7.1 Storing static files in a serverless application

7.2 Generating thumbnails

7.2.1 Deploying your S3 function

7.3 Taste it!

7.3.1 Exercise

7.3.2 Solution

7.4 End of part 1: Special exercise

7.4.1 Advanced task

7.5 Summary

Part 2: Let’s Talk

8 When pizza is one message away: Chatbots

8.1 Pizza ordering beyond the browser

8.2 Hello from Facebook Messenger

8.3 What kinds of pizzas do you have?

8.4 Speeding up the deployment

8.5 Messenger templates

8.6 How does Claudia Bot Builder work?

8.7 Taste it!

8.7.1 Exercise

8.7.2 Solution

8.8 Summary

9 Typing…​ Async and delayed responses

9.1 Making chatbots interactive

9.1.1 Click to order: Answering a postback

9.2 Making the chatbot structure more scalable

9.3 Connecting your chatbot to the DynamoDB database

9.4 Getting the user’s location from the chatbot

9.5 Scheduling a delivery

9.6 Small talk: Integrating simple NLP

9.7 Taste it!

9.7.1 Exercise

9.7.2 Solution

9.7.3 Advanced exercise

9.8 Summary

10 Blah, blah, blah

10.1 Can’t talk right now: Sending an SMS with Twilio

10.1.1 An SMS pizza list

10.1.2 Ordering a pizza

10.2 Hey Alexa!

10.2.1 Anatomy of an Alexa skill

10.2.2 Preparing the skill

10.2.3 Ordering pizza with Alexa

10.3 Taste it!

10.3.1 Exercise

10.3.2 Solution

10.4 End of part 2: Special exercise

10.5 Summary

Part 3: Next Steps

11 Testing, Testing, 1, 2, 3

11.1 Testing server-hosted and serverless applications

11.2 How to approach testing serverless applications

11.3 Preparation

11.4 Unit tests

11.5 Mocking your serverless functions

11.6 Integration tests

11.7 Other types of automated testing

11.8 A step beyond: Writing testable serverless functions

11.9 Taste it!

11.9.1 Exercise

11.9.2 Solution

11.10 Summary

12 Paying for pizza

12.1 Payment transactions

12.1.1 Implementing an online payment

12.2 Implementing your payment service

12.3 Could someone hack your payment service?

12.3.1 Standards

12.3.2 Competence

12.4 Taste it!

12.4.1 Exercise

12.4.2 Solution

12.5 Summary

13 Migrating your existing Express.js app to AWS Lambda

13.1 Uncle Roberto’s taxi application

13.2 Running an Express.js application in AWS Lambda

13.2.1 Proxy integration

13.2.2 How serverless-express works

13.3 Serving static content

13.4 Connecting to MongoDB

13.4.1 Using a managed MongoDB database with your serverless Express.js app

13.5 Limitations of serverless Express.js applications

13.6 Taste it!

13.6.1 Exercise

13.6.2 Solution

13.7 Summary

14 Migrating to serverless

14.1 Analyzing your current serverless application

14.2 Migrating your existing application to serverless

14.3 Embrace the platform

14.3.1 Serving static files

14.3.2 Storing state

14.3.3 Logs

14.3.4 Continuous integration

14.3.5 Managing environments: Production and development

14.3.6 Sharing secrets

14.3.7 VPC (Virtual Private Cloud)

14.4 Optimizing your application

14.4.1 Bundled or single-purpose functions

14.4.2 Choosing the right memory size for your Lambda function

14.5 Facing the challenges

14.5.1 Handling timeouts

14.5.2 Cold starts

14.5.3 DDoS attacks

14.5.4 Vendor lock-in

14.6 Taste it!

14.7 Summary

15 Real-world use cases

15.1 CodePen

15.1.1 Before serverless

15.1.2 Serverless migration

15.1.3 Cost of the infrastructure

15.1.4 Testing and challenges

15.1.5 CodePen recommendations

15.2 MindMup

15.2.1 Before serverless

15.2.2 Serverless migration

15.2.3 Cost of the infrastructure

15.2.4 Testing, logs, and challenges

15.3 Summary


Appendix A: A Installation and configuration

A.1 Installing Claudia

A.1.1 Configuring Claudia prerequisites

A.1.2 Creating an AWS profile and getting the keys

A.1.3 Installing Claudia API Builder

A.1.4 Installing Claudia Bot Builder

A.2 Installing the AWS CLI

Appendix B: B Facebook Messenger, Twilio, and Alexa configuration

B.1 Facebook Messenger setup

B.1.1 Creating a Facebook page

B.1.2 Creating a Facebook app

B.1.3 Creating a Facebook Messenger chatbot using Claudia Bot Builder

B.1.4 Enabling built-in NLP

B.2 Twilio setup

B.2.1 Creating a Twilio account

B.2.2 Getting a Twilio number

B.2.3 Setting up your Twilio Programmable SMS service

B.3 Alexa skill setup

Appendix C: C Setting up your Stripe account and retrieving Stripe API keys

C.1 Setting up your Stripe account and retrieving Stripe API keys

C.1.1 Creating a Stripe account

C.1.2 Getting your Stripe API keys

C.2 Installing and configuring MongoDB

C.2.1 Creating an account

C.2.2 Configuring your cluster

Appendix D: D The pizza recipe

About the Technology

Serverless computing services like AWS Lambda and API Gateway can be tedious to set up, aren't designed to work well with JavaScript and Node, and most of the quirks and gotchas aren't well documented. A new generation of serverless tools, including Claudia.js, make it radically easier to set up serverless web applications so you can focus on what your app does instead of meddling with infrastructure configuration and deployment. Claudia doesn't alter your project layout or abstract away the core AWS services; it just makes it easier to get started with them!

What's inside

  • Creating a serverless API using AWS Lambda and Claudia.js
  • Doing authentication and database storage in a serverless way
  • Creating a chatbot for multiple platforms
  • Building a voice assistant with Amazon Alexa
  • Developing microservices with Node.js, AWS Lambda, S3, and more

About the reader

Written for beginner and intermediate web developers comfortable with JavaScript and Node.js. Some prior experience with AWS is required.

About the authors

Slobodan Stojanović and Aleksandar Simović are core contributors to the Claudia.js project and are the lead developers and maintainers of Claudia Bot Builder. They work closely with Claudia.js founder Gojko Adzic, and present serverless and Claudia.js at conferences and workshops.

Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
MEAP combo $44.99 pBook + eBook + liveBook
MEAP eBook $35.99 pdf + ePub + kindle + liveBook

FREE domestic shipping on three or more pBooks