1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-12-22 13:07:00 +00:00
cloudtube/api/thumbnails.js

21 lines
501 B
JavaScript
Raw Normal View History

2021-05-11 09:27:57 +00:00
/** @type {import("node-fetch").default} */
// @ts-ignore
2020-11-25 00:34:08 +00:00
const fetch = require("node-fetch")
const constants = require("../utils/constants.js")
module.exports = [
{
route: `/vi/(${constants.regex.video_id})/(\\w+\\.jpg)`, methods: ["GET"], code: ({fill}) => {
const videoID = fill[0]
const file = fill[1]
return fetch(`https://i.ytimg.com/vi/${videoID}/${file}`).then(res => {
return {
statusCode: 200,
contentType: "image/jpeg",
stream: res.body
}
})
}
}
]