UNPKG

@sustain/core

Version:

Sustain is a Framework that is barely used despedcies to make stable and sustainable apps

34 lines 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.render505Page = exports.renderErrorPage = void 0; const constants_1 = require("./../constants"); const fs_1 = require("fs"); const path_1 = require("path"); function renderErrorPage(response, error) { fs_1.readFile(path_1.join(__dirname, '../public/404.html'), (err, data) => { if (!err) { data = data.toString(); data = data.replace('#error_message', error); data = data.replace('#status_code', response.statusCode); data = data.replace('#error', constants_1.IS_DEVELOPMENT ? error.stack : constants_1.EMPTY_STRING); response.end(data); } else { console.log(err); } }); } exports.renderErrorPage = renderErrorPage; function render505Page(response) { response.writeHead(200, { 'Content-Type': 'text/html' }); fs_1.readFile(path_1.join(__dirname, '../views/500.html'), (err, data) => { if (!err) { response.end(data); } else { console.log(err); } }); } exports.render505Page = render505Page; //# sourceMappingURL=render-error-pages.helper.js.map