mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-06-01 06:56:48 +00:00
Update dependencies
Removes node-fetch in favour of node.js 20+ native fetch.
This commit is contained in:
parent
8815e4f10b
commit
095dc3f918
6 changed files with 648 additions and 135 deletions
|
|
@ -1,7 +1,5 @@
|
|||
/** @type {import("node-fetch").default} */
|
||||
// @ts-ignore
|
||||
const fetch = require("node-fetch")
|
||||
const constants = require("../utils/constants.js")
|
||||
const {Readable} = require("stream")
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
|
|
@ -12,7 +10,7 @@ module.exports = [
|
|||
return {
|
||||
statusCode: 200,
|
||||
contentType: "image/jpeg",
|
||||
stream: res.body
|
||||
stream: Readable.fromWeb(res.body)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
const {request} = require("../utils/request")
|
||||
/** @type {import("node-fetch").default} */
|
||||
// @ts-ignore
|
||||
const fetch = require("node-fetch")
|
||||
const {render} = require("pinski/plugins")
|
||||
const db = require("../utils/db")
|
||||
const {getToken, getUser} = require("../utils/getuser")
|
||||
|
|
@ -150,7 +147,7 @@ module.exports = [
|
|||
var videoFuture = request(outURL).then(res => res.json())
|
||||
} else { // req.method === "POST"
|
||||
var instanceOrigin = "http://localhost:3000"
|
||||
var videoFuture = JSON.parse(new URLSearchParams(body.toString()).get("video"))
|
||||
var videoFuture = Promise.resolve(JSON.parse(new URLSearchParams(body.toString()).get("video")))
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -224,7 +221,7 @@ module.exports = [
|
|||
const locals = {instanceOrigin, error}
|
||||
|
||||
// Sort error category
|
||||
if (error instanceof fetch.FetchError) {
|
||||
if (String(error).includes("fetch")) {
|
||||
errorType = "fetch-error"
|
||||
} else if (error instanceof MessageError) {
|
||||
errorType = "message-error"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue