From 886f2950bc1ce01ee035c659c0903555af10016d Mon Sep 17 00:00:00 2001 From: dbauszus-glx Date: Thu, 19 Oct 2023 12:27:18 +0100 Subject: [PATCH] try getfrom fetch; fetch logger, remove custom.js --- mod/templates/_templates.js | 24 ++++++++++++++++++------ mod/templates/custom.js | 28 ---------------------------- mod/user/login.js | 2 -- 3 files changed, 18 insertions(+), 36 deletions(-) delete mode 100644 mod/templates/custom.js diff --git a/mod/templates/_templates.js b/mod/templates/_templates.js index 828021c9a..8230f234e 100644 --- a/mod/templates/_templates.js +++ b/mod/templates/_templates.js @@ -10,16 +10,28 @@ const cloudfront = require('../provider/cloudfront') const file = require('../provider/file') +const logger = require('../utils/logger') + const getFrom = { - https: async ref => { + https: async url => { + + try { + + const response = await fetch(url) - const response = await fetch(ref) + logger(`${response.status} - ${url}`,'fetch') - if (ref.match(/\.json$/i)) { - return await response.json() + if (url.match(/\.json$/i)) { + return await response.json() + } + + return await response.text() + + } catch (err) { + console.error(err) + return; } - - return await response.text() + }, file: ref => file(ref.split(':')[1]), cloudfront: ref => cloudfront(ref.split(':')[1]), diff --git a/mod/templates/custom.js b/mod/templates/custom.js deleted file mode 100644 index 3093726e0..000000000 --- a/mod/templates/custom.js +++ /dev/null @@ -1,28 +0,0 @@ -module.exports = { - 'register_view': { - 'en': 'https://geolytix.github.io/public/mapp/register.html' - }, - 'password_reset_view': { - 'en': 'https://geolytix.github.io/public/mapp/reset.html' - }, - 'login_view': { - 'en': 'https://geolytix.github.io/public/mapp/login.html' - }, - 'verify_password_reset': { - 'en': { - 'subject': 'Please verify your password reset for ${host}', - 'text': null, - 'html': 'https://geolytix.github.io/public/mapp/mails/reset_password.html' - } - }, - 'verify_account': { - 'en': { - 'subject': 'Please verify your account on ${host}', - 'text': null, - 'html': 'https://geolytix.github.io/public/mapp/mails/verify_registration.html' - } - }, - 'new_account_registered': { - 'en': 'https://geolytix.github.io/public/mapp/confirm.html' - } -} \ No newline at end of file diff --git a/mod/user/login.js b/mod/user/login.js index 61536517a..5cdbad615 100644 --- a/mod/user/login.js +++ b/mod/user/login.js @@ -73,8 +73,6 @@ async function view(req, res, message) { msg: message || ' ' }) - //res.clearCookie(process.env.TITLE) - // Clear user token cookie. res.setHeader('Set-Cookie', `${process.env.TITLE}=null;HttpOnly;Max-Age=0;Path=${process.env.DIR || '/'}`)