UNPKG

yahoi

Version:

Yet Another Highly Opinionated Isomorphic Framework

31 lines (22 loc) 579 B
import ControllerResponseType from './../ControllerResponseType'; import React from 'react'; import { renderToString } from 'react-dom/server' import fs from 'fs'; export default class RenderRaw extends ControllerResponseType { constructor(content) { super(); this.content = 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)); }); } }