WIP on builtin prosody.

This commit is contained in:
John Livingston
2021-04-12 20:52:21 +02:00
parent 79bdaceb48
commit 4690d97384
3 changed files with 136 additions and 7 deletions

View File

@ -5,20 +5,20 @@ const version: string = packagejson.version || ''
if (!/^\d+\.\d+\.\d+/.test(version)) {
throw new Error('Incorrect version in package.json.')
}
const name: string = packagejson.name || ''
if (!/^peertube-plugin-[-a-z]+$/.test(name)) {
const pluginName: string = packagejson.name || ''
if (!/^peertube-plugin-[-a-z]+$/.test(pluginName)) {
throw new Error('Incorrect plugin name in package.json.')
}
const shortName = name.substring('peertube-plugin-'.length)
const pluginShortName = pluginName.substring('peertube-plugin-'.length)
// FIXME: in Peertube <= 3.1.0, PeertubeHelpers dont provide this function
function getBaseRouter (): string {
return '/plugins/' + shortName + '/router/'
return '/plugins/' + pluginShortName + '/router/'
}
// FIXME: in Peertube <= 3.1.0, PeertubeHelpers dont provide this function
function getBaseStaticRoute (): string {
return '/plugins/' + shortName + '/' + version + '/static/'
return '/plugins/' + pluginShortName + '/' + version + '/static/'
}
// FIXME: Peertube <= 3.1.0 has no way to test that current user is admin
@ -36,5 +36,7 @@ function isUserAdmin (res: Response): boolean {
export {
getBaseRouter,
getBaseStaticRoute,
isUserAdmin
isUserAdmin,
pluginName,
pluginShortName
}