Skip to content

Commit 3de3225

Browse files
authored
format step (#114)
* format step * apply format
1 parent 3bf5aed commit 3de3225

26 files changed

Lines changed: 118 additions & 111 deletions

.github/workflows/static-checks.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ jobs:
3434
- name: Lint
3535
run: bun lint
3636

37+
format:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v4
41+
- uses: oven-sh/setup-bun@v1
42+
43+
- name: Bun Install
44+
run: |
45+
bun install --frozen-lockfile
46+
47+
- name: Format
48+
run: bun format --check
49+
3750
verify-open-api-doc:
3851
runs-on: ubuntu-latest
3952
steps:

src/core/RaidHubRouter.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ export class RaidHubRouter implements IRaidHubRoute {
4848
}
4949

5050
getFullPath(child: IRaidHubRoute): string {
51-
const path = this.routes.find(({ route }) =>
52-
normalizeRoute(route).includes(child)
53-
)?.path
51+
const path = this.routes.find(({ route }) => normalizeRoute(route).includes(child))?.path
5452
if (!path) throw new Error("Child not found")
5553

5654
return (this.parent ? this.parent.getFullPath(this) : "") + path

src/integrations/bungie/client.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const inFlightRequests = new Map<string, Promise<unknown>>()
1818
export const bungiePlatformHttp = (opts: { ttl: number }) => ({
1919
fetch: async <T>(config: BungieFetchConfig) => {
2020
const cacheKey = config.url.toString()
21-
21+
2222
// Check cache first
2323
if (inMemoryCache.has(cacheKey)) {
2424
return inMemoryCache.get(cacheKey)!.data as T
@@ -82,9 +82,12 @@ export const bungiePlatformHttp = (opts: { ttl: number }) => ({
8282
cause: body
8383
})
8484
} else {
85-
throw new Error(`Invalid response (${response.status}): ${response.statusText}`, {
86-
cause: body
87-
})
85+
throw new Error(
86+
`Invalid response (${response.status}): ${response.statusText}`,
87+
{
88+
cause: body
89+
}
90+
)
8891
}
8992
}
9093
})()

src/integrations/clickhouse/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Logger, LogFields } from "@/lib/utils/logging"
1+
import { LogFields, Logger } from "@/lib/utils/logging"
22
import {
33
ClickHouseLogLevel,
44
ErrorLogParams,

src/middleware/duration-metrics.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,32 @@ import { RequestHandler } from "express"
33
import { ParamsDictionary, Query } from "express-serve-static-core"
44
import { RaidHubLocals } from "./types"
55

6-
76
/**
87
* Factory function to create duration metrics middleware.
98
* Tracks request duration in Prometheus with path and status code labels.
10-
*
9+
*
1110
* @param path The route path pattern (e.g., "/player/:membershipId")
1211
*/
1312
export const durationMetrics = <
1413
P extends ParamsDictionary = ParamsDictionary,
1514
ResBody = unknown,
1615
ReqBody = unknown,
1716
ReqQuery extends Query = Query
18-
>(path: string): RequestHandler<P, ResBody, ReqBody, ReqQuery, RaidHubLocals> => {
17+
>(
18+
path: string
19+
): RequestHandler<P, ResBody, ReqBody, ReqQuery, RaidHubLocals> => {
1920
return (_, res, next) => {
2021
const start = Date.now()
2122
res.locals._startTime = start
22-
23+
2324
res.once("finish", () => {
2425
const responseTimeInMs = Date.now() - start
2526
res.locals._duration = responseTimeInMs
2627

2728
const code = res.statusCode.toString()
2829
httpRequestTimer.labels(path, code).observe(responseTimeInMs)
2930
})
30-
31+
3132
next()
3233
}
3334
}

src/middleware/region-metrics.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import {
2-
httpRequestCountByRegion
3-
} from "@/integrations/prometheus/metrics"
1+
import { httpRequestCountByRegion } from "@/integrations/prometheus/metrics"
42
import { RequestHandler } from "express"
5-
import { RaidHubLocals } from "./types"
63
import { ParamsDictionary, Query } from "express-serve-static-core"
4+
import { RaidHubLocals } from "./types"
75

86
/**
97
* Helper to extract a string header value, handling both string and array cases
@@ -23,7 +21,7 @@ function extractHeader(header: string | string[] | undefined): string {
2321
* - Country (CF-IPCountry) - ISO 3166-1 alpha-2 country code (always available)
2422
* - Continent (CF-IPContinent) - Continent code (requires "Add visitor location headers" Managed Transform)
2523
* - ASN (CF-IPASNum) - Autonomous System Number (always available)
26-
*
24+
*
2725
* Adds _region, _continent, and _asn properties to the locals.
2826
*/
2927
export const regionMetrics = <

src/middleware/request-logging.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const logger = new Logger("REQUEST_LOGGING")
99
* Middleware to log request completion with duration and related metadata.
1010
* Should be used alongside duration metrics middleware, which is responsible
1111
* for populating timing information (e.g. `_duration`) on `res.locals`.
12-
*
12+
*
1313
* This middleware logs the request duration and Cloudflare region/ASN/continent.
1414
*/
1515
export const requestLogging = <
@@ -20,7 +20,7 @@ export const requestLogging = <
2020
>(): RequestHandler<P, ResBody, ReqBody, ReqQuery, RaidHubLocals> => {
2121
return (req, res, next) => {
2222
res.once("finish", () => {
23-
const locals = (res.locals as RaidHubLocals)
23+
const locals = res.locals as RaidHubLocals
2424
logger.debug("REQUEST_COMPLETED", {
2525
path: req.path,
2626
url: req.ip,

src/middleware/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ export interface RaidHubLocals {
66
// populated by duration-metrics
77
_startTime: number
88
_duration: number
9-
}
9+
}

src/routes/admin/reporting/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { RaidHubRouter } from "@/core/RaidHubRouter"
22
import { blacklistInstanceRoute } from "./blacklist"
33
import { reportingStandingInstanceRoute } from "./instance-standing"
4-
import { getPlayerStanding } from "./player-standing"
54
import { patchPlayer } from "./player"
5+
import { getPlayerStanding } from "./player-standing"
66

77
export const reportingRouter = new RaidHubRouter({
88
routes: [

src/routes/admin/reporting/player-standing.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ import { ErrorCode } from "@/schema/errors/ErrorCode"
44
import { zBigIntString } from "@/schema/input"
55
import { zInt64 } from "@/schema/output"
66
import { getPlayer } from "@/services/player"
7-
import {
8-
getPlayerBlacklistedInstances,
9-
getPlayerRecentFlags
10-
} from "@/services/reporting/standing"
7+
import { getPlayerBlacklistedInstances, getPlayerRecentFlags } from "@/services/reporting/standing"
118
import { z } from "zod"
129

1310
export const getPlayerStanding = new RaidHubRoute({

0 commit comments

Comments
 (0)