Mirror of static site repo git.pfy.ch/pfych/static
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132import { Hono } from 'hono';import { getNowListening } from '../services/plex/getNowListening';import { getArtwork } from '../services/plex/getArtwork';import { handleResult } from '../lib/handleResult';
export const plexRouter = new Hono();
plexRouter.get('/listening', async (c) => { const nowListeningResult = await getNowListening();
return handleResult(c, nowListeningResult, (result) => { return c.json({ nowPlaying: result }); });});
plexRouter.get('/artwork/:path{.+}', async (c) => { const { path } = c.req.param(); const artworkResult = await getArtwork(path);
return handleResult( c, artworkResult, ({ contentType, data }) => { c.status(200); c.header('Content-Type', contentType); c.header('Cache-Control', 'max-age=604800'); return c.body(data); }, { UnexpectedMimeType: 400, ArtworkNotFound: 404 }, );});