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

uws-common

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uws-common

Common functions and utilities to improve DX (Developer Experience) with [uWebSockets.js](https://github.com/uNetworking/uWebSockets.js).

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

uws-common

Common functions and utilities to improve DX (Developer Experience) with uWebSockets.js.

Installation

yarn add uws-common

Usage

import { App } from 'uWebSockets.js'
import { getBodyJson, getBodyText, getQuery } from 'uws-common'

const port = +(process.env.PORT || 3000)

const app = App()

app
  .get(pattern, async ({ req, res }) => {
    console.log('Query:', getQuery(req))   // { q: 1, q: 2 }
    console.log('Text body:', await getBodyText(res))  // "Text in Request Body"
    console.log('JSON body:', await getBodyJson(res))  // { prop1: 1, prop2: 2 }
    res.end('Hello World!')
  })
  .listen(port, (listenSocket) => {
    if (listenSocket) {
      console.log(`Server running at http://localhost:${port}`)
    } else {
      console.log(`Failed to listen to port ${port}`)
    }
  })

License

This project is licensed under the MIT License.

FAQs

Package last updated on 21 Oct 2024

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