# ns-wingman

> Contains common features (logging, configuration, signal and event trapping) used in a node standalone server.

Latest version **1.0.6** (published 2018-04-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install ns-wingman
pnpm add ns-wingman
yarn add ns-wingman
bun add ns-wingman
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2018-04-02 |
| First published | 2016-10-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 1016.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Bill Hodges |
| Maintainers | wildbillh |
| Keywords | node, server, nconf, winston, signal trapping |

## Links

- npm: https://www.npmjs.com/package/ns-wingman
- Repository: https://github.com/wildbillh/ns-wingman
- Homepage: https://github.com/wildbillh/ns-wingman#readme
- Issues: https://github.com/wildbillh/ns-wingman/issues
- npm.io page: https://npm.io/package/ns-wingman

## Dependencies (3)

- [nconf](https://npm.io/package/nconf.md) ^0.8.5
- [winston](https://npm.io/package/winston.md) ^2.4.0
- [winston-wingman](https://npm.io/package/winston-wingman.md) ^1.0.8

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 1.0.6 (latest) — 2018-04-02
- 1.0.5 — 2017-11-28
- 1.0.4 — 2016-10-28
- 1.0.3 — 2016-10-28
- 1.0.2 — 2016-10-25
- 1.0.1 — 2016-10-25
- 1.0.0 — 2016-10-25

## README

# ns-wingman
######(node server wingman) 


[![Inline docs](http://inch-ci.org/github/wildbillh/ns-wingman.svg?branch=master)](http://inch-ci.org/github/wildbillh/ns-wingman)[![npm version](https://badge.fury.io/js/ns-wingman.svg)](https://badge.fury.io/js/ns-wingman)

## Synopsis
This module simplifies some of the common tasks needed for a NodeJS application running as a server.
#####Included features:
* Logs start and stop of server and includes process id.
* Catches unhandledRejection and uncaughtException, writes to log, calls cleanup() and exit().
* Traps and ignores SIGHUP.
* Traps SIGINT, writes to log and exits gracefully.
* Listens to beforeExit event and calls cleanup() and exit().
* Allows user to register a cleanup function and set a timeout prior to calling exit().
* Searches nconf configuration for WinstonConsoleTransport and WinstonFileTransport properties. If found, applies.
* Provides an easy winston interface through exported variable winstonWingman.

**Note:** *This class uses winston for logging.* 
*To write to the log use one of two interfaces below:*
* var winston = require('winston');
* var winston = require('ns-wingman').winstonWingman.winston;

## Install
```
$ npm install ns-wingman --save
```


## Usage
```javascript
let nconf = require('nconf');
let server = require('ns-wingman');

let winston = require('winston');
// Define cleanup function
let cleanup = () => {
    console.log('cleanup');
};

// Initialize the server
server.init('app.log', 'config.json', cleanup, 10);

// Log the value of a configuration property
winston.info(nconf.get('name'));

// Change a value of the winston console
server.winstonWingman.setConsoleTransport({colorize: false});

winston.info('should be in black and white now');
```

## Documentation
The class is documented with JSDoc. 

## Author
Bill Hodges

---
_Source: https://npm.io/package/ns-wingman · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
