Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rajatady/reduxpress
A utility framework built on top of expressJS to provide single line abstractions for commonly used tasks.
https://github.com/rajatady/reduxpress
expressjs logging metrics nodejs
Last synced: 4 months ago
JSON representation
A utility framework built on top of expressJS to provide single line abstractions for commonly used tasks.
- Host: GitHub
- URL: https://github.com/rajatady/reduxpress
- Owner: rajatady
- License: mit
- Created: 2018-06-13T08:35:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-22T09:23:06.000Z (about 2 years ago)
- Last Synced: 2024-10-11T14:07:37.101Z (4 months ago)
- Topics: expressjs, logging, metrics, nodejs
- Language: JavaScript
- Homepage: https://rajatady.github.io/Reduxpress/
- Size: 815 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.hbs
- License: LICENSE
Awesome Lists containing this project
README
Reduxpress
A utility framework built on top of [expressJS] to provide single line implementations for commonly used tasks.
[![view on npm](https://img.shields.io/npm/v/reduxpress.svg)](https://www.npmjs.org/package/reduxpress)
[![view on npm](https://img.shields.io/npm/dm/reduxpress.svg)](https://www.npmjs.org/package/reduxpress)***
It provides the following functionality
* Request Validation
* Formatted Console Logs
* Authentication
* Response Handling
* Error Handling
* Object Logging in File or DB### Example Usage
1. Install the reduxpress module
* `npm i reduxpress --save`
2. Configure the module before the endpoints
```javascript
// server.jsimport reduxpress from 'reduxpress'
// var reduxpress = require('reduxpress')
import api from './api';
// var api = require('./api');...
reduxpress.setOptions({
saveTrace : true,
// default - false | Flag to save the data generated with each request,
secret : ''
})...
```3. Mount the object as a middleware before the endpoints you want to have reduxpress included in
```javascript
// server.js...
app.use(reduxpress.mount);
// OR app.use('/api', reduxpress.mount);...
app.post('/api', api);
...
```
4. Access the redux object from the request object directly. Each redux object is unique and is saved separately for all the incoming requests
```javascript
// api.jsmodule.exports = function(request, response) {
var redux = request.redux;redux
.bodyValidator(response, ['name', '^email'])
.then(function(body) {
// body should now contain name property and an optional email
redux.sendSuccess(response, body, 'body');
})
.catch(function(err) {
// if the name property is not present in the body of the request, an error will be thrown
redux.sendError(response, err);
})
}```
{{>main}}
* * *
LICENSE
MIT LicenseCopyright (c) 2017-2018 Kumar DIvya Rajat
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.[expressJS]: (https://github.com/expressjs/express)