-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: return git info in /extended/v1/status
* feat: add build script to write git info to usable ts file * fix: run git-info before tests * fix: fetch all git history for running tests * fix: try moving git-info run to workflow * fix: add some debug info to setup * fix: try using the module as a relative route * chore: remove test commands now that tests pass * chore: create status endpoint openapi schema and example * feat: create a plain text file instead * chore: undo github workflow changes since they are no longer necessary * fix: make import paths relative
- Loading branch information
Showing
9 changed files
with
82 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,3 +123,6 @@ openapitools.json | |
|
||
.env.local | ||
yarn.lock | ||
|
||
# Git info output | ||
.git-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"server_version": "stacks-blockchain-api v0.64.1 (master:439d4f46)", | ||
"status": "ready" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"description": "GET blockchain API status", | ||
"title": "ServerStatusResponse", | ||
"type": "object", | ||
"additionalProperties": false, | ||
"required": [ | ||
"status" | ||
], | ||
"properties": { | ||
"server_version": { | ||
"type": "string", | ||
"description": "the server version that is currently running" | ||
}, | ||
"status": { | ||
"type": "string", | ||
"description": "the current server status" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as express from 'express'; | ||
import * as fs from 'fs'; | ||
import { addAsync, RouterWithAsync } from '@awaitjs/express'; | ||
import { DataStore } from '../../datastore/common'; | ||
import { ServerStatusResponse } from '@stacks/stacks-blockchain-api-types'; | ||
import { logger } from '../../helpers'; | ||
|
||
export function createStatusRouter(_: DataStore): RouterWithAsync { | ||
const router = addAsync(express.Router()); | ||
|
||
router.get('/', (_, res) => { | ||
try { | ||
const [branch, commit, tag] = fs.readFileSync('.git-info', 'utf-8').split('\n'); | ||
const response: ServerStatusResponse = { | ||
server_version: `stacks-blockchain-api ${tag} (${branch}:${commit})`, | ||
status: 'ready', | ||
}; | ||
res.json(response); | ||
} catch (error) { | ||
logger.error(`Unable to read git info`, error); | ||
const response: ServerStatusResponse = { | ||
status: 'ready', | ||
}; | ||
res.json(response); | ||
} | ||
}); | ||
|
||
return router; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters