0.2.0 • Published 4 years ago

httply v0.2.0

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Httply

Build Status Coverage Status

A wrapper for incoming and outgoing HTTP message.

Usage

npm install --save httply
const http = require('http');
const { IncomingMessage, OutgoingMessage } = require('httply');

const server = http.createServer(async (request, response) => {
  const incoming = new IncomingMessage(request);
  const { url, method, headers } = incoming;
  const query = incoming.query;
  const rawBody = await incoming.rawBody;

  const outgoing = new OutgoingMessage({
    status: 200,
    headers: {},
    content: { hello: 'world' }
  });
  outgoing.sendBy(response);
});