peertube-plugin-livechat/server/main.ts
John Livingston 20a461a84b Fix import.
2021-04-09 11:22:46 +02:00

37 lines
835 B
TypeScript

import { initSettings } from './lib/settings'
import { initRouters } from './lib/routers'
import type { Logger } from 'winston'
import decache from 'decache'
let logger: Logger | undefined
async function register ({
registerSetting,
settingsManager,
getRouter,
peertubeHelpers
}: RegisterServerOptions): Promise<any> {
logger = peertubeHelpers.logger
await initSettings({ registerSetting })
await initRouters({
settingsManager,
getRouter,
peertubeHelpers
})
}
async function unregister (): Promise<any> {
const module = __filename
logger?.info(`Unloading module ${module}...`)
// In peertube <= 3.1.0 sub modules are not removed from require.cache
decache(module)
logger?.info(`Successfully unloaded the module ${module}`)
logger = undefined
}
module.exports = {
register,
unregister
}