diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-06-01 01:36:53 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-06-02 16:57:07 +0200 |
commit | 76148b27f7501bac061992136852be4303370c8d (patch) | |
tree | fc0559253e833c9252fa14ebaec5321d88bfb4e8 /server/controllers/plugins.ts | |
parent | 5ed25fb76e920dac364cb9ef46f14ec4bd372949 (diff) | |
download | PeerTube-76148b27f7501bac061992136852be4303370c8d.tar.gz PeerTube-76148b27f7501bac061992136852be4303370c8d.tar.zst PeerTube-76148b27f7501bac061992136852be4303370c8d.zip |
refactor API errors to standard error format
Diffstat (limited to 'server/controllers/plugins.ts')
-rw-r--r-- | server/controllers/plugins.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/server/controllers/plugins.ts b/server/controllers/plugins.ts index 105f51518..7213e3f15 100644 --- a/server/controllers/plugins.ts +++ b/server/controllers/plugins.ts | |||
@@ -100,7 +100,7 @@ function getPluginTranslations (req: express.Request, res: express.Response) { | |||
100 | return res.json(json) | 100 | return res.json(json) |
101 | } | 101 | } |
102 | 102 | ||
103 | return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 103 | return res.status(HttpStatusCode.NOT_FOUND_404).end() |
104 | } | 104 | } |
105 | 105 | ||
106 | function servePluginStaticDirectory (req: express.Request, res: express.Response) { | 106 | function servePluginStaticDirectory (req: express.Request, res: express.Response) { |
@@ -110,7 +110,7 @@ function servePluginStaticDirectory (req: express.Request, res: express.Response | |||
110 | const [ directory, ...file ] = staticEndpoint.split('/') | 110 | const [ directory, ...file ] = staticEndpoint.split('/') |
111 | 111 | ||
112 | const staticPath = plugin.staticDirs[directory] | 112 | const staticPath = plugin.staticDirs[directory] |
113 | if (!staticPath) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 113 | if (!staticPath) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
114 | 114 | ||
115 | const filepath = file.join('/') | 115 | const filepath = file.join('/') |
116 | return res.sendFile(join(plugin.path, staticPath, filepath), sendFileOptions) | 116 | return res.sendFile(join(plugin.path, staticPath, filepath), sendFileOptions) |
@@ -120,7 +120,7 @@ function servePluginCustomRoutes (req: express.Request, res: express.Response, n | |||
120 | const plugin: RegisteredPlugin = res.locals.registeredPlugin | 120 | const plugin: RegisteredPlugin = res.locals.registeredPlugin |
121 | const router = PluginManager.Instance.getRouter(plugin.npmName) | 121 | const router = PluginManager.Instance.getRouter(plugin.npmName) |
122 | 122 | ||
123 | if (!router) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 123 | if (!router) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
124 | 124 | ||
125 | return router(req, res, next) | 125 | return router(req, res, next) |
126 | } | 126 | } |
@@ -130,7 +130,7 @@ function servePluginClientScripts (req: express.Request, res: express.Response) | |||
130 | const staticEndpoint = req.params.staticEndpoint | 130 | const staticEndpoint = req.params.staticEndpoint |
131 | 131 | ||
132 | const file = plugin.clientScripts[staticEndpoint] | 132 | const file = plugin.clientScripts[staticEndpoint] |
133 | if (!file) return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 133 | if (!file) return res.status(HttpStatusCode.NOT_FOUND_404).end() |
134 | 134 | ||
135 | return res.sendFile(join(plugin.path, staticEndpoint), sendFileOptions) | 135 | return res.sendFile(join(plugin.path, staticEndpoint), sendFileOptions) |
136 | } | 136 | } |
@@ -140,7 +140,7 @@ function serveThemeCSSDirectory (req: express.Request, res: express.Response) { | |||
140 | const staticEndpoint = req.params.staticEndpoint | 140 | const staticEndpoint = req.params.staticEndpoint |
141 | 141 | ||
142 | if (plugin.css.includes(staticEndpoint) === false) { | 142 | if (plugin.css.includes(staticEndpoint) === false) { |
143 | return res.sendStatus(HttpStatusCode.NOT_FOUND_404) | 143 | return res.status(HttpStatusCode.NOT_FOUND_404).end() |
144 | } | 144 | } |
145 | 145 | ||
146 | return res.sendFile(join(plugin.path, staticEndpoint), sendFileOptions) | 146 | return res.sendFile(join(plugin.path, staticEndpoint), sendFileOptions) |