Files
proxy/nodejs/routes/render.js
T
wmantly 9d34ff96e2 Add a footer, move GitHub link out of the nav (#130)
proxy had no page footer at all — no copyright, no license link, no
build/version info — unlike sso-manager-node, which already had one
(now cleaned up in a matching change there). Bring the two in line:

- Added a footer to bottom.ejs: theta42 logo/link, "© <year> theta42"
  with an MIT License link, a GitHub link, and build version/hash.
- Moved the GitHub icon link out of the top nav (where it competed
  with actual navigation items) and into the new footer.
- Added nodejs/utils/build_info.js (buildVersion/buildHash/buildYear,
  read once from package.json + git) and wired it into routes/render.js
  so every page has the values the footer needs. Mirrors the same
  helper added to sso-manager-node in the matching cleanup there.
- Copied the theta42.svg logo into nodejs/public/img/ (previously only
  present in sso-manager-node) so both apps' footers render identically.

Verified by rendering top+bottom with the real ejs package: no
template errors, GitHub link present exactly once (in the footer, not
the nav), logo and MIT License link present. npm test: 192/192 pass
(unaffected — view-only + a new leaf utility module).
2026-07-14 20:55:11 -04:00

82 lines
2.4 KiB
JavaScript

'use strict';
const path = require('path');
const express = require('express');
const router = require('express').Router();
const conf = require('@simpleworkjs/conf');
const buildInfo = require('../utils/build_info');
const values ={
title: conf.environment !== 'production' ? `dev` : '',
titleIcon: conf.environment !== 'production' ? `<i class="fa-brands fa-dev"></i>` : '',
...buildInfo,
}
// List of front end node modules to be served
const frontEndModules = ['bootstrap', 'mustache', 'jquery', '@fortawesome',
'moment', '@popper', 'jq-repeat',
];
// Server front end modules
// https://stackoverflow.com/a/55700773/3140931
frontEndModules.forEach(dep => {
router.use(`/static-modules/${dep}`, express.static(path.join(__dirname, `../node_modules/${dep}`)))
});
// Have express server static content( images, CSS, browser JS) from the public
// local folder.
router.use('/static', express.static(path.join(__dirname, '../public')))
router.get('/', (req, res) => {
res.redirect(301, '/hosts');
});
// Lightweight liveness probe for container healthchecks / monitoring. No auth,
// no dependencies — just confirms the Express process is up and routing.
router.get('/health', (req, res) => {
res.json({status: 'ok'});
});
router.get('/hosts', async function(req, res, next) {
res.render('hosts', {...values});
});
router.get('/dns', async function(req, res, next) {
res.render('dns', {...values});
});
router.get('/users', async function(req, res, next) {
res.render('users', {...values});
});
router.get('/permissions', async function(req, res, next) {
res.render('permissions', {...values});
});
router.get('/groups', async function(req, res, next) {
res.render('groups', {...values});
});
router.get('/profile', async function(req, res, next) {
res.render('profile', {...values});
});
router.get('/api-tokens', async function(req, res, next) {
res.render('api_tokens', {...values});
});
// Bare /login (the OIDC callback redirect target) and /login/<path>.
router.get('/login', async function(req, res, next) {
res.render('login', {...values, redirect: req.query.redirect});
});
router.get('/login/*splat', async function(req, res, next) {
res.render('login', {...values, redirect: req.query.redirect});
});
router.get('/test', async function(req, res, next) {
res.render('test', {...values, redirect: req.query.redirect});
});
module.exports = router;