Comparing version 0.0.1 to 0.0.2
'use strict'; | ||
module.exports = { | ||
Greeter: require('./greeter'), | ||
respondJson: require('./respond-json'), | ||
}; |
{ | ||
"name": "fiddleware", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Connect/Express middleware library with common utility functions.", | ||
@@ -35,2 +35,3 @@ "main": "index.js", | ||
"config": "^1.19.0", | ||
"connect-route": "^0.1.5", | ||
"eslint-config-airbnb": "^4.0.0", | ||
@@ -42,4 +43,6 @@ "eslint-plugin-react": "^3.16.1", | ||
"gulp-istanbul": "^0.10.3", | ||
"gulp-mocha": "^2.2.0" | ||
"gulp-mocha": "^2.2.0", | ||
"should": "^8.2.1", | ||
"supertest": "^1.1.0" | ||
} | ||
} |
@@ -12,4 +12,20 @@ # fiddleware | ||
** TODO ** Documentation for components. | ||
* respondJson() - Add .json(data, responseCode) method to 'res' objects in pipeline. | ||
## Middleware Types | ||
### **respondJson()** | ||
Simple JSON response extension for outgoing response object which stringifies the | ||
specified object, sets the HTTP response code and content type headers: | ||
const fiddleware = require('fiddleware'); | ||
app.use(fiddleware.respondJson()); | ||
function doSomething(req, res) { | ||
// Return all of the JSONs. | ||
res.json({ | ||
foo: 'bar'}, 200); | ||
} | ||
Please note that HTTP status code is defaulted to 200 if the second parameter is not passed. | ||
## Licencing | ||
@@ -16,0 +32,0 @@ This repository is MIT licensed. That means you can use it freely without restriction or attribution. |
Sorry, the diff of this file is not supported yet
84318
71
12
2244