diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-12-07 14:32:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-07 14:32:36 +0100 |
commit | 2d53be0267acc49cda46707b885096193a1f4e9c (patch) | |
tree | 887061a34bc67f40acbb96a6278f9544bf83caeb /server/controllers/client.ts | |
parent | adc1f09c0dbd997f34028c1c82d1c118dc8ead80 (diff) | |
download | PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.gz PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.tar.zst PeerTube-2d53be0267acc49cda46707b885096193a1f4e9c.zip |
replace numbers with typed http status codes (#3409)
Diffstat (limited to 'server/controllers/client.ts')
-rw-r--r-- | server/controllers/client.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts index 592233676..49e6fd661 100644 --- a/server/controllers/client.ts +++ b/server/controllers/client.ts | |||
@@ -8,6 +8,7 @@ import { logger } from '../helpers/logger' | |||
8 | import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' | 8 | import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' |
9 | import { ClientHtml } from '../lib/client-html' | 9 | import { ClientHtml } from '../lib/client-html' |
10 | import { asyncMiddleware, embedCSP } from '../middlewares' | 10 | import { asyncMiddleware, embedCSP } from '../middlewares' |
11 | import { HttpStatusCode } from '@shared/core-utils' | ||
11 | 12 | ||
12 | const clientsRouter = express.Router() | 13 | const clientsRouter = express.Router() |
13 | 14 | ||
@@ -87,7 +88,7 @@ clientsRouter.use('/client', express.static(distPath, { maxAge: STATIC_MAX_AGE.C | |||
87 | 88 | ||
88 | // 404 for static files not found | 89 | // 404 for static files not found |
89 | clientsRouter.use('/client/*', (req: express.Request, res: express.Response) => { | 90 | clientsRouter.use('/client/*', (req: express.Request, res: express.Response) => { |
90 | res.sendStatus(404) | 91 | res.sendStatus(HttpStatusCode.NOT_FOUND_404) |
91 | }) | 92 | }) |
92 | 93 | ||
93 | // Always serve index client page (the client is a single page application, let it handle routing) | 94 | // 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) { | |||
114 | return res.sendFile(path, { maxAge: STATIC_MAX_AGE.SERVER }) | 115 | return res.sendFile(path, { maxAge: STATIC_MAX_AGE.SERVER }) |
115 | } | 116 | } |
116 | 117 | ||
117 | return res.sendStatus(404) | 118 | return res.sendStatus(HttpStatusCode.NOT_FOUND_404) |
118 | } | 119 | } |
119 | 120 | ||
120 | async function serveIndexHTML (req: express.Request, res: express.Response) { | 121 | async function serveIndexHTML (req: express.Request, res: express.Response) { |
@@ -127,7 +128,7 @@ async function serveIndexHTML (req: express.Request, res: express.Response) { | |||
127 | } | 128 | } |
128 | } | 129 | } |
129 | 130 | ||
130 | return res.status(404).end() | 131 | return res.status(HttpStatusCode.INTERNAL_SERVER_ERROR_500).end() |
131 | } | 132 | } |
132 | 133 | ||
133 | async function generateEmbedHtmlPage (req: express.Request, res: express.Response) { | 134 | async function generateEmbedHtmlPage (req: express.Request, res: express.Response) { |