mirror of
https://github.com/DeNNiiInc/Advanced-Smtp-Tester.git
synced 2026-04-28 21:55:59 +00:00
Feat: Add git commit info badge
This commit is contained in:
20
server.js
20
server.js
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user