mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-09-25 22:22:58 +00:00
add api endpoint
This commit is contained in:
@@ -14,6 +14,7 @@ import express from 'express';
|
|||||||
import config from './config.js';
|
import config from './config.js';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
|
import { splitTextStyleAndMetadata } from '../shared/helpers.js';
|
||||||
|
|
||||||
import api from './homebrew.api.js';
|
import api from './homebrew.api.js';
|
||||||
const { homebrewApi, getBrew, getCSS } = api;
|
const { homebrewApi, getBrew, getCSS } = api;
|
||||||
@@ -135,6 +136,15 @@ export default async function createApp(vite) {
|
|||||||
app.get('/robots.txt', (req, res)=>{
|
app.get('/robots.txt', (req, res)=>{
|
||||||
return res.sendFile(`robots.txt`, { root: process.cwd() });
|
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
|
//Serve brew metadata
|
||||||
app.get('/metadata/:id', asyncHandler(getBrew('share')), (req, res)=>{
|
app.get('/metadata/:id', asyncHandler(getBrew('share')), (req, res)=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user