Cutwater:Core
A library providing the functionality that we always seem to need in every Typescript/Javascript project.
Installation
Via npm:
npm install cutwater-core
Via yarn:
yarn add cutwater-core
Documentation
Quick Start Guide
Configuration
; ;// Returns 'https://api.example.com' if there is no value for API_URL ;// Will throw an error (optionally with the provided message) if API_URL does not exist Config.put'BACKUP_API_URL', 'https://api-backup.example.com';
Environment
; if Env.isProd if Env.isDev
String Utility Functions
; if contains'Check This', 'This' if startsWith'x-forward', 'x-' if endsWith'x-Forward-Cookies', 'cookies', true
Time
; ;; console.logTZUtils.timestamp;// 2018-10-06 15:22:12,345 (This is UTC) TZUtils.timezoneOffset = TimeUnit.hours-5.toMinutes;console.logTZUtils.timestamp;// 2018-10-06 10:22:12,345 (Now we get the time in Ecuador, UTC-5) ;// localizedDate is the current date/time based on the timezoneOffset, Ecuador in this case.
Logging
; ;LOG.info'Hey, here is a log message.';LOG.debug'Examine this object: %j', someObj;
Http
Note: The http
related functions are designed to simplify aspects of working with the http module in Node.js
; ;;ifisResponseOkresponse