From e5d4ad07ea1b399752dafa85dbc15477b900f462 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 21 Feb 2026 03:43:27 +0000 Subject: [PATCH 1/2] Remove Discord timestamp from VOTD API response The `date` field in the `/votd/get` endpoint used Discord-specific formatting (e.g., ``). This change removes the `date` field from the response as requested. The logic to calculate the timestamp from the Bible Gateway feed is also removed to keep the code clean. Co-authored-by: benrobson <15405528+benrobson@users.noreply.github.com> --- routes/index.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/routes/index.js b/routes/index.js index e7620b6..0225ce6 100644 --- a/routes/index.js +++ b/routes/index.js @@ -76,13 +76,9 @@ export default function applicationSiteRoutes(app) { if (err) { console.error(err); } else { - const timestamp = Math.floor(new Date(result.feed.updated[0]).getTime() / 1000); - const date = ``; - const votd = { reference: result.feed.entry[0].title[0], referenceLink: result.feed.entry[0].link[0].$.href, - date: date, content: removeHtmlEntities(result.feed.entry[0].content[0]._), credit: result.feed.link[1].$.href }; From ba12225aead708f8bcf0d4e348bbf1e861dfa530 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 22 Feb 2026 02:38:56 +0000 Subject: [PATCH 2/2] Remove Discord timestamps and improve devotion scraping - Removed the `date` field (containing Discord-formatted timestamps) from both `/votd/get` and `/devotion/get` API responses. - Implemented an in-memory cache for devotions to improve performance and ensure consistency, clearing old entries on date change. - Normalized whitespace in devotion titles and readings to ensure cleaner data for frontend display. - Cleaned up unused variables in route handlers. Co-authored-by: benrobson <15405528+benrobson@users.noreply.github.com> --- routes/index.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/routes/index.js b/routes/index.js index 0225ce6..e0ebb59 100644 --- a/routes/index.js +++ b/routes/index.js @@ -4,12 +4,22 @@ import moment from "moment"; import xml2js from 'xml2js'; import { removeHtmlEntities } from '../app.js'; +const devotionCache = new Map(); + export default function applicationSiteRoutes(app) { app.get('/', async function (req, res) { return res.send(`DevoteMe-API\nConnection for all of the DevoteMe suite applications.\nDeveloped by Modular Software\nDocumentation: https://modularsoft.org/docs/products/devoteMe/`); }); app.get('/devotion/get', async function (req, res) { + const today = moment().format('YYYY-MM-DD'); + if (devotionCache.has(today)) { + return res.send(devotionCache.get(today)); + } + + // Clear cache to avoid memory leaks with old dates + devotionCache.clear(); + try { const response = await fetch('https://vision.org.au/read/bible-study/the-word-for-today/', { headers: { @@ -26,10 +36,8 @@ export default function applicationSiteRoutes(app) { const html = await response.text(); const $ = cheerio.load(html); - const devotionTitle = $('h1.entry-title').first().text().trim(); - const timestamp = Math.floor(Date.now() / 1000); - const date = ``; - const devotionReading = $('h2.dmach-acf-value').first().text().trim(); + const devotionTitle = $('h1.entry-title').first().text().trim().replace(/\s+/g, ' '); + const devotionReading = $('h2.dmach-acf-value').first().text().trim().replace(/\s+/g, ' '); const devotionContent = $('.dmach-acf-value').filter((i, el) => { return $(el).find('p').length > 1; @@ -50,13 +58,14 @@ export default function applicationSiteRoutes(app) { const devotion = { title: devotionTitle, - date: date, reading: devotionReading, content: contentArray, bibleInOneYear: bibleInOneYear, credit: "From Vision Christian Media (https://vision.org.au/read/bible-study/the-word-for-today/)" }; + devotionCache.set(today, devotion); + return res.send(devotion); } catch (error) {