refactoring.
This commit is contained in:
parent
b4db6be7c0
commit
1a1b246d45
@ -35,6 +35,8 @@ async function initApiRouter (options: RegisterServerOptions): Promise<Router> {
|
|||||||
|
|
||||||
await initFederationServerInfosApiRouter(options, router)
|
await initFederationServerInfosApiRouter(options, router)
|
||||||
|
|
||||||
|
await initConfigurationApiRouter(options, router)
|
||||||
|
|
||||||
if (isDebugMode(options)) {
|
if (isDebugMode(options)) {
|
||||||
// Only add this route if the debug mode is enabled at time of the server launch.
|
// Only add this route if the debug mode is enabled at time of the server launch.
|
||||||
// Note: the isDebugMode will be tested again when the API is called.
|
// Note: the isDebugMode will be tested again when the API is called.
|
||||||
@ -53,8 +55,6 @@ async function initApiRouter (options: RegisterServerOptions): Promise<Router> {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
router.use('/configuration', await initConfigurationApiRouter(options))
|
|
||||||
|
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,11 +7,10 @@ import { checkConfigurationEnabledMiddleware } from '../../middlewares/configura
|
|||||||
import { getChannelConfigurationOptions, storeChannelConfigurationOptions } from '../../configuration/channel/storage'
|
import { getChannelConfigurationOptions, storeChannelConfigurationOptions } from '../../configuration/channel/storage'
|
||||||
import { sanitizeChannelConfigurationOptions } from '../../configuration/channel/sanitize'
|
import { sanitizeChannelConfigurationOptions } from '../../configuration/channel/sanitize'
|
||||||
|
|
||||||
async function initConfigurationApiRouter (options: RegisterServerOptions): Promise<Router> {
|
async function initConfigurationApiRouter (options: RegisterServerOptions, router: Router): Promise<void> {
|
||||||
const router = options.getRouter()
|
|
||||||
const logger = options.peertubeHelpers.logger
|
const logger = options.peertubeHelpers.logger
|
||||||
|
|
||||||
router.get('/channel/:channelId', asyncMiddleware([
|
router.get('/configuration/channel/:channelId', asyncMiddleware([
|
||||||
checkConfigurationEnabledMiddleware(options),
|
checkConfigurationEnabledMiddleware(options),
|
||||||
getCheckConfigurationChannelMiddleware(options),
|
getCheckConfigurationChannelMiddleware(options),
|
||||||
async (req: Request, res: Response, _next: NextFunction): Promise<void> => {
|
async (req: Request, res: Response, _next: NextFunction): Promise<void> => {
|
||||||
@ -28,7 +27,7 @@ async function initConfigurationApiRouter (options: RegisterServerOptions): Prom
|
|||||||
}
|
}
|
||||||
]))
|
]))
|
||||||
|
|
||||||
router.post('/channel/:channelId', asyncMiddleware([
|
router.post('/configuration/channel/:channelId', asyncMiddleware([
|
||||||
checkConfigurationEnabledMiddleware(options),
|
checkConfigurationEnabledMiddleware(options),
|
||||||
getCheckConfigurationChannelMiddleware(options),
|
getCheckConfigurationChannelMiddleware(options),
|
||||||
async (req: Request, res: Response, _next: NextFunction): Promise<void> => {
|
async (req: Request, res: Response, _next: NextFunction): Promise<void> => {
|
||||||
@ -59,8 +58,6 @@ async function initConfigurationApiRouter (options: RegisterServerOptions): Prom
|
|||||||
res.json(result)
|
res.json(result)
|
||||||
}
|
}
|
||||||
]))
|
]))
|
||||||
|
|
||||||
return router
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user