mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
The commit refactors the chunked upload system to support a transformation pipeline. Key changes include: - Replace SSE field names for consistency (sseChannelId, sseUrl) - Fix progress reporting structure with state and percent fields - Add transformation handlers (a-dash, mq-hls, img-compress, video-compress) - Create new Upload class with clear separation of concerns - Improve file processing workflow with better directory structure - Fix typo in UploadButton component (progess → progress) - Remove deprecated file processing services
89 lines
2.0 KiB
JavaScript
Executable File
89 lines
2.0 KiB
JavaScript
Executable File
import { Server } from "linebridge"
|
|
|
|
import B2 from "backblaze-b2"
|
|
|
|
import DbManager from "@shared-classes/DbManager"
|
|
import RedisClient from "@shared-classes/RedisClient"
|
|
import StorageClient from "@shared-classes/StorageClient"
|
|
import CacheService from "@shared-classes/CacheService"
|
|
import SSEManager from "@shared-classes/SSEManager"
|
|
import SharedMiddlewares from "@shared-middlewares"
|
|
import LimitsClass from "@shared-classes/Limits"
|
|
import TaskQueueManager from "@shared-classes/TaskQueueManager"
|
|
|
|
// import * as Minio from 'minio'
|
|
|
|
// class StorageNG {
|
|
// constructor() {
|
|
|
|
// }
|
|
|
|
// async initialize() {
|
|
|
|
// }
|
|
// }
|
|
|
|
class API extends Server {
|
|
static refName = "files"
|
|
static useEngine = "hyper-express-ng"
|
|
static routesPath = `${__dirname}/routes`
|
|
static listen_port = process.env.HTTP_LISTEN_PORT ?? 3002
|
|
static enableWebsockets = true
|
|
|
|
middlewares = {
|
|
...SharedMiddlewares,
|
|
}
|
|
|
|
contexts = {
|
|
db: new DbManager(),
|
|
cache: new CacheService(),
|
|
storage: StorageClient(),
|
|
b2Storage: null,
|
|
SSEManager: new SSEManager(),
|
|
redis: RedisClient({
|
|
maxRetriesPerRequest: null,
|
|
}),
|
|
limits: {},
|
|
}
|
|
|
|
queuesManager = new TaskQueueManager(
|
|
{
|
|
workersPath: `${__dirname}/queues`,
|
|
},
|
|
this,
|
|
)
|
|
|
|
async onInitialize() {
|
|
global.sse = this.contexts.SSEManager
|
|
|
|
if (process.env.B2_KEY_ID && process.env.B2_APP_KEY) {
|
|
this.contexts.b2Storage = new B2({
|
|
applicationKeyId: process.env.B2_KEY_ID,
|
|
applicationKey: process.env.B2_APP_KEY,
|
|
})
|
|
|
|
global.b2Storage = this.contexts.b2Storage
|
|
|
|
await this.contexts.b2Storage.authorize()
|
|
} else {
|
|
console.warn(
|
|
"B2 storage not configured on environment, skipping...",
|
|
)
|
|
}
|
|
|
|
await this.contexts.redis.initialize()
|
|
await this.queuesManager.initialize({
|
|
redisOptions: this.contexts.redis.client,
|
|
})
|
|
await this.contexts.db.initialize()
|
|
await this.contexts.storage.initialize()
|
|
|
|
global.storage = this.contexts.storage
|
|
global.queues = this.queuesManager
|
|
|
|
this.contexts.limits = await LimitsClass.get()
|
|
}
|
|
}
|
|
|
|
Boot(API)
|