diff --git a/README.md b/README.md
index 728a8d7..66278a4 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,7 @@
| GET
`text/plain` | `/health` | Performs health checks and checks if the database is accessible |
| GET
`text/plain` | `/metrics` | [Prometheus](https://prometheus.io/) metrics |
| GET
`application/json` | `/openapi` | [OpenAPI](https://www.openapis.org/) specification |
+| GET
`application/json` | `/version` | API version and commit hash |
## Requirements
diff --git a/src/fetch/GET.ts b/src/fetch/GET.ts
index e6340c3..26dbc10 100644
--- a/src/fetch/GET.ts
+++ b/src/fetch/GET.ts
@@ -8,6 +8,8 @@ import { logger } from "../logger.js";
import swaggerHtml from "../../swagger/index.html"
import swaggerFavicon from "../../swagger/favicon.png"
import transfers from "./transfers.js";
+import { toJSON } from "./utils.js";
+import { APP_VERSION } from "../config.js";
export default async function (req: Request) {
const { pathname } = new URL(req.url);
@@ -21,6 +23,7 @@ export default async function (req: Request) {
if (pathname === "/health") return health(req);
if (pathname === "/metrics") return new Response(await registry.metrics(), { headers: { "Content-Type": registry.contentType } });
if (pathname === "/openapi") return new Response(openapi, { headers: { "Content-Type": "application/json" } });
+ if (pathname === "/version") return toJSON({ version: APP_VERSION.split('+')[0], commit: APP_VERSION.split('+')[1] });
// Token endpoints
if (pathname === "/supply") return supply(req);
diff --git a/src/fetch/openapi.ts b/src/fetch/openapi.ts
index abf9521..20f2e31 100644
--- a/src/fetch/openapi.ts
+++ b/src/fetch/openapi.ts
@@ -174,7 +174,14 @@ export default new OpenApiBuilder()
get: {
tags: [TAGS.DOCS],
summary: "OpenAPI JSON specification",
- responses: { 200: { description: "OpenAPI JSON specification", content: { "application/json": { schema: { type: "string" } } } } },
+ responses: { 200: { description: "OpenAPI JSON specification", content: { "application/json": {} } } },
+ },
+ })
+ .addPath("/version", {
+ get: {
+ tags: [TAGS.DOCS],
+ summary: "API version",
+ responses: { 200: { description: "API version and commit hash", content: { "application/json": {} } } },
},
})
.getSpecAsJson();
\ No newline at end of file