X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fplugins.ts;h=28fffc9e1dfcee68e0d886e3b655fdf69583b236;hb=ce7c099f0e36f00d88f7082dd7e158197d3146dd;hp=105f515184130196a093d5f2d842448e5e7542ca;hpb=903353d67a8d0fdda8465ed6c57b77a9a5afbe92;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/plugins.ts b/server/controllers/plugins.ts index 105f51518..28fffc9e1 100644 --- a/server/controllers/plugins.ts +++ b/server/controllers/plugins.ts @@ -1,9 +1,9 @@ -import * as express from 'express' +import express from 'express' import { join } from 'path' import { logger } from '@server/helpers/logger' import { optionalAuthenticate } from '@server/middlewares/auth' import { getCompleteLocale, is18nLocale } from '../../shared/core-utils/i18n' -import { HttpStatusCode } from '../../shared/core-utils/miscs/http-error-codes' +import { HttpStatusCode } from '../../shared/models/http/http-error-codes' import { PluginType } from '../../shared/models/plugins/plugin.type' import { isTestInstance } from '../helpers/core-utils' import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants' @@ -100,7 +100,7 @@ function getPluginTranslations (req: express.Request, res: express.Response) { return res.json(json) } - return res.sendStatus(HttpStatusCode.NOT_FOUND_404) + return res.status(HttpStatusCode.NOT_FOUND_404).end() } function servePluginStaticDirectory (req: express.Request, res: express.Response) { @@ -110,7 +110,7 @@ function servePluginStaticDirectory (req: express.Request, res: express.Response const [ directory, ...file ] = staticEndpoint.split('/') const staticPath = plugin.staticDirs[directory] - if (!staticPath) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) + if (!staticPath) return res.status(HttpStatusCode.NOT_FOUND_404).end() const filepath = file.join('/') return res.sendFile(join(plugin.path, staticPath, filepath), sendFileOptions) @@ -120,7 +120,7 @@ function servePluginCustomRoutes (req: express.Request, res: express.Response, n const plugin: RegisteredPlugin = res.locals.registeredPlugin const router = PluginManager.Instance.getRouter(plugin.npmName) - if (!router) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) + if (!router) return res.status(HttpStatusCode.NOT_FOUND_404).end() return router(req, res, next) } @@ -130,7 +130,7 @@ function servePluginClientScripts (req: express.Request, res: express.Response) const staticEndpoint = req.params.staticEndpoint const file = plugin.clientScripts[staticEndpoint] - if (!file) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) + if (!file) return res.status(HttpStatusCode.NOT_FOUND_404).end() return res.sendFile(join(plugin.path, staticEndpoint), sendFileOptions) } @@ -140,7 +140,7 @@ function serveThemeCSSDirectory (req: express.Request, res: express.Response) { const staticEndpoint = req.params.staticEndpoint if (plugin.css.includes(staticEndpoint) === false) { - return res.sendStatus(HttpStatusCode.NOT_FOUND_404) + return res.status(HttpStatusCode.NOT_FOUND_404).end() } return res.sendFile(join(plugin.path, staticEndpoint), sendFileOptions)