yahoi
Version:
Yet Another Highly Opinionated Isomorphic Framework
34 lines (24 loc) • 617 B
JavaScript
import ControllerResponseType from './../ControllerResponseType';
export default class RenderString extends ControllerResponseType {
constructor(props1, props2) {
if(typeof(props1)=='string') {
super(props2);
this.content = props1;
} else {
super(props1);
this.content = props1.content;
}
}
render() {
return new Promise((fulfill, reject) => {
fulfill(this.content);
});
}
respond(req, res) {
this.render(req).then(content => {
res.send(content);
}).catch(e => {
res.send('error: ' + String(e));
});
}
}