peertube-plugin-livechat/server/lib/routers/index.ts

27 lines
933 B
TypeScript
Raw Normal View History

2024-05-23 09:42:14 +00:00
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
//
// SPDX-License-Identifier: AGPL-3.0-only
import type { RegisterServerOptions } from '@peertube/peertube-types'
2021-04-09 17:29:44 +00:00
import type { NextFunction, Request, Response } from 'express'
import { initWebchatRouter } from './webchat'
2021-04-09 19:28:16 +00:00
import { initSettingsRouter } from './settings'
2021-04-29 16:31:48 +00:00
import { initApiRouter } from './api'
import { initOIDCRouter } from './oidc'
2021-04-09 17:29:44 +00:00
2021-04-09 17:39:40 +00:00
async function initRouters (options: RegisterServerOptions): Promise<void> {
const { getRouter } = options
2021-04-09 17:29:44 +00:00
const router = getRouter()
router.get('/ping', (req: Request, res: Response, _next: NextFunction) => res.json({ message: 'pong' }))
2021-04-09 17:39:40 +00:00
router.use('/webchat', await initWebchatRouter(options))
2021-04-09 19:28:16 +00:00
router.use('/settings', await initSettingsRouter(options))
2021-04-29 16:31:48 +00:00
router.use('/api', await initApiRouter(options))
router.use('/oidc', await initOIDCRouter(options))
2021-04-09 17:29:44 +00:00
}
export {
initRouters
}