Skip to content

Commit

Permalink
fix: version should now be correctly set during runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Tethik committed Sep 29, 2023
1 parent cacc7e7 commit e1e9fe0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion api/src/controlApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { DataAccessLayer } from "@gram/core/dist/data/dal.js";
import { createHealthChecks } from "./healthchecks/index.js";
import { metricsMiddleware } from "./metrics/metrics.js";
import errorHandler from "./middlewares/errorHandler.js";
import { version } from "./util/version.js";

export function createControlApp(dal: DataAccessLayer) {
const app = express();
Expand All @@ -14,7 +15,7 @@ export function createControlApp(dal: DataAccessLayer) {
app.get("/service-metadata", (_req, res) => {
return res.json({
service_name: "gram",
service_version: `${process.env.npm_package_version}`,
service_version: `${version}`,
description: "Threat modeling",
owner: "Secure Development",
tags: ["threat-modeling", "appsec", "security"],
Expand Down
3 changes: 2 additions & 1 deletion api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import log4js from "log4js";
import { notificationSender } from "@gram/core/dist/notifications/sender.js";
import { attachWebsocketServer } from "./ws/index.js";
import { config } from "@gram/core/dist/config/index.js";
import { version } from "./util/version.js";

const NOTIFICATION_INTERVAL = 1000 * 30; // 30 seconds

Expand All @@ -24,7 +25,7 @@ process.on("unhandledRejection", handleUnhandledError);
process.on("uncaughtException", handleUnhandledError);

const listen = async () => {
log.info(`Starting gram@${process.env.npm_package_version}`);
log.info(`Starting gram@${version}`);
const dal = await bootstrap();

// Create Express Apps
Expand Down
3 changes: 2 additions & 1 deletion api/src/util/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Express } from "express";
import pkg from "log4js";
const { getLogger } = pkg;
import { config } from "@gram/core/dist/config/index.js";
import { version } from "./version.js";

const log = getLogger("sentry");

Expand Down Expand Up @@ -32,7 +33,7 @@ export function initSentry(app: Express) {
}

Sentry.init({
release: `gram@${process.env.npm_package_version}`,
release: `gram@${version}`,
environment: process.env["NODE_ENV"],
dsn: sentryDSN as string,
integrations: [
Expand Down
4 changes: 4 additions & 0 deletions api/src/util/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import fs from "fs";

const json = JSON.parse(fs.readFileSync("package.json", "utf8"));
export const version: string = json.version;

0 comments on commit e1e9fe0

Please sign in to comment.