Skip to content
This repository was archived by the owner on Jan 7, 2026. It is now read-only.

Commit 772c10a

Browse files
committed
chore: npm run lint:fix
Signed-off-by: Miroslav Bajtoš <oss@bajtos.net>
1 parent 2fe783a commit 772c10a

22 files changed

+707
-651
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "npm"
4-
directory: "/"
3+
- package-ecosystem: 'npm'
4+
directory: '/'
55
versioning-strategy: increase
66
schedule:
7-
interval: "daily"
8-
time: "09:00"
9-
timezone: "Europe/Berlin"
7+
interval: 'daily'
8+
time: '09:00'
9+
timezone: 'Europe/Berlin'
1010
commit-message:
11-
prefix: "deps"
12-
prefix-development: "deps(dev)"
13-
- package-ecosystem: "github-actions"
14-
directory: "/"
11+
prefix: 'deps'
12+
prefix-development: 'deps(dev)'
13+
- package-ecosystem: 'github-actions'
14+
directory: '/'
1515
schedule:
16-
interval: "daily"
17-
time: "09:00"
18-
timezone: "Europe/Berlin"
16+
interval: 'daily'
17+
time: '09:00'
18+
timezone: 'Europe/Berlin'
1919
commit-message:
20-
prefix: "ci"
21-
- package-ecosystem: "docker"
20+
prefix: 'ci'
21+
- package-ecosystem: 'docker'
2222
directories:
23-
- "/"
23+
- '/'
2424
schedule:
25-
interval: "daily"
26-
time: "15:00"
27-
timezone: "Europe/Berlin"
25+
interval: 'daily'
26+
time: '15:00'
27+
timezone: 'Europe/Berlin'

.github/workflows/dependabot-auto-approve-always.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
id: metadata
1818
uses: dependabot/fetch-metadata@v2
1919
with:
20-
github-token: "${{ secrets.GITHUB_TOKEN }}"
20+
github-token: '${{ secrets.GITHUB_TOKEN }}'
2121
- name: Approve a PR
2222
if: ${{startsWith(steps.metadata.outputs.dependency-names, matrix.dependencyStartsWith)}}
2323
run: gh pr review --approve "$PR_URL"

.github/workflows/dependabot-auto-approve-minor.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ jobs:
2626
id: metadata
2727
uses: dependabot/fetch-metadata@v2
2828
with:
29-
github-token: "${{ secrets.GITHUB_TOKEN }}"
29+
github-token: '${{ secrets.GITHUB_TOKEN }}'
3030
- name: Approve a PR
31-
if: ${{startsWith(steps.metadata.outputs.dependency-names, matrix.dependencyStartsWith) && (steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor')}}
31+
if:
32+
${{startsWith(steps.metadata.outputs.dependency-names, matrix.dependencyStartsWith) &&
33+
(steps.metadata.outputs.update-type == 'version-update:semver-patch' ||
34+
steps.metadata.outputs.update-type == 'version-update:semver-minor')}}
3235
run: gh pr review --approve "$PR_URL"
3336
env:
3437
PR_URL: ${{github.event.pull_request.html_url}}

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,26 @@ A lightweight IPNI node mapping Filecoin PieceCID → payload block CID.
66

77
## Basic use
88

9-
Note: this will change soon, see
10-
https://github.com/filecoin-station/piece-indexer/issues/33
9+
Note: this will change soon, see https://github.com/filecoin-station/piece-indexer/issues/33
1110

1211
## `GET /sample/{provider-id}/{piece-cid}`
1312

14-
Sample a set of multihashes ingested by IPNI for a given ContextID, matching the
15-
route eventually to be exposed by an IPNI reverse index.
13+
Sample a set of multihashes ingested by IPNI for a given ContextID, matching the route eventually to
14+
be exposed by an IPNI reverse index.
1615

1716
_This is an alternative implementation of the IPNI Reverse Index as specified in
1817
[xedni/openapi.yaml](https://github.com/ipni/xedni/blob/526f90f5a6001cb50b52e6376f8877163f8018af/openapi.yaml)._
1918

2019
Parameters:
2120

2221
- `provider-id` - the peer ID of the storage provider (index publisher)
23-
- `piece-cid` - the Filecoin deal's PieceCID as advertised by the provider in
24-
Graphsync retrieval metadata
22+
- `piece-cid` - the Filecoin deal's PieceCID as advertised by the provider in Graphsync retrieval
23+
metadata
2524

2625
Response:
2726

28-
- `samples` - a list of exactly one payload block CID contained inside the piece
29-
identified by the requested PieceCID.
27+
- `samples` - a list of exactly one payload block CID contained inside the piece identified by the
28+
requested PieceCID.
3029

3130
Example:
3231

api/bin/server.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {
99
HOST = '127.0.0.1',
1010
DOMAIN: domain = 'localhost',
1111
REDIS_URL: redisUrl = 'redis://localhost:6379',
12-
REQUEST_LOGGING: requestLogging = 'true'
12+
REQUEST_LOGGING: requestLogging = 'true',
1313
} = process.env
1414

1515
const redisUrlParsed = new URL(redisUrl)
@@ -19,7 +19,7 @@ const redis = new Redis({
1919
username: redisUrlParsed.username,
2020
password: redisUrlParsed.password,
2121
lazyConnect: true, // call connect() explicitly so that we can exit on connection error
22-
family: 6 // required for upstash
22+
family: 6, // required for upstash
2323
})
2424

2525
await redis.connect()
@@ -29,8 +29,8 @@ const app = createApp({
2929
repository,
3030
domain,
3131
logger: {
32-
level: ['1', 'true'].includes(requestLogging) ? 'info' : 'error'
33-
}
32+
level: ['1', 'true'].includes(requestLogging) ? 'info' : 'error',
33+
},
3434
})
3535
console.log('Starting the http server on host %j port %s', HOST, PORT)
3636
const baseUrl = await app.listen({ host: HOST, port: Number(PORT) })

api/lib/app.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Fastify from 'fastify'
77
* @param {string|boolean} args.domain
88
* @param {Fastify.FastifyLoggerOptions} args.logger
99
*/
10-
export function createApp ({ repository, domain, logger }) {
10+
export function createApp({ repository, domain, logger }) {
1111
const app = Fastify({ logger })
1212
Sentry.setupFastifyErrorHandler(app)
1313

@@ -41,7 +41,7 @@ export function createApp ({ repository, domain, logger }) {
4141
if (!walkerState) {
4242
return reply.send({
4343
providerId,
44-
ingestionStatus: 'Unknown provider ID'
44+
ingestionStatus: 'Unknown provider ID',
4545
})
4646
}
4747

@@ -54,7 +54,7 @@ export function createApp ({ repository, domain, logger }) {
5454
lastHeadWalkedFrom: walkerState.lastHead ?? walkerState.head,
5555
adsMissingPieceCID: walkerState.adsMissingPieceCID ?? 0,
5656
entriesNotRetrievable: walkerState.entriesNotRetrievable ?? 0,
57-
piecesIndexed: await repository.countPiecesIndexed(providerId)
57+
piecesIndexed: await repository.countPiecesIndexed(providerId),
5858
})
5959
})
6060

api/lib/instrument.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,9 @@ const { SENTRY_ENVIRONMENT = 'development' } = process.env
77

88
const pkg = JSON.parse(
99
await fs.readFile(
10-
join(
11-
dirname(fileURLToPath(import.meta.url)),
12-
'..',
13-
'..',
14-
'package.json'
15-
),
16-
'utf8'
17-
)
10+
join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'package.json'),
11+
'utf8',
12+
),
1813
)
1914

2015
Sentry.init({
@@ -24,13 +19,13 @@ Sentry.init({
2419
tracesSampleRate: 0.1,
2520
// Ignore Fastify 4xx errors
2621
// Remove once https://github.com/getsentry/sentry-javascript/pull/13198 lands
27-
beforeSend (event, { originalException: err }) {
22+
beforeSend(event, { originalException: err }) {
2823
const isBadRequest =
2924
typeof err === 'object' &&
3025
err !== null &&
3126
'statusCode' in err &&
3227
typeof err.statusCode === 'number' &&
3328
err.statusCode < 500
3429
return isBadRequest ? null : event
35-
}
30+
},
3631
})

api/test/app.test.js

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ describe('HTTP request handler', () => {
2424
repository,
2525
domain: false,
2626
logger: {
27-
level: process.env.DEBUG === '*' || process.env.DEBUG?.includes('test')
28-
? 'debug'
29-
: 'error'
30-
}
27+
level: process.env.DEBUG === '*' || process.env.DEBUG?.includes('test') ? 'debug' : 'error',
28+
},
3129
})
3230
baseUrl = await app.listen()
3331
})
@@ -48,20 +46,35 @@ describe('HTTP request handler', () => {
4846

4947
describe('GET /samples/{providerId}/{pieceCid}', () => {
5048
it('returns the first payload block from the index', async () => {
51-
await repository.addPiecePayloadBlocks('provider-id', 'piece-cid', 'payload-cid-1', 'payload-cid-2')
52-
await repository.addPiecePayloadBlocks('provider-id2', 'piece-cid', 'payload-cid-1', 'payload-cid-2')
53-
await repository.addPiecePayloadBlocks('provider-id', 'piece-cid2', 'payload-cid-1', 'payload-cid-2')
49+
await repository.addPiecePayloadBlocks(
50+
'provider-id',
51+
'piece-cid',
52+
'payload-cid-1',
53+
'payload-cid-2',
54+
)
55+
await repository.addPiecePayloadBlocks(
56+
'provider-id2',
57+
'piece-cid',
58+
'payload-cid-1',
59+
'payload-cid-2',
60+
)
61+
await repository.addPiecePayloadBlocks(
62+
'provider-id',
63+
'piece-cid2',
64+
'payload-cid-1',
65+
'payload-cid-2',
66+
)
5467

5568
const res = await fetch(new URL('/sample/provider-id/piece-cid', baseUrl))
5669
await assertResponseStatus(res, 200)
5770
const body = await res.json()
5871

5972
assert.deepStrictEqual(body, {
60-
samples: ['payload-cid-1']
73+
samples: ['payload-cid-1'],
6174
})
6275
assert.strictEqual(
6376
res.headers.get('cache-control'),
64-
`public, max-age=${24 * 3600}, immutable`
77+
`public, max-age=${24 * 3600}, immutable`,
6578
)
6679
})
6780

@@ -73,12 +86,9 @@ describe('HTTP request handler', () => {
7386
const body = await res.json()
7487

7588
assert.deepStrictEqual(body, {
76-
error: 'PROVIDER_OR_PIECE_NOT_FOUND'
89+
error: 'PROVIDER_OR_PIECE_NOT_FOUND',
7790
})
78-
assert.strictEqual(
79-
res.headers.get('cache-control'),
80-
`public, max-age=${60}`
81-
)
91+
assert.strictEqual(res.headers.get('cache-control'), `public, max-age=${60}`)
8292
})
8393

8494
it('returns error when provider piece is not found', async () => {
@@ -89,12 +99,9 @@ describe('HTTP request handler', () => {
8999
const body = await res.json()
90100

91101
assert.deepStrictEqual(body, {
92-
error: 'PROVIDER_OR_PIECE_NOT_FOUND'
102+
error: 'PROVIDER_OR_PIECE_NOT_FOUND',
93103
})
94-
assert.strictEqual(
95-
res.headers.get('cache-control'),
96-
`public, max-age=${60}`
97-
)
104+
assert.strictEqual(res.headers.get('cache-control'), `public, max-age=${60}`)
98105
})
99106
})
100107

@@ -115,20 +122,17 @@ describe('HTTP request handler', () => {
115122
lastHeadWalkedFrom: 'last-head',
116123
adsMissingPieceCID: 0,
117124
entriesNotRetrievable: 0,
118-
piecesIndexed: 1
125+
piecesIndexed: 1,
119126
})
120127

121-
assert.strictEqual(
122-
res.headers.get('cache-control'),
123-
`public, max-age=${60}`
124-
)
128+
assert.strictEqual(res.headers.get('cache-control'), `public, max-age=${60}`)
125129
})
126130

127131
it('returns error for an unknown provider', async () => {
128132
await repository.setWalkerState('provider-id', {
129133
status: 'walking',
130134
tail: 'tail',
131-
lastHead: 'last-head'
135+
lastHead: 'last-head',
132136
})
133137
await repository.addPiecePayloadBlocks('provider-id', 'piece-cid', 'bafy1')
134138

@@ -138,13 +142,10 @@ describe('HTTP request handler', () => {
138142

139143
assert.deepStrictEqual(body, {
140144
providerId: 'unknown-provider-id',
141-
ingestionStatus: 'Unknown provider ID'
145+
ingestionStatus: 'Unknown provider ID',
142146
})
143147

144-
assert.strictEqual(
145-
res.headers.get('cache-control'),
146-
`public, max-age=${60}`
147-
)
148+
assert.strictEqual(res.headers.get('cache-control'), `public, max-age=${60}`)
148149
})
149150

150151
it('returns "head" as "lastHead" when the initial walk has not finished yet', async () => {
@@ -161,21 +162,18 @@ describe('HTTP request handler', () => {
161162
lastHeadWalkedFrom: 'head',
162163
adsMissingPieceCID: 0,
163164
entriesNotRetrievable: 0,
164-
piecesIndexed: 1
165+
piecesIndexed: 1,
165166
})
166167

167-
assert.strictEqual(
168-
res.headers.get('cache-control'),
169-
`public, max-age=${60}`
170-
)
168+
assert.strictEqual(res.headers.get('cache-control'), `public, max-age=${60}`)
171169
})
172170

173171
it('returns the number of adsMissingPieceCID and entriesNotRetrievable', async () => {
174172
await repository.setWalkerState('provider-id', {
175173
status: 'walking',
176174
head: 'head',
177175
entriesNotRetrievable: 10,
178-
adsMissingPieceCID: 20
176+
adsMissingPieceCID: 20,
179177
})
180178

181179
const res = await fetch(new URL('/ingestion-status/provider-id', baseUrl))
@@ -188,13 +186,10 @@ describe('HTTP request handler', () => {
188186
lastHeadWalkedFrom: 'head',
189187
entriesNotRetrievable: 10,
190188
adsMissingPieceCID: 20,
191-
piecesIndexed: 0
189+
piecesIndexed: 0,
192190
})
193191

194-
assert.strictEqual(
195-
res.headers.get('cache-control'),
196-
`public, max-age=${60}`
197-
)
192+
assert.strictEqual(res.headers.get('cache-control'), `public, max-age=${60}`)
198193
})
199194
})
200195
})

api/test/test-helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const assertResponseStatus = async (res, status) => {
55
throw new AssertionError({
66
actual: res.status,
77
expected: status,
8-
message: `Unexpected status code ${res.status} (expected ${status}). Response body: ${await res.text() || '(empty)'}`
8+
message: `Unexpected status code ${res.status} (expected ${status}). Response body: ${(await res.text()) || '(empty)'}`,
99
})
1010
}
1111
}

0 commit comments

Comments
 (0)