Skip to content

Commit 5175b2c

Browse files
committed
Add git info to backend API
1 parent f734772 commit 5175b2c

File tree

6 files changed

+27
-3
lines changed

6 files changed

+27
-3
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,5 @@ test-results
101101
/.nyc_output/
102102

103103
**/coverage
104+
105+
backend/api/metadata.json

backend/api/deploy-api.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ PROJECT="compass-130ba"
2525
SERVICE_NAME="api"
2626

2727
GIT_REVISION=$(git rev-parse --short HEAD)
28+
GIT_COMMIT_DATE=$(git log -1 --format=%ci)
29+
GIT_COMMIT_AUTHOR=$(git log -1 --format='%an')
30+
31+
cat > metadata.json << EOF
32+
{
33+
"git": {
34+
"revision": "${GIT_REVISION}",
35+
"commitDate": "${GIT_COMMIT_DATE}",
36+
"author": "${GIT_COMMIT_AUTHOR}"
37+
}
38+
}
39+
EOF
40+
2841
TIMESTAMP=$(date +"%s")
2942
IMAGE_TAG="${TIMESTAMP}-${GIT_REVISION}"
3043
IMAGE_URL="${REGION}-docker.pkg.dev/${PROJECT}/builds/${SERVICE_NAME}:${IMAGE_TAG}"

backend/api/metadata.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1-
{}
1+
{
2+
"git": {
3+
"revision": "f734772",
4+
"commitDate": "2025-12-04 20:18:25 +0100",
5+
"author": "MartinBraquet"
6+
}
7+
}

backend/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"debug": "nodemon -r tsconfig-paths/register --watch src -e ts --watch ../../common/src --watch ../shared/src --exec \"yarn build && node --inspect-brk src/serve.ts\"",
1616
"dist": "yarn dist:clean && yarn dist:copy",
1717
"dist:clean": "rm -rf dist && mkdir -p dist/common/lib dist/backend/shared/lib dist/backend/api/lib dist/backend/email/lib",
18-
"dist:copy": "rsync -a --delete ../../common/lib/ dist/common/lib && rsync -a --delete ../shared/lib/ dist/backend/shared/lib && rsync -a --delete ../email/lib/ dist/backend/email/lib && rsync -a --delete ./lib/* dist/backend/api/lib && cp ../../yarn.lock dist && cp package.json dist && cp package.json dist/backend/api",
18+
"dist:copy": "rsync -a --delete ../../common/lib/ dist/common/lib && rsync -a --delete ../shared/lib/ dist/backend/shared/lib && rsync -a --delete ../email/lib/ dist/backend/email/lib && rsync -a --delete ./lib/* dist/backend/api/lib && cp ../../yarn.lock dist && cp package.json dist && cp package.json dist/backend/api && cp metadata.json dist && cp metadata.json dist/backend/api",
1919
"watch": "tsc -w",
2020
"verify": "yarn --cwd=../.. verify",
2121
"verify:dir": "npx eslint . --max-warnings 0",

backend/api/src/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ import {createBookmarkedSearch} from './create-bookmarked-search'
6464
import {deleteBookmarkedSearch} from './delete-bookmarked-search'
6565
import {OpenAPIV3} from 'openapi-types';
6666
import {version as pkgVersion} from './../package.json'
67+
import {git} from './../metadata.json'
6768
import {z, ZodFirstPartyTypeKind, ZodTypeAny} from "zod";
6869
import {getUser} from "api/get-user";
6970
import {localSendTestEmail} from "api/test";
@@ -280,7 +281,7 @@ const swaggerDocument: OpenAPIV3.Document = {
280281
openapi: "3.0.0",
281282
info: {
282283
title: "Compass API",
283-
description: "Compass is a free, open-source platform to help people form deep, meaningful, and lasting connections — whether platonic, romantic, or collaborative. It’s made possible by contributions from the community, including code, ideas, feedback, and donations. Unlike typical apps, Compass prioritizes values, interests, and personality over swipes and ads, giving you full control over who you discover and how you connect.",
284+
description: `Compass is a free, open-source platform to help people form deep, meaningful, and lasting connections — whether platonic, romantic, or collaborative. It’s made possible by contributions from the community, including code, ideas, feedback, and donations. Unlike typical apps, Compass prioritizes values, interests, and personality over swipes and ads, giving you full control over who you discover and how you connect.\n Git: ${git.commitDate} (${git.revision}).`,
284285
version: pkgVersion,
285286
contact: {
286287
name: "Compass",

backend/api/src/health.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { APIHandler } from './helpers/endpoint'
2+
import {git} from './../metadata.json'
23

34
export const health: APIHandler<'health'> = async (_, auth) => {
45
return {
56
message: 'Server is working.',
67
uid: auth?.uid,
8+
git: git,
79
}
810
}

0 commit comments

Comments
 (0)