]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/controllers/themes.ts
WIP plugins: hook on client side
[github/Chocobozzz/PeerTube.git] / server / controllers / themes.ts
CommitLineData
345da516
C
1import * as express from 'express'
2import { PLUGIN_GLOBAL_CSS_PATH } from '../initializers/constants'
3import { join } from 'path'
4import { RegisteredPlugin } from '../lib/plugins/plugin-manager'
5import { servePluginStaticDirectoryValidator } from '../middlewares/validators/plugins'
6import { serveThemeCSSValidator } from '../middlewares/validators/themes'
7
8const themesRouter = express.Router()
9
10themesRouter.get('/:themeName/:themeVersion/css/:staticEndpoint',
11 serveThemeCSSValidator,
12 serveThemeCSSDirectory
13)
14
15// ---------------------------------------------------------------------------
16
17export {
18 themesRouter
19}
20
21// ---------------------------------------------------------------------------
22
23function serveThemeCSSDirectory (req: express.Request, res: express.Response) {
24 const plugin: RegisteredPlugin = res.locals.registeredPlugin
25 const staticEndpoint = req.params.staticEndpoint
26
27 return express.static(join(plugin.path, staticEndpoint), { fallthrough: false })
28}