1
0
forked from noxious/server

Storage class is now OOP

This commit is contained in:
2025-01-01 21:34:23 +01:00
parent 04e081c31a
commit 5982422e04
15 changed files with 109 additions and 72 deletions

View File

@ -6,7 +6,7 @@ import { Server as SocketServer } from 'socket.io'
import config from '#application/config'
import Logger, { LoggerType } from '#application/logger'
import { getAppPath } from '#application/storage'
import Storage from '#application/storage'
import { TSocket } from '#application/types'
import SocketManager from '#managers/socketManager'
@ -56,9 +56,9 @@ class QueueManager {
const { jobName, params, socketId } = job.data
try {
const jobsDir = getAppPath('jobs')
const jobsDir = Storage.getAppPath('jobs')
const extension = config.ENV === 'development' ? '.ts' : '.js'
const jobPath = getAppPath('jobs', `${jobName}${extension}`)
const jobPath = Storage.getAppPath('jobs', `${jobName}${extension}`)
if (!fs.existsSync(jobPath)) {
this.logger.warn(`Job file not found: ${jobPath}`)

View File

@ -7,7 +7,7 @@ import { Server as SocketServer } from 'socket.io'
import config from '#application/config'
import Logger, { LoggerType } from '#application/logger'
import { getAppPath } from '#application/storage'
import Storage from '#application/storage'
import { TSocket } from '#application/types'
import { Authentication } from '#middleware/authentication'
@ -61,11 +61,11 @@ class SocketManager {
*/
private async loadEventHandlers(baseDir: string, subDir: string, socket: TSocket): Promise<void> {
try {
const fullDir = getAppPath(baseDir, subDir)
const fullDir = Storage.getAppPath(baseDir, subDir)
const files = await fs.promises.readdir(fullDir, { withFileTypes: true })
for (const file of files) {
const filePath = getAppPath(baseDir, subDir, file.name)
const filePath = Storage.getAppPath(baseDir, subDir, file.name)
if (file.isDirectory()) {
await this.loadEventHandlers(baseDir, `${subDir}/${file.name}`, socket)