Comments (1)
This may be a decent enough starting point:
"use strict";
const fs = require("fs");
const path = require("path");
const router = require("express").Router();
let commmit;
try {
commit = require("git-rev-sync").short();
} catch (err) {
// ignore
}
const { version, homepage } = require("../package.json");
const versionJsonPath = path.join(__dirname, "..", "public", "version.json");
const versionJson = {
commit,
source: homepage,
version,
};
fs.writeFileSync(versionJsonPath, JSON.stringify(versionJson, null, 2) + "\n");
router.get("/__version__", (req, res) => {
return res.sendFile(versionJsonPath);
});
router.get("/__heartbeat__", (req, res) => {
return res.send("OK");
});
router.get("/__lbheartbeat__", (req, res) => {
return res.send("OK");
});
module.exports = router;
This should create a ./public/version.json file which gets generated at startup and then visiting /__version__
will just return that static file. By wrapping it in a try..catch
, I think it should also work if the target stage/production server doesn't have Git installed but OPs or somebody manually creates a ./public/version.json file during their build process.
We'd also need to do npm i git-rev-sync -D and add ./public/version.json to the .gitignore.
Or, I'm way off and this is just stupid. 🤷♀️
from blurts-server.
Related Issues (20)
- Add lint:ts to lint targets in package.json (in nextjs branch)? HOT 1
- Add eslint-plugin-import plugin? HOT 1
- Update Coverage Badge in README HOT 2
- The title does not fit to the body in the result page HOT 1
- Localization issues in premium.ftl HOT 4
- Caz
- Update channels to match with nimbus ids HOT 1
- Poor JPEG images received at monitor.firefox.com when visitng with WebP accept header stripped HOT 2
- src/db/tables/featureFlags.ts uses `modified_at` whereas other tables use `updated_at`
- Non localizable string and placeholder issues in dashboard HOT 4
- Text overlap in landing page image (long localized category name)
- Style issue with hero image on new Mozilla Monitor home page (with long word; i18n)
- Gd
- Ganz
- Zcsng
- Ok
- Alternative solution for OneRep API key HOT 1
- Hudson Rock Cybercrime Intelligence Free Integration
- Add a CI job for validating Nimbus FML
- Bohari 0pur
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from blurts-server.