@codification/cutwater-node-core

A library providing the basic utility classes for node.

Usage no npm install needed!

<script type="module">
  import codificationCutwaterNodeCore from 'https://cdn.skypack.dev/@codification/cutwater-node-core';
</script>

README

@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.
}