https://github.com/busterc/express-log-routes
:eyes: console.log available Express routes
https://github.com/busterc/express-log-routes
console-log express express-middleware
Last synced: 18 days ago
JSON representation
:eyes: console.log available Express routes
- Host: GitHub
- URL: https://github.com/busterc/express-log-routes
- Owner: busterc
- License: isc
- Created: 2016-04-19T02:24:18.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2018-08-25T21:48:25.000Z (almost 8 years ago)
- Last Synced: 2025-10-20T10:48:43.428Z (7 months ago)
- Topics: console-log, express, express-middleware
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# express-log-routes [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]
> console.log available Express routes
## Installation
```sh
$ npm install --save express-log-routes
```
## Usage
```js
var router = require('express').Router();
var LogRoutes = require('express-log-routes');
// Initialize with the default configuration:
/*
{
baseUri: '/',
router: undefined,
headerTemplate: function () {
return `---------------------\nROUTES AVAILABLE FOR: ${this.baseUri}\n---------------------`;
},
uriTemplate: function (method, uri, endpoint) {
return `==> ${method.toUpperCase()} ${endpoint}`;
},
footerTemplate: function () {
return '';
},
whilst: function () {
return true;
}
}
*/
var logRoutes = LogRoutes();
// or, customize the initial configuration
var options = {
whilst: function() {
// only during dev
if (process.env.ENV === 'dev') {
return true;
}
return false;
}
};
logRoutes = LogRoutes(options);
// ...
// Note: if you pass a router into the initial configuration,
// you can then simply activate the logging with:
//
// logRoutes();
//
// Otherwise: activate logging for a specific router:
logRoutes({
router: router,
baseUri: '/api/user' // <-- you can also override initial configurations
});
```
## License
ISC © [Buster Collings](https://about.me/buster)
[npm-image]: https://badge.fury.io/js/express-log-routes.svg
[npm-url]: https://npmjs.org/package/express-log-routes
[travis-image]: https://travis-ci.org/busterc/express-log-routes.svg?branch=master
[travis-url]: https://travis-ci.org/busterc/express-log-routes
[daviddm-image]: https://david-dm.org/busterc/express-log-routes.svg?theme=shields.io
[daviddm-url]: https://david-dm.org/busterc/express-log-routes