mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
Drop deprecated endpoints & utils
This commit is contained in:
parent
d078a91ab5
commit
ad860f51d3
@ -11,18 +11,6 @@ import SharedMiddlewares from "@shared-middlewares"
|
|||||||
import LimitsClass from "@shared-classes/Limits"
|
import LimitsClass from "@shared-classes/Limits"
|
||||||
import TaskQueueManager from "@shared-classes/TaskQueueManager"
|
import TaskQueueManager from "@shared-classes/TaskQueueManager"
|
||||||
|
|
||||||
// import * as Minio from 'minio'
|
|
||||||
|
|
||||||
// class StorageNG {
|
|
||||||
// constructor() {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// async initialize() {
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
class API extends Server {
|
class API extends Server {
|
||||||
static refName = "files"
|
static refName = "files"
|
||||||
static useEngine = "hyper-express-ng"
|
static useEngine = "hyper-express-ng"
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
import mimetypes from "mime-types"
|
|
||||||
|
|
||||||
export default {
|
|
||||||
useContext: ["storage"],
|
|
||||||
fn: async (req, res) => {
|
|
||||||
const streamPath = req.path.replace(req.route.pattern.replace("*", ""), "/")
|
|
||||||
|
|
||||||
this.default.contexts.storage.getObject(process.env.S3_BUCKET, streamPath, (err, dataStream) => {
|
|
||||||
if (err) {
|
|
||||||
return res.status(404).end()
|
|
||||||
}
|
|
||||||
|
|
||||||
const extname = mimetypes.lookup(streamPath)
|
|
||||||
|
|
||||||
// send chunked response
|
|
||||||
res.status(200)
|
|
||||||
|
|
||||||
// set headers
|
|
||||||
res.setHeader("Content-Type", extname)
|
|
||||||
res.setHeader("Accept-Ranges", "bytes")
|
|
||||||
|
|
||||||
return dataStream.pipe(res)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
import fs from "node:fs"
|
|
||||||
import os from "node:os"
|
|
||||||
import axios from "axios"
|
|
||||||
|
|
||||||
export default async (outputDir) => {
|
|
||||||
const arch = os.arch()
|
|
||||||
|
|
||||||
console.log(`Downloading ffmpeg for ${arch}...`)
|
|
||||||
const baseURL = `https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-${arch}-static.tar.xz`
|
|
||||||
|
|
||||||
|
|
||||||
const response = await axios.get(baseURL, {
|
|
||||||
responseType: "stream"
|
|
||||||
})
|
|
||||||
|
|
||||||
const ffmpegPath = path.join(outputDir, `ffmpeg-${arch}.tar.xz`)
|
|
||||||
const ffmpegFile = fs.createWriteStream(ffmpegPath)
|
|
||||||
|
|
||||||
response.data.pipe(ffmpegFile)
|
|
||||||
}
|
|
@ -1,20 +0,0 @@
|
|||||||
export default (from, to) => {
|
|
||||||
const resolvedUrl = new URL(to, new URL(from, "resolve://"))
|
|
||||||
|
|
||||||
if (resolvedUrl.protocol === "resolve:") {
|
|
||||||
let { pathname, search, hash } = resolvedUrl
|
|
||||||
|
|
||||||
if (to.includes("@")) {
|
|
||||||
const fromUrl = new URL(from)
|
|
||||||
const toUrl = new URL(to, fromUrl.origin)
|
|
||||||
|
|
||||||
pathname = toUrl.pathname
|
|
||||||
search = toUrl.search
|
|
||||||
hash = toUrl.hash
|
|
||||||
}
|
|
||||||
|
|
||||||
return pathname + search + hash
|
|
||||||
}
|
|
||||||
|
|
||||||
return resolvedUrl.toString()
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
import fs from "fs"
|
|
||||||
import path from "path"
|
|
||||||
|
|
||||||
async function syncFolder(dir, destPath) {
|
|
||||||
const files = await fs.promises.readdir(dir)
|
|
||||||
|
|
||||||
for await (const file of files) {
|
|
||||||
const filePath = path.resolve(dir, file)
|
|
||||||
const desitinationFilePath = `${destPath}/${file}`
|
|
||||||
|
|
||||||
const stat = fs.statSync(filePath)
|
|
||||||
|
|
||||||
if (stat.isDirectory()) {
|
|
||||||
await syncFolder(filePath, desitinationFilePath)
|
|
||||||
} else {
|
|
||||||
const fileContent = await fs.promises.readFile(filePath)
|
|
||||||
|
|
||||||
await global.storage.putObject(process.env.S3_BUCKET, desitinationFilePath, fileContent)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default syncFolder
|
|
Loading…
x
Reference in New Issue
Block a user