chore: update Angular build cache and TypeScript definitions
This commit is contained in:
+65
-9
@@ -37,6 +37,10 @@ import {
|
||||
updateWatchHistoryById,
|
||||
deleteWatchHistoryById,
|
||||
deleteAllWatchHistory,
|
||||
likeVideo,
|
||||
unlikeVideo,
|
||||
listLikedVideos,
|
||||
isVideoLiked,
|
||||
} from './db.mjs';
|
||||
|
||||
const app = express();
|
||||
@@ -977,7 +981,8 @@ r.post('/user/history/search', authMiddleware, (req, res) => {
|
||||
r.get('/user/history/search', authMiddleware, (req, res) => {
|
||||
const limit = Math.min(200, Number(req.query.limit || 50));
|
||||
const before = req.query.before ? String(req.query.before) : undefined;
|
||||
const rows = listSearchHistory({ userId: req.user.id, limit, before });
|
||||
const q = typeof req.query.q === 'string' ? req.query.q : undefined;
|
||||
const rows = listSearchHistory({ userId: req.user.id, limit, before, q });
|
||||
return res.json(rows);
|
||||
});
|
||||
|
||||
@@ -992,21 +997,46 @@ r.delete('/user/history/search', authMiddleware, (req, res) => {
|
||||
return res.status(204).end();
|
||||
});
|
||||
|
||||
// Delete a single search history item
|
||||
r.delete('/user/history/search/:id', authMiddleware, (req, res) => {
|
||||
const { id } = req.params;
|
||||
if (!id) return res.status(400).json({ error: 'id is required' });
|
||||
try {
|
||||
deleteSearchHistoryById(req.user.id, id);
|
||||
return res.status(204).end();
|
||||
} catch (e) {
|
||||
return res.status(500).json({ error: 'delete_failed', details: String(e?.message || e) });
|
||||
}
|
||||
});
|
||||
|
||||
// --- History: Watch ---
|
||||
r.post('/user/history/watch', authMiddleware, (req, res) => {
|
||||
const { provider, videoId, title, watchedAt, progressSeconds, durationSeconds, lastPositionSeconds } = req.body || {};
|
||||
const { provider, videoId, title, thumbnail, watchedAt, progressSeconds, durationSeconds, lastPositionSeconds } = req.body || {};
|
||||
if (!provider || !videoId) return res.status(400).json({ error: 'provider and videoId are required' });
|
||||
const row = upsertWatchHistory({ userId: req.user.id, provider, videoId, title, watchedAt, progressSeconds, durationSeconds, lastPositionSeconds });
|
||||
const row = upsertWatchHistory({ userId: req.user.id, provider, videoId, title, thumbnail, watchedAt, progressSeconds, durationSeconds, lastPositionSeconds });
|
||||
return res.status(201).json(row);
|
||||
});
|
||||
|
||||
r.get('/user/history/watch', authMiddleware, (req, res) => {
|
||||
const limit = Math.min(200, Number(req.query.limit || 50));
|
||||
const before = req.query.before ? String(req.query.before) : undefined;
|
||||
const rows = listWatchHistory({ userId: req.user.id, limit, before });
|
||||
const q = typeof req.query.q === 'string' ? req.query.q : undefined;
|
||||
const rows = listWatchHistory({ userId: req.user.id, limit, before, q });
|
||||
return res.json(rows);
|
||||
});
|
||||
|
||||
// Delete a single watch history item
|
||||
r.delete('/user/history/watch/:id', authMiddleware, (req, res) => {
|
||||
const { id } = req.params;
|
||||
if (!id) return res.status(400).json({ error: 'id is required' });
|
||||
try {
|
||||
deleteWatchHistoryById(req.user.id, id);
|
||||
return res.status(204).end();
|
||||
} catch (e) {
|
||||
return res.status(500).json({ error: 'delete_failed', details: String(e?.message || e) });
|
||||
}
|
||||
});
|
||||
|
||||
r.patch('/user/history/watch/:id', authMiddleware, (req, res) => {
|
||||
const { progressSeconds, lastPositionSeconds } = req.body || {};
|
||||
const row = updateWatchHistoryById(req.params.id, { progressSeconds, lastPositionSeconds });
|
||||
@@ -1014,17 +1044,43 @@ r.patch('/user/history/watch/:id', authMiddleware, (req, res) => {
|
||||
return res.json(row);
|
||||
});
|
||||
|
||||
r.delete('/user/history/watch/:id', authMiddleware, (req, res) => {
|
||||
deleteWatchHistoryById(req.user.id, req.params.id);
|
||||
return res.status(204).end();
|
||||
});
|
||||
|
||||
r.delete('/user/history/watch', authMiddleware, (req, res) => {
|
||||
if (String(req.query.all || '') !== '1') return res.status(400).json({ error: 'set all=1' });
|
||||
deleteAllWatchHistory(req.user.id);
|
||||
return res.status(204).end();
|
||||
});
|
||||
|
||||
// --- Likes ---
|
||||
r.get('/user/likes', authMiddleware, (req, res) => {
|
||||
const limit = Math.min(500, Number(req.query.limit || 100));
|
||||
const q = typeof req.query.q === 'string' ? req.query.q : undefined;
|
||||
const rows = listLikedVideos({ userId: req.user.id, limit, q });
|
||||
return res.json(rows);
|
||||
});
|
||||
|
||||
r.post('/user/likes', authMiddleware, (req, res) => {
|
||||
const { provider, videoId } = req.body || {};
|
||||
if (!provider || !videoId) return res.status(400).json({ error: 'provider and videoId are required' });
|
||||
const row = likeVideo({ userId: req.user.id, provider, videoId });
|
||||
return res.status(201).json(row);
|
||||
});
|
||||
|
||||
r.delete('/user/likes', authMiddleware, (req, res) => {
|
||||
const provider = req.query.provider ? String(req.query.provider) : '';
|
||||
const videoId = req.query.videoId ? String(req.query.videoId) : '';
|
||||
if (!provider || !videoId) return res.status(400).json({ error: 'provider and videoId are required' });
|
||||
const result = unlikeVideo({ userId: req.user.id, provider, videoId });
|
||||
return res.json(result);
|
||||
});
|
||||
|
||||
r.get('/user/likes/status', authMiddleware, (req, res) => {
|
||||
const provider = req.query.provider ? String(req.query.provider) : '';
|
||||
const videoId = req.query.videoId ? String(req.query.videoId) : '';
|
||||
if (!provider || !videoId) return res.status(400).json({ error: 'provider and videoId are required' });
|
||||
const liked = isVideoLiked({ userId: req.user.id, provider, videoId });
|
||||
return res.json({ liked });
|
||||
});
|
||||
|
||||
app.use('/api', r);
|
||||
// Mount dedicated Rumble router (browse, search, video)
|
||||
app.use('/api/rumble', rumbleRouter);
|
||||
|
||||
Reference in New Issue
Block a user