Serverless Express – Easy APIs On AWS Lambda & AWS HTTP API

Serverless Express – Easy APIs On AWS Lambda & AWS HTTP API

Serverless Express enables you to easily host Express.js APIs on AWS Lambda and AWS HTTP API. Here is how to get started and deliver a Serverless Express.js based API with a custom domain, free SSL certificate and much more!

TLDR - Take existing Express.js apps and host them easily onto cheap, auto-scaling, serverless infrastructure on AWS Lambda and AWS HTTP API with Serverless Express. It's packed loads of production-ready features, like custom domains, SSL certificates, canary deployments, and costs ~$0.000003 per request.

If you simply want to host a common Express.js Node.js application, have it auto-scale to billions of requests, and charge you only when it's used, we have something special for you...

Announcing Serverless Express, a Serverless Framework offering enabling you to easily host and manage Express.js applications on AWS Lambda and the new AWS HTTP API, which is 60% faster and 71% cheaper than their initial API Gateway product.

Serverless Expess is a pure Express.js experience and it's perfect for those that want to focus on apps, not infrastructure complexity.

Here are the highlights:

  • Easy, Safe, Performance - Includes the optimal infrastructure pattern for cost, performance & scale.
  • Never Pay For Idle - No API requests? No cost. Averages ~$0.000003 per request.
  • Zero Configuration - Add your Express app, then deploy (advanced config options are available).
  • Fast Deployments - Deploy changes to the cloud in seconds.
  • Real-time Logging - Rapidly develop on the cloud w/ real-time logs and errors in the CLI.
  • Canary Deployments - Deploy your app gradually to a subset of your traffic.
  • Custom Domain + SSL - Auto-configure a custom domain w/ a free AWS ACM SSL certificate.
  • Team Collaboration - Collaborate with your teamates with shared state and outputs.

Here is how to get started and deliver a Serverless Express.js based API with a custom domain, free SSL certificate and much more! You can also check out our Serverless Fullstack Application boilerplate, which includes Serverless Express in a real-world example that features a database, website using React and more.

Set-Up

Serverless Express is a Serverless Framework Component (i.e premium experiences for popular serverless use-cases) and you'll need to install Node.js and the Serverless Framework CLI to use it.

Install Node.js here.

Then run this command to install Serverless Framework.

npm i -g serverless

Next, install the Serverless Express template:

serverless create --template-url https://github.com/serverless/components/tree/master/templates/express

Lastly, Serverless Express deploys onto your own Amazon Web Services account, so you'll need Access Keys to an AWS account you own. Follow this guide to create those.

After you have created AWS Access Keys you can add them directly to an .env file, or reference an AWS Profile in a .env file, within the root of the template you installed.

AWS_ACCESS_KEY_ID=123456789
AWS_SECRET_ACCESS_KEY=123456789

You can also reference an AWS Profile in a .env file like this.

AWS_PROFILE=default

If you don't include a .env file, the Serverless Framework will automatically look for a default AWS Profile in the root folder of your machine.

Also, Serverless Framework has a built-in stages concept. If you change the stage it will deploy a totally separate copy of your serverless application.

# serverless.yml
component: [email protected]
  name: express-api
  stage: prod

Even better, you can use different .env files for each stage by simply using this convention:

.env # all stages
.env.dev # "dev" stage
.env.prod # "prod" stage

One last—often overlooked—step is to install the Express.js dependency, by running npm i in the template.

serverless apis aws aws lambda aws http api

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Build a Serverless API with AWS Gateway and Lambda

In this article, we explain general API implementation concepts using AWS Lambda and other AWS services. APIs are a crucial part of any web application and there are different techniques for development and design. Serverless is one approach gaining popularity, because of its cost-efficiency, scalability and relative simplicity. As a leading serverless provider, Amazon Web Services (AWS) has made a huge contribution to the world of serverless development, and in this article, we will explain general API implementation concepts using AWS Lambda and other AWS services.

Serverless Auth with AWS HTTP APIs

Let's learn how to usethe new AWS HTTP APIs with one of the new features they offer - the JSON Web Token integration. and how to use Amazon Cognito to add authentication and authorization to your AWS HTTP API endpoints.

Serverless APIs with Python, AWS Lambda & API Gateway

Serverless APIs with Python, AWS Lambda & API Gateway

How to Build an API in AWS - Using AWS Lambda and API Gateway

APIs, short for Application Programming Interfaces, are connection points that allow different (parts of) computer programs to exchange data. Using APIs for the delivery of a software service makes your code better organized and easily reusable. In this article, I am going through the basic steps of creating an API using AWS Lambda and API Gateway.

Exposing HTTP API Gateway Via AWS CloudFront | Detailed Guide

AWS has saved a lot of money for their customers who were looking for a simple proxy to expose serverless application by releasing HTTP API Gateway. In this blog, we will learn how to serve HTTP API Gateway via AWS CloudFront as it by default does not support edge optimised endpoint