Skip to content

Commit

Permalink
fix: show status endpoint in /extended (#1869)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr authored Feb 19, 2024
1 parent e71b111 commit cf47f8f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,7 @@ paths:
example:
$ref: ./api/core-node/get-info.example.json

/extended/v1/status:
/extended:
get:
summary: API status
description: Retrieves the running status of the Stacks Blockchain API, including the server version and current chain tip information.
Expand Down
7 changes: 5 additions & 2 deletions src/api/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export async function startApiServer(opts: {
app.set('etag', false);

app.get('/', (req, res) => {
res.redirect(`/extended/v1/status`);
res.redirect(`/extended/`);
});

app.use('/doc', (req, res) => {
Expand Down Expand Up @@ -189,6 +189,7 @@ export async function startApiServer(opts: {
res.set('Cache-Control', 'no-store');
next();
});
router.use('/', createStatusRouter(datastore));
router.use(
'/v1',
(() => {
Expand All @@ -203,7 +204,9 @@ export async function startApiServer(opts: {
v1.use('/info', createInfoRouter(datastore));
v1.use('/stx_supply', createStxSupplyRouter(datastore));
v1.use('/debug', createDebugRouter(datastore));
v1.use('/status', createStatusRouter(datastore));
v1.use('/status', (req, res) =>
res.redirect(`${req.baseUrl.replace(/v1\/status/, '')}${getReqQuery(req)}`)
);
v1.use('/fee_rate', createFeeRateRouter(datastore));
v1.use('/tokens', createTokenRouter(datastore));

Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async function init(): Promise<void> {
if (isProdEnv && !fs.existsSync('.git-info')) {
throw new Error(
'File not found: .git-info. This generated file is required to display the running API version in the ' +
'`/extended/v1/status` endpoint. Please execute `npm run build` to regenerate it.'
'`/extended/` endpoint. Please execute `npm run build` to regenerate it.'
);
}
chainIdConfigurationCheck();
Expand Down
2 changes: 1 addition & 1 deletion src/tests/other-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ describe('other tests', () => {
});

test('active status', async () => {
const result = await supertest(api.server).get(`/extended/v1/status/`);
const result = await supertest(api.server).get(`/extended/`);
expect(result.body.status).toBe('ready');
});

Expand Down

0 comments on commit cf47f8f

Please sign in to comment.