UNPKG

yahoi

Version:

Yet Another Highly Opinionated Isomorphic Framework

37 lines (25 loc) 682 B
import ControllerResponseType from './../ControllerResponseType'; export default class RenderView extends ControllerResponseType { constructor(props1, props2) { if(typeof(props1)=='object') { super(props2); this.content = props1; } else { super(props1); this.content = props1.content; } } render() { return new Promise((fulfill, reject) => { fulfill(this.content.error); }); } respond(req, res) { this.render(req).then(content => { res.setHeader('Content-Type', 'application/json'); res.send(content); }).catch(e => { res.send('error: ' + String(e)); }); } }