express-on-serverless

0.1.1 • Public • Published

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

  • express
  • GET/POST request
  • POST json with body-parser
  • POST urlencoded with body-parser
  • 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!!

Readme

Keywords

none

Package Sidebar

Install

npm i express-on-serverless

Weekly Downloads

1

Version

0.1.1

License

MIT

Last publish

Collaborators

  • toduq