# enoch

> [![https://nodei.co/npm/enoch.png?downloads=true&downloadRank=true&stars=true](https://nodei.co/npm/enoch.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/enoch)

Latest version **1.4.6** (published 2019-01-30) · 0 weekly downloads

## Install

```sh
npm install enoch
pnpm add enoch
yarn add enoch
bun add enoch
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.6 |
| Published | 2019-01-30 |
| First published | 2018-10-08 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | ^8.11.0 |
| Dependencies | 21 |
| Unpacked size | 13.3 MB |
| Known vulnerabilities | 0 (+23 in 4 direct dependencies) |
| Install scripts | no |
| Maintainers | mhorne |

## Links

- npm: https://www.npmjs.com/package/enoch
- npm.io page: https://npm.io/package/enoch

## Dependencies (21)

- [cors](https://npm.io/package/cors.md) ^2.8.4
- [rxjs](https://npm.io/package/rxjs.md) ^6.0.0
- [moment](https://npm.io/package/moment.md) ^2.22.2
- [core-js](https://npm.io/package/core-js.md) ^2.5.4
- [express](https://npm.io/package/express.md) ^4.16.3
- [is-json](https://npm.io/package/is-json.md) ^2.0.1
- [zone.js](https://npm.io/package/zone.js.md) ^0.8.26
- [ngx-pipes](https://npm.io/package/ngx-pipes.md) ^2.3.5
- [node-cron](https://npm.io/package/node-cron.md) ^2.0.1
- [express-ip](https://npm.io/package/express-ip.md) ^1.0.3
- [highcharts](https://npm.io/package/highcharts.md) ^6.2.0
- [@angular/core](https://npm.io/package/@angular/core.md) ^6.0.3
- [@angular/http](https://npm.io/package/@angular/http.md) ^6.0.3
- [@angular/forms](https://npm.io/package/@angular/forms.md) ^6.0.3
- [@angular/common](https://npm.io/package/@angular/common.md) ^6.0.3
- [@angular/router](https://npm.io/package/@angular/router.md) ^6.0.3
- [parabol-material](https://npm.io/package/parabol-material.md) ^1.0.1
- [@angular/compiler](https://npm.io/package/@angular/compiler.md) ^6.0.3
- [@angular/animations](https://npm.io/package/@angular/animations.md) ^6.0.3
- [@angular/platform-browser](https://npm.io/package/@angular/platform-browser.md) ^6.0.3
- [@angular/platform-browser-dynamic](https://npm.io/package/@angular/platform-browser-dynamic.md) ^6.0.3

## Recent versions

- 1.4.6 (latest) — 2019-01-30
- 1.4.5 — 2019-01-25
- 1.4.3 — 2019-01-25
- 1.4.2 — 2019-01-07
- 1.4.1 — 2018-10-30
- 1.4.0 — 2018-10-29
- 1.3.6 — 2018-10-29
- 1.3.5 — 2018-10-29
- 1.3.4 — 2018-10-25
- 1.3.3 — 2018-10-25
- 1.3.2 — 2018-10-25
- 1.3.0 — 2018-10-25
- 1.2.31 — 2018-10-25
- 1.2.30 — 2018-10-25
- 1.2.29 — 2018-10-25
- … 49 more at https://npm.io/package/enoch/versions

## README

[![https://nodei.co/npm/enoch.png?downloads=true&downloadRank=true&stars=true](https://nodei.co/npm/enoch.png?downloads=true&downloadRank=true&stars=true)](https://www.npmjs.com/package/enoch)

[![Node version](https://img.shields.io/node/v/enoch.svg?style=flat)](http://nodejs.org/download/)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)
[![NSP Status](https://nodesecurity.io/orgs/dwyl/projects/1047e39b-0d4a-45ff-af65-c04afc41fc20/badge)](https://nodesecurity.io/orgs/dwyl/projects/1047e39b-0d4a-45ff-af65-c04afc41fc20)


# Enoch - An Express Middleware to log API requests

## Instalation

`npm i enoch`

## Usage

At the top of your node file, include this line:

```
const enoch = require('enoch');
```


### Store logs

To store logs, attach the .store() function to the Express route as a middleware either by doing:

```
app.use('**', enoch.store());
```

to capture all routes or directly on the route like:

```
router.post('/example', enoch.store(), (req, res, next) => {
  // Do something

  next();
});
```


### Clean logs

Enoch stores logs as JSON files, in order to clean up old JSON files and prevent excess disk usage, call the cleanup file like so:

`enoch.clean('0 0 * * *', 60);`

The 2 parameters to provide are:

- cron_schedule
- removal_time_in_days (optional)

So in the above example, this will start a cron job to run every day at midnight and will remove JSON logs which are more than 60 days old.


### Serve UI

Enoch has a basic UI which will create a route named `/enoch-logs` to be used by the application to fetch the logs. It also creates a subdiretory named `/enoch` which you can navigate to to view your API logs. Add these routes to your applcication by including the following line in your Node applicaiton.

```
enoch.serve(app);
```


## Run in dev mode

To run in dev mode simply clone the repo, navigate to the directory and run `npm run dev` which will allow you to edit the UI directly with the Angular CLI on port 4000. You can also run `npm run prod` to serve the UI from the Node.js server. This will run Enoch, including the UI, on your local machine at `localhost:8085`. You will need to supply some sample logs in the `/logs` directory.

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