Initializing a diagnostic tools. WIP

This commit is contained in:
John Livingston
2021-04-09 21:28:16 +02:00
parent 8b3763761b
commit 59cd78ee82
7 changed files with 115 additions and 5 deletions

25
server/lib/helpers.ts Normal file
View File

@ -0,0 +1,25 @@
const packagejson: any = require('../../../package.json')
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)) {
throw new Error('Incorrect plugin name in package.json.')
}
const shortName = name.substring('peertube-plugin-'.length)
// FIXME: in Peertube <= 3.1.0, PeertubeHelpers dont provide this function
function getBaseRouter (): string {
return '/plugins/' + shortName + '/router/'
}
// FIXME: in Peertube <= 3.1.0, PeertubeHelpers dont provide this function
function getBaseStaticRoute (): string {
return '/plugins/' + shortName + '/' + version + '/static/'
}
export {
getBaseRouter,
getBaseStaticRoute
}