chore: update TypeScript build info cache
This commit is contained in:
+42
-1
@@ -44,7 +44,9 @@ import {
|
||||
// Playlists
|
||||
createPlaylist,
|
||||
listPlaylists,
|
||||
listPublicPlaylists,
|
||||
getPlaylistRaw,
|
||||
getPlaylistWithItemsIfAllowed,
|
||||
updatePlaylist,
|
||||
deletePlaylist,
|
||||
listPlaylistItems,
|
||||
@@ -60,6 +62,46 @@ const ACCESS_TTL_MIN = Number(process.env.ACCESS_TTL_MIN || 15);
|
||||
const REFRESH_TTL_DAYS = Number(process.env.REFRESH_TTL_DAYS || 2);
|
||||
const REMEMBER_TTL_DAYS = Number(process.env.REMEMBER_TTL_DAYS || 30);
|
||||
|
||||
// Create router
|
||||
const r = express.Router();
|
||||
|
||||
// Public: list public playlists (no auth required)
|
||||
r.get('/playlists/public', (req, res) => {
|
||||
try {
|
||||
const limit = Math.min(200, Math.max(1, Number(req.query.limit || 50)));
|
||||
const offset = Math.max(0, Number(req.query.offset || 0));
|
||||
const q = typeof req.query.q === 'string' ? req.query.q : undefined;
|
||||
const rows = listPublicPlaylists({ limit, offset, q });
|
||||
return res.json(rows);
|
||||
} catch (e) {
|
||||
return res.status(500).json({ error: 'list_public_failed', details: String(e?.message || e) });
|
||||
}
|
||||
});
|
||||
|
||||
// Public: view a playlist if allowed (owner or public). Authorization header is optional.
|
||||
r.get('/playlists/:id/view', (req, res) => {
|
||||
try {
|
||||
const id = String(req.params.id || '');
|
||||
let viewerUserId = undefined;
|
||||
try {
|
||||
const auth = req.headers['authorization'] || '';
|
||||
const [, token] = String(auth).split(' ');
|
||||
if (token) {
|
||||
const payload = jwt.verify(token, JWT_SECRET);
|
||||
viewerUserId = payload?.sub;
|
||||
}
|
||||
} catch {}
|
||||
const limit = Math.min(2000, Math.max(1, Number(req.query.limit || 500)));
|
||||
const offset = Math.max(0, Number(req.query.offset || 0));
|
||||
const result = getPlaylistWithItemsIfAllowed({ viewerUserId, id, limit, offset });
|
||||
if (result === 'forbidden') return res.status(404).json({ error: 'not_found' });
|
||||
if (!result) return res.status(404).json({ error: 'not_found' });
|
||||
return res.json(result);
|
||||
} catch (e) {
|
||||
return res.status(500).json({ error: 'view_failed', details: String(e?.message || e) });
|
||||
}
|
||||
});
|
||||
|
||||
// Servir les fichiers statiques du dossier dist
|
||||
app.use(express.static(path.join(process.cwd(), 'dist')));
|
||||
app.use('/assets', express.static(path.join(process.cwd(), 'assets')));
|
||||
@@ -528,7 +570,6 @@ function formatListFromMeta(meta) {
|
||||
}
|
||||
|
||||
// Routes under /api
|
||||
const r = express.Router();
|
||||
|
||||
// -------------------- YouTube simple cache (GET) --------------------
|
||||
// Cache TTL defaults to 15 minutes, configurable via env YT_CACHE_TTL_MS
|
||||
|
||||
Reference in New Issue
Block a user