serverless-offline-express

0.4.3 • Public • Published

Serverless Offline Express

serverless License: MIT

A Serverless v1.x plugin to run HTTP and PubSub functions with Express.

This plugin is for you if you want to run offline multiple NodeJS/TypeScript functions, which use request and response Express framework.

Some of serverless services like Google Gloud Functions or Firebase Function use standard Express requests and response on HTTP function invocation, and this plugin allow to run them together offline and keep compatible develoment all Express based functions.

Highlights

  • Configuration possibilities range from zero-config
  • Combine in same running Express process all HTTP and PubSub handlers
  • Support TypeScript functions execution
  • Express 4 support
  • Support NPM and Yarn for packaging
  • Hot Module Reload support
  • Emulate Message interface for PubSub functions

Install

$ npm install serverless-offline-express --save-dev

Add the plugin to your serverless.yml file:

plugins:
  - serverless-offline-express

Configure

Plugin not support yet any configuration.

Configure function

# serverless.yml

# Accessible by URL: /myFunction
functions:
  myFunction:
    handler: handlers/myHandlerFile.myFunctionName
    events:
      - http: 
          path: myHttpUrlPath
          method: GET|PUT|POST|DELETE

# Accessible by URL: /pubsub/myPubSubMessageTopic?message={"name":"test"}&attributes[name]=test_attribute
  myPubSubFunction:
    handler: handlers/anotherHandlerFile.myPubSubFunctionName
    events:
      - pubsub: 
          topic: myPubSubMessageTopic

Run Express server

$ serverless express

Environment variables

  • EXPRESS_HOST - Host name where Express will start
  • EXPRESS_PORT - Port where Express will start

Package Sidebar

Install

npm i serverless-offline-express

Weekly Downloads

2

Version

0.4.3

License

MIT

Unpacked Size

11.6 kB

Total Files

5

Last publish

Collaborators

  • evgheni