This package has been deprecated

Author message:

use @chubbyts/chubbyts-framework instead

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

1.3.0 • Public • Published

chubbyjs-node-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 node req/res psr-htt-message bridge.

Requirements

Installation

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

npm i @chubbyjs/chubbyjs-node-psr-http-message-bridge@1.3.0 \
    @chubbyjs/chubbyjs-http-message@1.1.1

Usage

import NodeResponseEmitter from '@chubbyjs/chubbyjs-node-psr-http-message-bridge/dist/NodeResponseEmitter';
import PsrRequestFactory from '@chubbyjs/chubbyjs-node-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 { createServer, IncomingMessage, ServerResponse } from 'http';

const responseFactory = new ResponseFactory();

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

const nodeResponseEmitter = new NodeResponseEmitter();

const server = createServer(async (req: IncomingMessage, res: ServerResponse) => {
    const serverRequest = psrRequestFactory.create(req);
    const response = responseFactory.createResponse(200);

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

    nodeResponseEmitter.emit(response, res);
});

server.listen(8080, '0.0.0.0');

Copyright

Dominik Zogg 2021

Package Sidebar

Install

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

Weekly Downloads

3

Version

1.3.0

License

MIT

Unpacked Size

12.1 kB

Total Files

7

Last publish

Collaborators

  • dominikzogg