Feat: Add git commit info badge

This commit is contained in:
2025-12-27 17:44:39 +11:00
parent 8dcbacf0ed
commit d6cf8f6603
4 changed files with 458 additions and 276 deletions

View File

@@ -3,10 +3,25 @@ const nodemailer = require("nodemailer");
const bodyParser = require("body-parser");
const cors = require("cors");
const path = require("path");
const { execSync } = require("child_process");
const app = express();
const port = process.env.PORT || 3000;
// Get Git Commit Info
let gitInfo = {
hash: 'Unknown',
date: 'Unknown'
};
try {
const hash = execSync('git log -1 --format="%h"').toString().trim();
const date = execSync('git log -1 --format="%cd"').toString().trim();
gitInfo = { hash, date };
} catch (e) {
console.warn("Could not retrieve git info:", e.message);
}
app.use(cors());
app.use(bodyParser.json());
@@ -18,6 +33,11 @@ app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
// API Endpoint for Version Info
app.get('/api/version', (req, res) => {
res.json(gitInfo);
});
app.post('/api/test-smtp', async (req, res) => {
const { host, port, secure, user, pass, from, to } = req.body;