UNPKG

@leafage/server

Version:

The React Server Side Render Framework

48 lines (44 loc) 1.56 kB
/** * @leafage/server v1.3.2 * * Copyright (c) Leafage. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */ 'use strict'; var _rollupPluginBabelHelpers = require('../_virtual/_rollupPluginBabelHelpers.js'); var handleErrorResponse = require('../common/handleErrorResponse.js'); var errorPreset = function errorPreset(ctx) { ctx.app.use(/*#__PURE__*/function () { var _ref = _rollupPluginBabelHelpers.asyncToGenerator(/*#__PURE__*/_rollupPluginBabelHelpers.regenerator().m(function _callee(err, req, res, next) { var _handleErrorResponse, statusCode, message, html; return _rollupPluginBabelHelpers.regenerator().w(function (_context) { while (1) switch (_context.n) { case 0: _handleErrorResponse = handleErrorResponse.handleErrorResponse(err, req, res), statusCode = _handleErrorResponse.statusCode, message = _handleErrorResponse.message; _context.n = 1; return ctx.renderer.render('Error', { statusCode: statusCode, message: message }); case 1: html = _context.v; res.status(statusCode); if (html) { res.send(html); } next(); case 2: return _context.a(2); } }, _callee); })); return function (_x, _x2, _x3, _x4) { return _ref.apply(this, arguments); }; }()); }; exports.errorPreset = errorPreset;