mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 10:19:35 +02:00
replace numbers with typed http status codes (#3409)
This commit is contained in:
parent
adc1f09c0d
commit
2d53be0267
149 changed files with 1721 additions and 1108 deletions
|
@ -8,6 +8,7 @@ import { logger } from '../helpers/logger'
|
|||
import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants'
|
||||
import { ClientHtml } from '../lib/client-html'
|
||||
import { asyncMiddleware, embedCSP } from '../middlewares'
|
||||
import { HttpStatusCode } from '@shared/core-utils'
|
||||
|
||||
const clientsRouter = express.Router()
|
||||
|
||||
|
@ -87,7 +88,7 @@ clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE.C
|
|||
|
||||
// 404 for static files not found
|
||||
clientsRouter.use('/client/*', (req: express.Request, res: express.Response) => {
|
||||
res.sendStatus(404)
|
||||
res.sendStatus(HttpStatusCode.NOT_FOUND_404)
|
||||
})
|
||||
|
||||
// Always serve index client page (the client is a single page application, let it handle routing)
|
||||
|
@ -114,7 +115,7 @@ function serveServerTranslations (req: express.Request, res: express.Response) {
|
|||
return res.sendFile(path, { maxAge: STATIC_MAX_AGE.SERVER })
|
||||
}
|
||||
|
||||
return res.sendStatus(404)
|
||||
return res.sendStatus(HttpStatusCode.NOT_FOUND_404)
|
||||
}
|
||||
|
||||
async function serveIndexHTML (req: express.Request, res: express.Response) {
|
||||
|
@ -127,7 +128,7 @@ async function serveIndexHTML (req: express.Request, res: express.Response) {
|
|||
}
|
||||
}
|
||||
|
||||
return res.status(404).end()
|
||||
return res.status(HttpStatusCode.INTERNAL_SERVER_ERROR_500).end()
|
||||
}
|
||||
|
||||
async function generateEmbedHtmlPage (req: express.Request, res: express.Response) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue