# @klouddydev/node-box

> [![Build Status](https://travis-ci.com/klouddy/node-box.svg?branch=master)](https://travis-ci.com/klouddy/node-box.svg?branch=master)

Latest version **1.0.11** (published 2020-02-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install @klouddydev/node-box
pnpm add @klouddydev/node-box
yarn add @klouddydev/node-box
bun add @klouddydev/node-box
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2020-02-13 |
| First published | 2020-02-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 35.1 KB |
| Known vulnerabilities | 0 (+5 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | klouddy |

## Links

- npm: https://www.npmjs.com/package/@klouddydev/node-box
- Repository: https://github.com/klouddy/node-box
- Homepage: https://github.com/klouddy/node-box#readme
- Issues: https://github.com/klouddy/node-box/issues
- npm.io page: https://npm.io/package/@klouddydev/node-box

## Dependencies (10)

- [nconf](https://npm.io/package/nconf.md) ^0.10.0
- [helmet](https://npm.io/package/helmet.md) ^3.21.2
- [express](https://npm.io/package/express.md) ~4.17.1
- [js-yaml](https://npm.io/package/js-yaml.md) ^3.13.1
- [winston](https://npm.io/package/winston.md) ^3.2.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.19.0
- [prom-client](https://npm.io/package/prom-client.md) ^11.5.3
- [lodash.escaperegexp](https://npm.io/package/lodash.escaperegexp.md) ^4.1.2
- [http-proxy-middleware](https://npm.io/package/http-proxy-middleware.md) ^0.20.0
- [prometheus-api-metrics](https://npm.io/package/prometheus-api-metrics.md) ^2.2.3

## Recent versions

- 1.0.11 (latest) — 2020-02-13
- 1.0.10 — 2020-02-13
- 1.0.5 — 2020-02-13
- 1.0.4 — 2020-02-13
- 1.0.3 — 2020-02-13
- 1.0.2 — 2020-02-13
- 1.0.1 — 2020-02-11
- 1.0.0 — 2020-02-10

## README

# Node Box
[![Build Status](https://travis-ci.com/klouddy/node-box.svg?branch=master)](https://travis-ci.com/klouddy/node-box.svg?branch=master)

Quick way to create an express app for static html/js sites with some extra features.

**Install**

`npm install --save @klouddydev/node-box`

**Sample Usage**

```js
const nodeBox = require('@klouddydev/node-box');

var a = new nodeBox.NodeBox({filename: './config.yml'});

a.logger.warn('logging warn message');
a.app.listen(3000, () => {
  console.log('listening on 3000')
});
```
** Example config file **
```yml
actuator:
    prefix: /actuator
    paths:
        info: /info
        health: /health
        metrics: /prometheus
        logger: /logfile
application:
    name: App name
static:
    path: /
    src: ./public
logger:
    level: info
    filename: app.log
    postPath: /logger
proxies:
    - path: /api
      target: http://localhost:8080
      logLevel: info
```

## Configuration

Must include a config file.

**Actuator**

This comes from spring boot. The intention is to provide some basic information about the app
and some typically useful access points.  

 - `prefix` is the leading path for access the rest of the actuator endpionts
 - `paths.info` endpoint for getting info details.  This will return a json value of
 everything in the `applciation` property.  IT will be converted to a JSON object and returned.
 - `paths.health` endpoint for getting health response. Health endpoint will return `{"status":"up"}`
 - `paths.logger` endpoint to view the logfile that is created by the app.  
 - `paths.metrics` endopoint to view the prometheus metrics for the app.  
 The metrics are accomplished by using `prometheus-api-metrics`
 

**Application**

This can be any properly formatted yml.  It will be converted to a json object and returned to the `/acuator/info` endpoint

**Static**

Config for serving static html/js content

- `path` is the endpoint that the static files will be served from.
- `src` is the relative path the static files are located in.

**Logger**

Configuration for logger of the express application.  Uses `winstonjs`.

- `level` log level
- `filename` if this is present the application will also write log messages to a file. 
It will also be what is returned when accessing the `/actuator/logger` endpoint.
- `postPath` is the path used to post a log message to. Can be used for external logging of a SPA.

**Proxies**

Configuration of reverse proxies created.  This is accomplished by using the `http-proxy-middleware`. 
It is a list of proxies.

- `path` path the proxy is accessible from.
- `target` target for the reverse proxy.
- `logLevel` log level set for the revers proxy.

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