diff --git a/.gitignore b/.gitignore index 8323d66..eb51aa0 100644 --- a/.gitignore +++ b/.gitignore @@ -101,3 +101,5 @@ test-results /.nyc_output/ **/coverage + +backend/api/metadata.json diff --git a/backend/api/deploy-api.sh b/backend/api/deploy-api.sh index 140370f..abb376d 100755 --- a/backend/api/deploy-api.sh +++ b/backend/api/deploy-api.sh @@ -25,6 +25,19 @@ PROJECT="compass-130ba" SERVICE_NAME="api" GIT_REVISION=$(git rev-parse --short HEAD) +GIT_COMMIT_DATE=$(git log -1 --format=%ci) +GIT_COMMIT_AUTHOR=$(git log -1 --format='%an') + +cat > metadata.json << EOF +{ + "git": { + "revision": "${GIT_REVISION}", + "commitDate": "${GIT_COMMIT_DATE}", + "author": "${GIT_COMMIT_AUTHOR}" + } +} +EOF + TIMESTAMP=$(date +"%s") IMAGE_TAG="${TIMESTAMP}-${GIT_REVISION}" IMAGE_URL="${REGION}-docker.pkg.dev/${PROJECT}/builds/${SERVICE_NAME}:${IMAGE_TAG}" diff --git a/backend/api/metadata.json b/backend/api/metadata.json index 9e26dfe..00fdda4 100644 --- a/backend/api/metadata.json +++ b/backend/api/metadata.json @@ -1 +1,7 @@ -{} \ No newline at end of file +{ + "git": { + "revision": "f734772", + "commitDate": "2025-12-04 20:18:25 +0100", + "author": "MartinBraquet" + } +} diff --git a/backend/api/package.json b/backend/api/package.json index 4aeb263..1a28b21 100644 --- a/backend/api/package.json +++ b/backend/api/package.json @@ -15,7 +15,7 @@ "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\"", "dist": "yarn dist:clean && yarn dist:copy", "dist:clean": "rm -rf dist && mkdir -p dist/common/lib dist/backend/shared/lib dist/backend/api/lib dist/backend/email/lib", - "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", + "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", "watch": "tsc -w", "verify": "yarn --cwd=../.. verify", "verify:dir": "npx eslint . --max-warnings 0", diff --git a/backend/api/src/app.ts b/backend/api/src/app.ts index db9edfd..efb328e 100644 --- a/backend/api/src/app.ts +++ b/backend/api/src/app.ts @@ -64,6 +64,7 @@ import {createBookmarkedSearch} from './create-bookmarked-search' import {deleteBookmarkedSearch} from './delete-bookmarked-search' import {OpenAPIV3} from 'openapi-types'; import {version as pkgVersion} from './../package.json' +import {git} from './../metadata.json' import {z, ZodFirstPartyTypeKind, ZodTypeAny} from "zod"; import {getUser} from "api/get-user"; import {localSendTestEmail} from "api/test"; @@ -280,7 +281,7 @@ const swaggerDocument: OpenAPIV3.Document = { openapi: "3.0.0", info: { title: "Compass API", - 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.", + 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}).`, version: pkgVersion, contact: { name: "Compass", diff --git a/backend/api/src/health.ts b/backend/api/src/health.ts index 8b5d654..33e9886 100644 --- a/backend/api/src/health.ts +++ b/backend/api/src/health.ts @@ -1,8 +1,10 @@ import { APIHandler } from './helpers/endpoint' +import {git} from './../metadata.json' export const health: APIHandler<'health'> = async (_, auth) => { return { message: 'Server is working.', uid: auth?.uid, + git: git, } }