1
0
forked from noxious/server

Many many more improvements

This commit is contained in:
2024-12-28 19:21:15 +01:00
parent bd3bf6f580
commit 918f5141fc
27 changed files with 178 additions and 191 deletions

View File

@ -3,7 +3,6 @@ import fs from 'fs'
import { Request, Response } from 'express'
import { BaseController } from '#application/base/baseController'
import { httpLogger } from '#application/logger'
import { getPublicPath } from '#application/storage'
import { AssetData, UUID } from '#application/types'
import SpriteRepository from '#repositories/spriteRepository'
@ -99,13 +98,13 @@ export class AssetsController extends BaseController {
const assetPath = type === 'sprites' && spriteId ? getPublicPath(type, spriteId, file) : getPublicPath(type, file)
if (!fs.existsSync(assetPath)) {
httpLogger.error(`File not found: ${assetPath}`)
this.logger.error(`File not found: ${assetPath}`)
return this.sendError(res, 'Asset not found', 404)
}
res.sendFile(assetPath, (err) => {
if (err) {
httpLogger.error('Error sending file:', err)
this.logger.error('Error sending file:' + err)
this.sendError(res, 'Error downloading the asset', 500)
}
})