improve /version api route to only call git once on startup
This commit is contained in:
parent
45a4935190
commit
a79a1eab81
@ -67,6 +67,10 @@ Sentry.init({
|
|||||||
environment: config.global.debug ? 'development' : 'production'
|
environment: config.global.debug ? 'development' : 'production'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.locals.versionRev = require('child_process')
|
||||||
|
.execSync('git rev-parse --short HEAD')
|
||||||
|
.toString().trim()
|
||||||
|
|
||||||
// RequestHandler creates a separate execution context using domains, so that every
|
// RequestHandler creates a separate execution context using domains, so that every
|
||||||
// transaction/span/breadcrumb is attached to its own Hub instance
|
// transaction/span/breadcrumb is attached to its own Hub instance
|
||||||
app.use(Sentry.Handlers.requestHandler());
|
app.use(Sentry.Handlers.requestHandler());
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import express, { Request, Response } from 'express';
|
import express, { Request, Response } from 'express';
|
||||||
|
|
||||||
function get(req: Request, res: Response) {
|
function get(req: Request, res: Response) {
|
||||||
const revision = require('child_process')
|
const revision = req.app.locals.versionRev;
|
||||||
.execSync('git rev-parse --short HEAD')
|
|
||||||
.toString().trim()
|
|
||||||
res.status(200).send({ version: '1.0.0', commit: revision });
|
res.status(200).send({ version: '1.0.0', commit: revision });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user