This package has been deprecated

Author message:

use @chubbyts/chubbyts-uwebsockets-http-bridge instead

@chubbyjs/chubbyjs-uwebsockets-psr-http-message-bridge

1.3.1 • Public • Published

chubbyjs-uwebsockets-psr-http-message-bridge

CI Coverage Status Infection MSI npm-version

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

A uWebSockets.js req/res psr-htt-message bridge.

Requirements

Installation

Through NPM as @chubbyjs/chubbyjs-uwebsockets-psr-http-message-bridge.

npm i @chubbyjs/chubbyjs-uwebsockets-psr-http-message-bridge@1.3.1 \
    @chubbyjs/chubbyjs-http-message@1.1.1

Usage

import PsrRequestFactory from '@chubbyjs/chubbyjs-uwebsockets-psr-http-message-bridge/dist/PsrRequestFactory';
import ResponseFactory from '@chubbyjs/chubbyjs-http-message/dist/Factory/ResponseFactory';
import ServerRequestFactory from '@chubbyjs/chubbyjs-http-message/dist/Factory/ServerRequestFactory';
import StreamFactory from '@chubbyjs/chubbyjs-http-message/dist/Factory/StreamFactory';
import UriFactory from '@chubbyjs/chubbyjs-http-message/dist/Factory/UriFactory';
import UwebsocketResponseEmitter from '@chubbyjs/chubbyjs-uwebsockets-psr-http-message-bridge/dist/UwebsocketResponseEmitter';
import { HttpRequest, HttpResponse } from 'uWebSockets.js';

const responseFactory = new ResponseFactory();

const psrRequestFactory = new PsrRequestFactory(
    new ServerRequestFactory(),
    new UriFactory(),
    new StreamFactory()
);

const uwebsocketResponseEmitter = new UwebsocketResponseEmitter();

require('uWebSockets.js')
    .App()
    .any('/*', (res: HttpResponse, req: HttpRequest) => {
        const serverRequest = psrRequestFactory.create(req, res);
        const response = responseFactory.createResponse(200);

        serverRequest.getBody().pipe(response.getBody());

        uwebsocketResponseEmitter.emit(response, res);
    })
    .listen('0.0.0.0', 8080, (listenSocket: unknown) => {
        if (listenSocket) {
            console.log('Listening to port 0.0.0.0:8080');
        }
    });

Copyright

Dominik Zogg 2021

Package Sidebar

Install

npm i @chubbyjs/chubbyjs-uwebsockets-psr-http-message-bridge

Weekly Downloads

0

Version

1.3.1

License

MIT

Unpacked Size

13.3 kB

Total Files

7

Last publish

Collaborators

  • dominikzogg