diff --git a/CHANGES.md b/CHANGES.md index 0c82dbf..770ad72 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,11 @@ CHANGELOG Branch 3.X.X ------------------------------------------------------ +### 3.1.0 ### + +* Added: exposed `express.js` response object within `filter()` callback + + ### 3.0.0 ### * Refactored the whole codebase diff --git a/docs/HTTP504.html b/docs/HTTP504.html new file mode 100644 index 0000000..09b9e0e --- /dev/null +++ b/docs/HTTP504.html @@ -0,0 +1,13 @@ + + + + + + We've got some trouble | 504 - Webservice currently unavailable + + + +

Webservice currently unavailable 502

We've got some trouble with our backend upstream cluster.
Our service team has been dispatched to bring it back online.

+ + + diff --git a/examples/express.js b/examples/express.js index 25e94fb..7b28e1f 100644 --- a/examples/express.js +++ b/examples/express.js @@ -45,7 +45,7 @@ async function bootstrap(){ footer: 'Hello World', pagetitle: 'we are sorry - an internal error encountered', }, - filter: function(data){ + filter: function(data, req, res){ // remove footer //data.footer = null; return data; diff --git a/examples/koa.js b/examples/koa.js index 4fb0fcf..ba1a482 100644 --- a/examples/koa.js +++ b/examples/koa.js @@ -14,7 +14,7 @@ async function bootstrap(){ footer: 'Hello World', pagetitle: 'we are sorry - an internal error encountered', }, - filter: function(data){ + filter: function(data, ctx){ // remove footer //data.footer = null; return data; diff --git a/gulpfile.js b/gulpfile.js index 3ab2d29..43bb132 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,5 +1,5 @@ const _gulp = require('gulp'); -const _sass = require('gulp-sass'); +const _sass = require('gulp-sass')(require('sass')); const _prettyError = require('gulp-prettyerror'); const _cleanCSS = require('gulp-clean-css'); const _concat = require('gulp-concat'); diff --git a/i18n/pages-en_US.json b/i18n/pages-en_US.json index 257d5a4..1dcd54b 100644 --- a/i18n/pages-en_US.json +++ b/i18n/pages-en_US.json @@ -1,4 +1,31 @@ -{ +{ + // REDIRECT CODES + // ======================================================= + + "301": { + "title": "Moved Permanently", + "message": "We found it elsewhere." + }, + "302": { + "title": "Found", + "message": "We found it elsewhere." + }, + + "303": { + "title": "See Other", + "message": "We found it elsewhere." + }, + + "307": { + "title": "Temporary Redirect", + "message": "We found it elsewhere." + }, + + "308": { + "title": "Permanent Redirect", + "message": "We found it elsewhere." + }, + // STANDARD ERROR CODES // ======================================================= @@ -21,7 +48,12 @@ "title": "Resource not found", "message": "The requested resource could not be found but may be available again in the future." }, - + + "405": { + "title": "Method Not Allowed", + "message": "A request method is not supported for the requested resource." + }, + // internal server error "500": { "title": "Webservice currently unavailable", @@ -45,6 +77,12 @@ "title": "Webservice currently unavailable", "message": "We've got some trouble with our backend upstream cluster.\nOur service team has been dispatched to bring it back online." }, + + // http proxy time out error + "504": { + "title": "Webservice currently unavailable", + "message": "We've got some trouble with our backend upstream cluster.\nOur service team has been dispatched to bring it back online." + }, // CUSTOM ERROR CODES // ======================================================= @@ -66,4 +104,4 @@ "title": "Scheduled Maintenance", "message": "This site is currently down for maintenance.\nOur service team is working hard to bring it back online soon." } -} \ No newline at end of file +} diff --git a/i18n/pages-es_VE.json b/i18n/pages-es_VE.json index 2b1508b..4becc96 100644 --- a/i18n/pages-es_VE.json +++ b/i18n/pages-es_VE.json @@ -51,6 +51,12 @@ "message": "Se encontró una condición inesperada. Nuestro equipo de servicio está abocado para colocarlo nuevamente en servicio." }, + // http 504 Gateway Timeout + "504": { + "title": "Servicio web proxy actualmente no disponible", + "message": "Tenemos algunos problemas con nuestro racimo. Nuestro equipo de servicio fue enviado para restablecerlo nuevamente en línea." + }, + //https://tools.ietf.org/html/rfc6585#section-6 // http 511 Network Authentication Required (offer a URL for login) diff --git a/i18n/pages-fr_FR.json b/i18n/pages-fr_FR.json index a6af9e1..438947c 100644 --- a/i18n/pages-fr_FR.json +++ b/i18n/pages-fr_FR.json @@ -45,6 +45,12 @@ "title": "Service Web actuellement indisponible", "message": "Nous avons quelques problèmes avec notre cluster en amont. Notre équipe de service a été dépêchée pour le remettre en ligne." }, + + // http proxy timeout error + "504": { + "title": "Service Web actuellement indisponible", + "message": "Nous avons quelques problèmes avec notre cluster en amont. Notre équipe de service a été dépêchée pour le remettre en ligne." + }, // CUSTOM ERROR CODES // ======================================================= diff --git a/i18n/pages-pl-PL.json b/i18n/pages-pl-PL.json new file mode 100644 index 0000000..880177c --- /dev/null +++ b/i18n/pages-pl-PL.json @@ -0,0 +1,86 @@ +{ + + "400": { + "title": "Błędne zapytanie", + "message": "Serwer nie mógł przetworzyć żądania." + }, + "401": { + "title": "Brak uwierzytelnienia", + "message": "Żądany zasób wymaga uwierzytelnienia." + }, + + "403": { + "title": "Brak dostępu", + "message": "Żądany zasób wymaga uwierzytelnienia." + }, + + "404": { + "title": "Nie znaleziono", + "message": "Nie można znaleźć żądanego zasobu, ale może on być ponownie dostępny w przyszłości." + }, + + "405": { + "title": "Nie dozwolona metoda", + "message": "Witryna nie bługuje wybranej metody." + }, + + "408": { + "title": "Upłynął limit czasu żadania", + "message": "Witryna przekroczyła limit czasu oczekiwania na żądanie przeglądarki." + }, + + "410": { + "title": "Nie znaleziono", + "message": "Nie można znaleźć żądanego zasobu, ale był on kiedyś dostępny." + }, + + "429": { + "title": "Za dużo zapytań", + "message": "Wysłano zbyt wiele zapytań w zbyt krótkim czasie." + }, + + "499": { + "title": "Żądanie zamknięcia", + "message": "Przeglądarka wsyłała żądanie przerwania" + }, + + "500": { + "title": "Witryna jest aktualnie niedostępna", + "message": "Wystąpił nieoczekiwany błąd.\nJuż pracujemy nad przywróceniem witryny." + }, + + "501": { + "title": "Brak obsługi", + "message": "Witryna nie jest w stanie obsłużyć takiego zapytania." + }, + + "502": { + "title": "Witryna jest aktualnie niedostępna", + "message": "Wystąpił nieoczekiwany błąd.\nJuż pracujemy nad przywróceniem witryny." + }, + + "503": { + "title": "Witryna jest aktualnie niedostępna", + "message": "Wystąpił nieoczekiwany błąd.\nJuż pracujemy nad przywróceniem witryny." + }, + + "504": { + "title": "Witryna jest aktualnie niedostępna", + "message": "Wystąpił nieoczekiwany błąd.\nJuż pracujemy nad przywróceniem witryny." + }, + + "520": { + "title": "Błąd — nieznany host", + "message": "Żądana nazwa hosta nie jest routowana. Używaj tylko nazw hostów, aby uzyskać dostęp do zasobów." + }, + + "521": { + "title": "Witryna jest aktualnie niedostępna", + "message": "Wystąpił nieoczekiwany błąd.\nJuż pracujemy nad przywróceniem witryny." + }, + + "533": { + "title": "Zaplanowana konserwacja", + "message": "Witryna jest obecnie niedostępna z powodu konserwacji.\nPracujemy na tym, aby wkrótce przywrócić ją do trybu online." + } +} diff --git a/i18n/pages-pt_BR.json b/i18n/pages-pt_BR.json index c5562fa..061ac7f 100644 --- a/i18n/pages-pt_BR.json +++ b/i18n/pages-pt_BR.json @@ -44,6 +44,12 @@ "message": "Nós tivemos alguns problema com o nosso backend. Nosso time de serviços está trabalhando para deixar isso online novamente." }, + // http proxy timeout error + "504": { + "title": "Webservice atualmente indisponível", + "message": "Nós tivemos alguns problema com o nosso backend. Nosso time de serviços está trabalhando para deixar isso online novamente." + }, + // CUSTOM ERROR CODES // ======================================================= // webserver origin error diff --git a/i18n/pages-zh_CN.json b/i18n/pages-zh_CN.json index 097d652..2f12214 100644 --- a/i18n/pages-zh_CN.json +++ b/i18n/pages-zh_CN.json @@ -45,6 +45,12 @@ "title": "Webservice目前不可用", "message": "我们的后端上游服务器出现了问题。\n技术支持团队正在努力修复中。" }, + + // http proxy timeout error + "504": { + "title": "Webservice目前不可用", + "message": "我们的后端上游服务器出现了问题。\n技术支持团队正在努力修复中。" + }, // CUSTOM ERROR CODES // ======================================================= diff --git a/lib/express.js b/lib/express.js index df88839..1b6de54 100644 --- a/lib/express.js +++ b/lib/express.js @@ -27,7 +27,7 @@ async function createDispatcher(options={}){ // standard http-error-pages html: function(){ res.type('.html'); - res.send(_render(resources.template, resources.stylesheet, opt.filter(templateVars, req))) + res.send(_render(resources.template, resources.stylesheet, opt.filter(templateVars, req, res))) }, // json diff --git a/package.json b/package.json index 174ae82..cfc2990 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "http-error-pages", - "version": "3.0.0", + "version": "3.1.0", "description": "Simple HTTP Error Pages. standalone + static + koa + express", "engines": { "node": ">=7.6" @@ -50,9 +50,10 @@ "gulp-clean-css": "^4.3.0", "gulp-concat": "^2.6.1", "gulp-prettyerror": "^2.0.0", - "gulp-sass": "^4.1.0", + "gulp-sass": "^5.1.0", "koa": "^2.13.0", - "less": "^3.11.3" + "less": "^3.11.3", + "sass": "^1.60.0" }, "dependencies": { "ejs": "^3.1.3",