removed unnecessary redis

This commit is contained in:
SrGooglo 2025-02-05 02:50:52 +00:00
parent 71eac66b1f
commit 9d0afcb329

View File

@ -5,18 +5,19 @@ import B2 from "backblaze-b2"
import hePkg from "hyper-express/package.json" import hePkg from "hyper-express/package.json"
import DbManager from "@shared-classes/DbManager" import DbManager from "@shared-classes/DbManager"
import RedisClient from "@shared-classes/RedisClient"
import StorageClient from "@shared-classes/StorageClient" import StorageClient from "@shared-classes/StorageClient"
import CacheService from "@shared-classes/CacheService" import CacheService from "@shared-classes/CacheService"
import SSEManager from "@shared-classes/SSEManager"
import SharedMiddlewares from "@shared-middlewares" import SharedMiddlewares from "@shared-middlewares"
import LimitsClass from "@shared-classes/Limits" import LimitsClass from "@shared-classes/Limits"
import TaskQueueManager from "@shared-classes/TaskQueueManager"
class API extends Server { class API extends Server {
static refName = "files" static refName = "files"
static useEngine = "hyper-express" static useEngine = "hyper-express"
static routesPath = `${__dirname}/routes` static routesPath = `${__dirname}/routes`
static listen_port = process.env.HTTP_LISTEN_PORT ?? 3002 static listen_port = process.env.HTTP_LISTEN_PORT ?? 3002
static enableWebsockets = true
middlewares = { middlewares = {
...SharedMiddlewares ...SharedMiddlewares
@ -25,16 +26,20 @@ class API extends Server {
contexts = { contexts = {
db: new DbManager(), db: new DbManager(),
cache: new CacheService(), cache: new CacheService(),
redis: RedisClient(),
storage: StorageClient(), storage: StorageClient(),
b2Storage: null, b2Storage: null,
SSEManager: new SSEManager(),
limits: {}, limits: {},
} }
queuesManager = new TaskQueueManager({
workersPath: `${__dirname}/queues`,
})
async onInitialize() { async onInitialize() {
console.log(`Using HyperExpress v${hePkg.version}`) console.log(`Using HyperExpress v${hePkg.version}`)
global.storage = this.contexts.storage global.sse = this.contexts.SSEManager
if (process.env.B2_KEY_ID && process.env.B2_APP_KEY) { if (process.env.B2_KEY_ID && process.env.B2_APP_KEY) {
this.contexts.b2Storage = new B2({ this.contexts.b2Storage = new B2({
@ -49,10 +54,15 @@ class API extends Server {
console.warn("B2 storage not configured on environment, skipping...") console.warn("B2 storage not configured on environment, skipping...")
} }
await this.queuesManager.initialize({
redisOptions: this.engine.ws.redis.options
})
await this.contexts.db.initialize() await this.contexts.db.initialize()
await this.contexts.redis.initialize()
await this.contexts.storage.initialize() await this.contexts.storage.initialize()
global.storage = this.contexts.storage
global.queues = this.queuesManager
this.contexts.limits = await LimitsClass.get() this.contexts.limits = await LimitsClass.get()
} }
} }