@johnmmackey/ms-utils

4.0.1 • Public • Published

ms-utils

Helper functions to use with Microservices Architecture.

Due to the use of ES6 features, this module requires Node.js V8 or above.

Quick Start

npm install @johnmmackey/ms-utils
const { Utils, Config, winstonMSLoggerFactory, sendmail } = require('@johnmmackey/ms-utils');
winston
    .remove(winston.transports.Console)
    .add(winston.transports.Console, {
        timestamp: true,
        level: 'debug'
    })
    .add(winstonMSLoggerFactory(winston, 'smtpengine', aC), {
        level: 'debug'
    });

const config = await Config.get('logger');
winston.debug('Config:', Utils.maskKeys(config));
let x = Config.get('key');      //typeof string
let y = Config.getObj('key');   // typeof Object

sendmail(
    [
        {"email": "user1@gmail.com","name": "John Smith"},
        {"email": "user2@yahoo.com","name": "Jane Doe"},
        {"email": "user3@aol.com","name": "Karen from Texas"}
    ],
    {
        from: 'info@countryglen.org',
        subject: "Test",
        htmlBody: "<em>This</em> is progress...",
        includeUnsubscribeLink: true
    })
    .then( () => console.log('Success'))
    .catch( err => console.log(err))

Future

  • Add local queueing for log events when AMQP is not operative.
  • Configurable logging setup (drivers)

Readme

Keywords

none

Package Sidebar

Install

npm i @johnmmackey/ms-utils

Weekly Downloads

2

Version

4.0.1

License

ISC

Unpacked Size

9.72 kB

Total Files

9

Last publish

Collaborators

  • johnmmackey