Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including express-on-serverless with all npm packages installed. Try it out:

var expressOnServerless = require("express-on-serverless")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

express-on-serverless v0.1.1

Node.js express on AWS Lambda, deploying via Serverless framework!

Express on Serverless

Now you can run Node.js express on AWS Lambda, using Serverless framework!

What's this?

I want to run express on AWS Lambda and deploy it using Serverless.
This can be run with express, koa or other Node.js servers as far as it is requestListener

Features

  • [x] express
  • [x] GET/POST request
  • [x] POST json with body-parser
  • [x] POST urlencoded with body-parser
  • [x] POST binary file with multer
    (need to enable API Gateway binary support)

How to use

Install npm modules and generate template.

npm install -g serverless
npm install -S express express-on-serverless
serverless create --template aws-nodejs

Modify handler.js and serverless.yml

// handler.js
const express = require('express')
const app = express()

app.get('/test', (req, res) => {
  res.send("I'm fine!")
})

exports.index = require('express-on-serverless')(app)
// serverless.yml
service: aws-nodejs

provider:
  name: aws
  runtime: nodejs4.3

functions:
  index:
    handler: handler.index
    events:
      http: any {proxy+}

Deploy to AWS!

serverless deploy

Now you can access https://API_GATEWAY_HOST/dev/test ! It's too easy!!

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free