@codification/cutwater-node-core
TypeScript icon, indicating that this package has built-in type declarations

0.35.31 • Public • Published

@codification/cutwater-node-core

A library of tools for simplifying interaction with IO and HTTP on the server-side.

Installation

Via npm:

npm install @codification/cutwater-node-core

Via yarn:

yarn add @codification/cutwater-node-core

Documentation

Quick Start Guide

Http

Note: The http related functions are designed to simplify aspects of working with the http module in Node.js

import { HttpUtils } from '@codification/cutwater-node-core';

const LOG = LoggerFactory.getLogger();
const response = magicalHttpRequestFunction();
if(HttpUtils.isResponseOk(response)){
  HttpUtils.toBodyText(response).then(
    bodyTxt => {
      LOG.info('The body text was: %s', bodyTxt);
    }
  ).catch(
    err => {
      LOG.error('Oops! Problem reading the body: %j',err);
    }
  )

  const nextRequestHeaders = HttpUtils.mergeHeaders(response.headers,{'x-custom-header':'Custom Value'},true);
  // Will add the 'x-custom-header' to the received headers, or overwrite if it already exists.
}

Package Sidebar

Install

npm i @codification/cutwater-node-core

Weekly Downloads

7

Version

0.35.31

License

Apache-2.0

Unpacked Size

51.9 kB

Total Files

23

Last publish

Collaborators

  • wweiss