1.4.6 • Published 5 years ago

enoch v1.4.6

Weekly downloads
192
License
-
Repository
-
Last release
5 years ago

https://nodei.co/npm/enoch.png?downloads=true&downloadRank=true&stars=true

Node version contributions welcome NSP Status

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.

1.4.6

5 years ago

1.4.5

5 years ago

1.4.3

5 years ago

1.4.2

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.0

5 years ago

1.2.31

5 years ago

1.2.30

5 years ago

1.2.29

5 years ago

1.2.28

5 years ago

1.2.27

5 years ago

1.2.26

5 years ago

1.2.25

5 years ago

1.2.24

5 years ago

1.2.23

5 years ago

1.2.22

5 years ago

1.2.21

5 years ago

1.2.20

5 years ago

1.2.19

5 years ago

1.2.18

5 years ago

1.2.17

5 years ago

1.2.16

5 years ago

1.2.15

5 years ago

1.2.14

5 years ago

1.2.13

5 years ago

1.2.12

5 years ago

1.2.11

5 years ago

1.2.10

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.14

6 years ago

1.1.13

6 years ago

1.1.12

6 years ago

1.1.11

6 years ago

1.1.10

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.0.0

9 years ago