POC working new caching method - moved controllers folder, renamed assets to textures, fixed HTTP bug, formatted code

This commit is contained in:
2025-01-07 03:58:32 +01:00
parent f47023dc81
commit 010454914b
25 changed files with 131 additions and 137 deletions

View File

@ -1,4 +1,6 @@
import { Request, Response } from 'express'
import fs from 'fs'
import { Response } from 'express'
import Logger, { LoggerType } from '#application/logger'
@ -19,4 +21,18 @@ export abstract class BaseController {
message
})
}
protected sendFile(res: Response, filePath: string) {
if (!fs.existsSync(filePath)) {
this.logger.error(`File not found: ${filePath}`)
return this.sendError(res, 'Asset not found', 404)
}
res.sendFile(filePath, (error) => {
if (error) {
this.logger.error('Error sending file:' + error)
this.sendError(res, 'Error downloading the asset', 500)
}
})
}
}