1.0.0 • Published 1 year ago

@httpi/adapter-uwebsockets v1.0.0

Weekly downloads
-
License
CC0-1.0
Repository
github
Last release
1 year ago

@httpi/adapter-uwebsockets

This is a uWebsockets.js adapter for @httpi/client.

Install the adapter using one of these:

npm i @httpi/adapter-uwebsockets
yarn add @httpi/adapter-uwebsockets
pnpm i @httpi/adapter-uwebsockets

Example usage

import uWebSockets from 'uWebSockets.js';
import { createEvents } from '@httpi/client';
import { createUWebsocketsAdapter } from '@httpi/adapter-uwebsockets';

uWebSockets
  .App()
  .post(
    '/interactions',
    createUWebsocketsAdapter({
      publicKey,
      events: createEvents({
        commands,
        components,
      }),
    }),
  )
  .listen(port, (listenSocket) => {
    if (!listenSocket) throw new Error(`Failed to listen port ${port}`);
  });