diff --git a/api/src/routes/api/index.js b/api/src/routes/api/index.js index 1e52232..b239a77 100644 --- a/api/src/routes/api/index.js +++ b/api/src/routes/api/index.js @@ -6,6 +6,7 @@ router.use('/tracks', require('./tracks')); router.use('/tags', require('./tags')); router.use('/accounts', require('../../accounts/accounts.controller')); router.use('/stats', require('./stats')); +router.use('/info', require('./info')); router.use(function (err, req, res, next) { if (err.name === 'ValidationError') { diff --git a/api/src/routes/api/info.js b/api/src/routes/api/info.js new file mode 100644 index 0000000..a3e9a1c --- /dev/null +++ b/api/src/routes/api/info.js @@ -0,0 +1,11 @@ +const router = require('express').Router(); + +const { version } = require('../../../package.json'); + +router.route('/').get((req, res) => { + res.json({ + version, + }); +}); + +module.exports = router; diff --git a/frontend/src/App.js b/frontend/src/App.js index e731f28..9181c63 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -2,6 +2,9 @@ import React from 'react' import {connect} from 'react-redux' import {List, Grid, Container, Menu, Header, Dropdown} from 'semantic-ui-react' import {BrowserRouter as Router, Switch, Route, Link} from 'react-router-dom' +import {useObservable} from 'rxjs-hooks' +import {from} from 'rxjs' +import {pluck} from 'rxjs/operators' import config from 'config.json' import styles from './App.module.scss' @@ -18,6 +21,11 @@ import { UploadPage, } from 'pages' import {Avatar, LoginButton} from 'components' +import api from 'api' + +import packageJson from '../package.json' + +const {version} = packageJson // This component removes the "navigate" prop before rendering a Menu.Item, // which is a workaround for an annoying warning that is somehow caused by the @@ -27,6 +35,8 @@ function MenuItemForLink({navigate, ...props}) { } const App = connect((state) => ({login: state.login}))(function App({login}) { + const apiVersion = useObservable(() => from(api.get('/info')).pipe(pluck('version'))) + return ( @@ -147,7 +157,21 @@ const App = connect((state) => ({login: state.login}))(function App({login}) { - + +
Info
+ + + + Frontend v{version} + + + + + API v{apiVersion ?? '...'} + + + +