1
0
Fork 0

Add config helper for plugins

This commit is contained in:
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 { buildLogger } from '@server/helpers/logger'
import { VideoModel } from '@server/models/video/video'
import { WEBSERVER } from '@server/initializers/constants'
function buildPluginHelpers (npmName: string): PeerTubeHelpers {
const logger = buildPluginLogger(npmName)
@ -9,10 +10,13 @@ function buildPluginHelpers (npmName: string): PeerTubeHelpers {
const database = buildDatabaseHelpers()
const videos = buildVideosHelpers()
const config = buildConfigHelpers()
return {
logger,
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: {
removeVideo: (videoId: number) => Promise<void>
}
config: {
getWebserverUrl: () => string
}
}
export type RegisterServerOptions = {