aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-04-30 08:46:40 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-05-04 16:21:39 +0200
commit5a7eecdd56120bc29b47ab071c8b8cd16efa3843 (patch)
tree5e7d5b4bf95abeccde12252d7927d3847c925569 /server
parentebefc902f59be6c5542c19ff706e310d9dddf75f (diff)
downloadPeerTube-5a7eecdd56120bc29b47ab071c8b8cd16efa3843.tar.gz
PeerTube-5a7eecdd56120bc29b47ab071c8b8cd16efa3843.tar.zst
PeerTube-5a7eecdd56120bc29b47ab071c8b8cd16efa3843.zip
Add config helper for plugins
Diffstat (limited to 'server')
-rw-r--r--server/lib/plugins/plugin-helpers.ts14
-rw-r--r--server/typings/plugins/register-server-option.model.ts4
2 files changed, 17 insertions, 1 deletions
diff --git a/server/lib/plugins/plugin-helpers.ts b/server/lib/plugins/plugin-helpers.ts
index e91beffba..608207e05 100644
--- a/server/lib/plugins/plugin-helpers.ts
+++ b/server/lib/plugins/plugin-helpers.ts
@@ -2,6 +2,7 @@ import { PeerTubeHelpers } from '@server/typings/plugins'
2import { sequelizeTypescript } from '@server/initializers/database' 2import { sequelizeTypescript } from '@server/initializers/database'
3import { buildLogger } from '@server/helpers/logger' 3import { buildLogger } from '@server/helpers/logger'
4import { VideoModel } from '@server/models/video/video' 4import { VideoModel } from '@server/models/video/video'
5import { WEBSERVER } from '@server/initializers/constants'
5 6
6function buildPluginHelpers (npmName: string): PeerTubeHelpers { 7function buildPluginHelpers (npmName: string): PeerTubeHelpers {
7 const logger = buildPluginLogger(npmName) 8 const logger = buildPluginLogger(npmName)
@@ -9,10 +10,13 @@ function buildPluginHelpers (npmName: string): PeerTubeHelpers {
9 const database = buildDatabaseHelpers() 10 const database = buildDatabaseHelpers()
10 const videos = buildVideosHelpers() 11 const videos = buildVideosHelpers()
11 12
13 const config = buildConfigHelpers()
14
12 return { 15 return {
13 logger, 16 logger,
14 database, 17 database,
15 videos 18 videos,
19 config
16 } 20 }
17} 21}
18 22
@@ -43,3 +47,11 @@ function buildVideosHelpers () {
43 } 47 }
44 } 48 }
45} 49}
50
51function buildConfigHelpers () {
52 return {
53 getWebserverUrl () {
54 return WEBSERVER.URL
55 }
56 }
57}
diff --git a/server/typings/plugins/register-server-option.model.ts b/server/typings/plugins/register-server-option.model.ts
index bcabf2fec..c1e63316d 100644
--- a/server/typings/plugins/register-server-option.model.ts
+++ b/server/typings/plugins/register-server-option.model.ts
@@ -25,6 +25,10 @@ export type PeerTubeHelpers = {
25 videos: { 25 videos: {
26 removeVideo: (videoId: number) => Promise<void> 26 removeVideo: (videoId: number) => Promise<void>
27 } 27 }
28
29 config: {
30 getWebserverUrl: () => string
31 }
28} 32}
29 33
30export type RegisterServerOptions = { 34export type RegisterServerOptions = {