23 lines
551 B
JavaScript
23 lines
551 B
JavaScript
|
import express from 'express';
|
||
|
import { exploreVideos, graphToDOT } from '../lib/explore.mjs';
|
||
|
import { retryable } from '../lib/retry.mjs';
|
||
|
|
||
|
const router = express.Router();
|
||
|
export default router;
|
||
|
|
||
|
const retryExploreVideos = retryable(exploreVideos);
|
||
|
|
||
|
router.get('/:videoId', async (req, res) => {
|
||
|
try
|
||
|
{
|
||
|
const graph = await retryExploreVideos(req.params.videoId);
|
||
|
const dot = graphToDOT(...graph);
|
||
|
res.send(dot);
|
||
|
}
|
||
|
catch (err)
|
||
|
{
|
||
|
console.error(err);
|
||
|
res.status(500).send('Error');
|
||
|
}
|
||
|
});
|