Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@lawcket/body-parser

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lawcket/body-parser

Middleware for @lawcket/websocket that parses body information

  • 0.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
decreased by-78.95%
Maintainers
1
Weekly downloads
 
Created
Source

@lawcket/body-parser

Downloads Version License

Middleware for @lawcket/websocket that parses body information

Installation

npm install @lawcket/websocket @lawcket/body-parser

or

yarn add @lawcket/websocket @lawcket/body-parser

Usage

By default, the @lawcket/websocket implementation does not modify incoming body data. Automatically parsing base64 or json stringified content, is as easy as adding the middleware to our @lawcket/websocket configuration.

const bodyParser = require('@lawcket/body-parser');
const LambdaWebSocket = require('@lawcket/websocket');

const lambdaSocket = new LambdaWebSocket({
  middleware: [bodyParser],
});

// const fakeEvent = {
//    body: "{\"foo\":\"bar\"}"
// };
lambdaSocket.on('message', async (event) => {
    console.log(event.body); // { "foo": "bar" } 
});

lambdaSocket.on('connect', async (event) => {});

lambdaSocket.on('close', async (event) => {});


module.exports = {
  default: lambdaSocket.createHandler(),
};
Caveats

Currently the middleware only tries to auto-parse json data. If the base64 contents is not an encoded json object, then the original base64 encoded string will be provided. This also goes for non-json strings.

Keywords

FAQs

Package last updated on 10 Feb 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc