fp/packages/strapi/database/migrations/2023.05.09-video-src-sanity...

26 lines
514 B
Plaintext
Raw Normal View History

2024-01-20 16:16:14 +00:00
const fetch = require('node-fetch')
let problemUrls = []
async function checkUrl(url) {
const res = await fetch(url);
if (!res.ok || !res?.headers?.get('x-bz-file-name') || !res?.headers?.get('x-bz-file-id')) problemUrls.push(url)
}
module.exports = {
async up(knex) {
// Get all VODs from the database
const vods = await knex.select('*').from('vods');
// sanity check every B2 URL
for (const vod of vods) {
await checkUrl(vod.video_src)
}
process.exit(5923423)
},
};