Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@lawcket/body-parser
Advanced tools
npm install @lawcket/websocket @lawcket/body-parser
or
yarn add @lawcket/websocket @lawcket/body-parser
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(),
};
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.
FAQs
Middleware for @lawcket/websocket that parses body information
The npm package @lawcket/body-parser receives a total of 8 weekly downloads. As such, @lawcket/body-parser popularity was classified as not popular.
We found that @lawcket/body-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.