Giter Site home page Giter Site logo

iqdavidh / serverless-websockets-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from serverless/serverless-websockets-plugin

0.0 1.0 0.0 159 KB

Websocket support for Serverless Framework on AWS

License: Apache License 2.0

JavaScript 98.01% Shell 1.99%

serverless-websockets-plugin's Introduction

Serverless Websockets Plugin

Deprecation Notice

This repo is now deprecated, and we are no longer maintaining it. v1.38.0 of the framework now includes built-in support for websockets. Please check the docs for more info

1. Installation

Install the plugin by adding it to your service dependencies:

npm i serverless-websockets-plugin --save

Note: Because this plugin uses the new ApiGatewayV2 service in the AWS SDK, it requires v1.35.0+ of the Serverless Framework.

2. Usage

Load the serverless-websockets-plugin, then optionally provide a new API name and Route Selection Expression, and finally define your WebSockets events and their route keys:

service: serverless-websockets-service

# Load the plugin
plugins:
  - serverless-websockets-plugin

provider:
  name: aws
  runtime: nodejs8.10
  
  # Optional
  websocketApiName: foobar
  websocketApiRouteSelectionExpression: $request.body.action

functions:
  connectionManagement:
    handler: handler.connectionManagement
    events:
      - websocket:
          routeKey: $connect
      - websocket:
          routeKey: $disconnect
  defaultMessage:
    handler: handler.default
    events:
      - websocket:
          routeKey: $default
  chatMessage:
    handler: handler.chat
    events:
      - websocket:
          routeKey: message
  twoWayMessage:
    handler: handler.twoWay
    events:
      - websocket:
          routeKey: twoway
          # The property below will enable an integration response in the API Gateway.
          # See https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-route-response.html
          routeResponseSelectionExpression: $default

serverless-websockets-plugin's People

Contributors

eahefnawy avatar shortjared avatar alexdebrie avatar braindx avatar dbramwell avatar chrillo avatar ashishtilara avatar brianneisler avatar agutoli avatar guerrerocarlos avatar khornberg avatar popenkomaksim avatar coldfire87 avatar skithy avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.