diff --git a/backend/app.ts b/backend/app.ts index e30b3c7..a7e14cc 100644 --- a/backend/app.ts +++ b/backend/app.ts @@ -9,6 +9,13 @@ import { UserConfig } from './UserConfig'; import { ServerConfiguration } from 'ass'; import { MySql } from './sql/mysql'; +/** + * Top-level metadata exports + */ +export const App = { + pkgVersion: '' +} + /** * Custom middleware to attach the ass object (and construct the `host` property) */ @@ -29,6 +36,8 @@ async function main() { const pkg = await fs.readJson(path.join('package.json')) as { name: string, version: string }; log.blank().info(pkg.name, pkg.version).blank(); + App.pkgVersion = pkg.version; + // Ensure data files exist await ensureFiles(); diff --git a/backend/routers/index.ts b/backend/routers/index.ts index 123591f..e3bbf2b 100644 --- a/backend/routers/index.ts +++ b/backend/routers/index.ts @@ -9,6 +9,7 @@ import { BusBoyFile, AssFile } from 'ass'; import { getFileS3, uploadFileS3 } from '../s3'; import { Readable } from 'stream'; import * as data from '../data'; +import { App } from '../app'; const router = Router({ caseSensitive: true }); @@ -23,7 +24,7 @@ bb.extend(router, { }); // Render or redirect -router.get('/', (req, res) => UserConfig.ready ? res.render('index') : res.redirect('/setup')); +router.get('/', (req, res) => UserConfig.ready ? res.render('index', { version: App.pkgVersion }) : res.redirect('/setup')); // Upload flow router.post('/', async (req, res) => { diff --git a/backend/routers/setup.ts b/backend/routers/setup.ts index 8d5df9e..e84c70b 100644 --- a/backend/routers/setup.ts +++ b/backend/routers/setup.ts @@ -4,11 +4,12 @@ import { log } from '../log'; import { UserConfig } from '../UserConfig'; import { setDataModeToSql } from '../data'; import { MySql } from '../sql/mysql'; +import { App } from '../app'; const router = Router({ caseSensitive: true }); // Static routes -router.get('/', (req, res) => UserConfig.ready ? res.redirect('/') : res.render('setup')); +router.get('/', (req, res) => UserConfig.ready ? res.redirect('/') : res.render('setup', { version: App.pkgVersion })); router.get('/ui.js', (req, res) => UserConfig.ready ? res.send('') : res.type('text/javascript').sendFile(path.join('dist-frontend/setup.mjs'))); // Setup route diff --git a/views2/index.pug b/views2/index.pug index 61ee97f..5ee6f75 100644 --- a/views2/index.pug +++ b/views2/index.pug @@ -2,4 +2,4 @@ extends _base_ block section span ass block content - h1.text-3xl Welcome to ass, a ShareX server. + h1.text-3xl Welcome to ass #{version}, a ShareX server.