2019-07-27 01:22:26 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-04 00:24:39 +08:00
|
|
|
const formats = require('../../models/formats');
|
2019-07-27 01:22:26 +08:00
|
|
|
|
2019-12-24 01:19:08 +08:00
|
|
|
module.exports = function formatter () {
|
2019-07-27 01:22:26 +08:00
|
|
|
return function formatterMiddleware (req, res, next) {
|
|
|
|
const { format } = res.locals.params;
|
|
|
|
|
|
|
|
const FormatClass = formats[format];
|
|
|
|
req.formatter = new FormatClass();
|
|
|
|
|
|
|
|
next();
|
|
|
|
};
|
|
|
|
};
|