mio-extensions
v1.0.4
Published
Extract requested file type
Downloads
7
Readme
MIO Extensions Formater Lib
Response formater midleware for express
Extract requested file type and parse data
Quick Start
Add extract() as midleware
Add postfix .:ext? to the route
Use render() for response
Try to open your route at browser with adding .json, .xml or .html extension at the end or by changing requested mime type
Sample
const extensions = require('mio-extensions');
... INIT express ...
app.use(extensions.extract);
... Update Routes ...
app.get('/error/:code?.:ext?')...
... Write Route function
extensions.render(req, res, {
status: errorCode,
template: './pathToYourTemplate/Vash.PuG',
data: {
code: errorCode,
error: errorMessage,
message: errorHint
}
});
Notes
This library just wrap up your logic, so it's agnostic to your template engine.
All options except data are optional