From 057125aa17273c53b57835ccc6c841be8e068128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Losada=20Hern=C3=A1ndez?= Date: Tue, 22 Sep 2026 00:32:43 +0200 Subject: [PATCH] add api endpoint --- server/app.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/app.js b/server/app.js index 714c4beba..49767c09d 100644 --- a/server/app.js +++ b/server/app.js @@ -14,6 +14,7 @@ import express from 'express'; import config from './config.js'; import path from 'path'; import fs from 'fs-extra'; +import { splitTextStyleAndMetadata } from '../shared/helpers.js'; import api from './homebrew.api.js'; const { homebrewApi, getBrew, getCSS } = api; @@ -135,6 +136,15 @@ export default async function createApp(vite) { app.get('/robots.txt', (req, res)=>{ return res.sendFile(`robots.txt`, { root: process.cwd() }); }); + //serve brew for sharepage rerender + app.get('/api/fetch/:id', asyncHandler(getBrew('share')), asyncHandler(async (req, res) => { + const { brew } = req; + brew.authors.includes(req.account?.username) + ? sanitizeBrew(brew, 'shareAuthor') + : sanitizeBrew(brew, 'share'); + splitTextStyleAndMetadata(brew); + res.json({ brew }); + })); //Serve brew metadata app.get('/metadata/:id', asyncHandler(getBrew('share')), (req, res)=>{