Add config helper for plugins

pull/2737/head
Chocobozzz 2020-04-30 08:46:40 +02:00 committed by Chocobozzz
parent ebefc902f5
commit 5a7eecdd56
2 changed files with 17 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import { PeerTubeHelpers } from '@server/typings/plugins'
import { sequelizeTypescript } from '@server/initializers/database' import { sequelizeTypescript } from '@server/initializers/database'
import { buildLogger } from '@server/helpers/logger' import { buildLogger } from '@server/helpers/logger'
import { VideoModel } from '@server/models/video/video' import { VideoModel } from '@server/models/video/video'
import { WEBSERVER } from '@server/initializers/constants'
function buildPluginHelpers (npmName: string): PeerTubeHelpers { function buildPluginHelpers (npmName: string): PeerTubeHelpers {
const logger = buildPluginLogger(npmName) const logger = buildPluginLogger(npmName)
@ -9,10 +10,13 @@ function buildPluginHelpers (npmName: string): PeerTubeHelpers {
const database = buildDatabaseHelpers() const database = buildDatabaseHelpers()
const videos = buildVideosHelpers() const videos = buildVideosHelpers()
const config = buildConfigHelpers()
return { return {
logger, logger,
database, database,
videos videos,
config
} }
} }
@ -43,3 +47,11 @@ function buildVideosHelpers () {
} }
} }
} }
function buildConfigHelpers () {
return {
getWebserverUrl () {
return WEBSERVER.URL
}
}
}

View File

@ -25,6 +25,10 @@ export type PeerTubeHelpers = {
videos: { videos: {
removeVideo: (videoId: number) => Promise<void> removeVideo: (videoId: number) => Promise<void>
} }
config: {
getWebserverUrl: () => string
}
} }
export type RegisterServerOptions = { export type RegisterServerOptions = {