@codification/cutwater-node-core
v0.35.31
Published
A library providing the basic utility classes for node.
Downloads
271
Maintainers
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.
}