mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 02:09:37 +02:00
refactor API errors to standard error format
This commit is contained in:
parent
5ed25fb76e
commit
76148b27f7
75 changed files with 785 additions and 547 deletions
|
@ -56,10 +56,10 @@ async function getActorImage (req: express.Request, res: express.Response) {
|
|||
}
|
||||
|
||||
const image = await ActorImageModel.loadByName(filename)
|
||||
if (!image) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
|
||||
if (!image) return res.status(HttpStatusCode.NOT_FOUND_404).end()
|
||||
|
||||
if (image.onDisk === false) {
|
||||
if (!image.fileUrl) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
|
||||
if (!image.fileUrl) return res.status(HttpStatusCode.NOT_FOUND_404).end()
|
||||
|
||||
logger.info('Lazy serve remote actor image %s.', image.fileUrl)
|
||||
|
||||
|
@ -67,7 +67,7 @@ async function getActorImage (req: express.Request, res: express.Response) {
|
|||
await pushActorImageProcessInQueue({ filename: image.filename, fileUrl: image.fileUrl, type: image.type })
|
||||
} catch (err) {
|
||||
logger.warn('Cannot process remote actor image %s.', image.fileUrl, { err })
|
||||
return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
|
||||
return res.status(HttpStatusCode.NOT_FOUND_404).end()
|
||||
}
|
||||
|
||||
image.onDisk = true
|
||||
|
@ -83,21 +83,21 @@ async function getActorImage (req: express.Request, res: express.Response) {
|
|||
|
||||
async function getPreview (req: express.Request, res: express.Response) {
|
||||
const result = await VideosPreviewCache.Instance.getFilePath(req.params.filename)
|
||||
if (!result) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
|
||||
if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end()
|
||||
|
||||
return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.LAZY_SERVER })
|
||||
}
|
||||
|
||||
async function getVideoCaption (req: express.Request, res: express.Response) {
|
||||
const result = await VideosCaptionCache.Instance.getFilePath(req.params.filename)
|
||||
if (!result) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
|
||||
if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end()
|
||||
|
||||
return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.LAZY_SERVER })
|
||||
}
|
||||
|
||||
async function getTorrent (req: express.Request, res: express.Response) {
|
||||
const result = await VideosTorrentCache.Instance.getFilePath(req.params.filename)
|
||||
if (!result) return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
|
||||
if (!result) return res.status(HttpStatusCode.NOT_FOUND_404).end()
|
||||
|
||||
// Torrents still use the old naming convention (video uuid + .torrent)
|
||||
return res.sendFile(result.path, { maxAge: STATIC_MAX_AGE.SERVER })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue