Skip to content

Commit 7dfc5a9

Browse files
authored
fix: bugged re-org logic introduced in microblock implementation #670
1 parent f7c5e28 commit 7dfc5a9

12 files changed

+845
-439
lines changed

src/api/init.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Server, createServer } from 'http';
22
import { Socket } from 'net';
33
import * as express from 'express';
44
import * as expressWinston from 'express-winston';
5+
import * as winston from 'winston';
56
import { v4 as uuid } from 'uuid';
67
import * as cors from 'cors';
78
import { addAsync, ExpressWithAsync } from '@awaitjs/express';
@@ -50,19 +51,20 @@ export interface ApiServer {
5051
terminate: () => Promise<void>;
5152
}
5253

53-
export async function startApiServer({
54-
datastore,
55-
chainId,
56-
httpLogLevel,
57-
}: {
54+
export async function startApiServer(opts: {
5855
datastore: DataStore;
5956
chainId: ChainID;
57+
/** If not specified, this is read from the STACKS_BLOCKCHAIN_API_HOST env var. */
58+
serverHost?: string;
59+
/** If not specified, this is read from the STACKS_BLOCKCHAIN_API_PORT env var. */
60+
serverPort?: number;
6061
httpLogLevel?: LogLevel;
6162
}): Promise<ApiServer> {
62-
const app = addAsync(express());
63+
const { datastore, chainId, serverHost, serverPort, httpLogLevel } = opts;
6364

64-
const apiHost = process.env['STACKS_BLOCKCHAIN_API_HOST'];
65-
const apiPort = parseInt(process.env['STACKS_BLOCKCHAIN_API_PORT'] ?? '');
65+
const app = addAsync(express());
66+
const apiHost = serverHost ?? process.env['STACKS_BLOCKCHAIN_API_HOST'];
67+
const apiPort = serverPort ?? parseInt(process.env['STACKS_BLOCKCHAIN_API_PORT'] ?? '');
6668

6769
if (!apiHost) {
6870
throw new Error(
@@ -214,7 +216,7 @@ export async function startApiServer({
214216

215217
app.use(
216218
expressWinston.errorLogger({
217-
winstonInstance: logger,
219+
winstonInstance: logger as winston.Logger,
218220
metaField: (null as unknown) as string,
219221
blacklistedMetaFields: ['trace', 'os', 'process'],
220222
})

0 commit comments

Comments
 (0)