• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / storage / 29003813455

09 Jul 2026 08:09AM UTC coverage: 79.236% (+0.008%) from 79.228%
29003813455

Pull #1217

github

web-flow
Merge b21ea8fc3 into 34a4d397b
Pull Request #1217: fix: cache fast path and less allocations for outcome

5319 of 7277 branches covered (73.09%)

Branch coverage included in aggregate %.

8 of 11 new or added lines in 3 files covered. (72.73%)

3822 existing lines in 164 files now uncovered.

10403 of 12565 relevant lines covered (82.79%)

422.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/http/plugins/storage.ts
1
import { createStorageBackend, StorageBackendAdapter } from '@storage/backend'
2
import type { Database } from '@storage/database'
3
import { StoragePgDB } from '@storage/database'
4
import { PassThroughLocation, TenantLocation } from '@storage/locator'
5
import { Storage } from '@storage/storage'
6
import fastifyPlugin from 'fastify-plugin'
7
import { getConfig } from '../../config'
8

9
declare module 'fastify' {
10
  interface FastifyRequest {
11
    storage: Storage
12
    backend: StorageBackendAdapter
13
  }
14
}
15

16
const { storageBackendType, storageS3Bucket } = getConfig()
31✔
17

18
const storageBackend = createStorageBackend(storageBackendType)
31✔
19

20
// TenantLocation is immutable so singleton not to allocate per request.
21
const tenantLocation = new TenantLocation(storageS3Bucket)
31✔
22

23
export const storage = fastifyPlugin(
31✔
24
  async function storagePlugin(fastify) {
25
    fastify.decorateRequest('storage')
6,011✔
26
    fastify.addHook('preHandler', async (request) => {
6,011✔
UNCOV
27
      const databaseOptions = {
1,085✔
28
        tenantId: request.tenantId,
29
        host: request.headers['x-forwarded-host'] as string,
30
        reqId: request.id,
31
        sbReqId: request.sbReqId,
32
        latestMigration: request.latestMigration,
33
      }
34

UNCOV
35
      const database: Database = new StoragePgDB(request.db, databaseOptions)
1,085✔
36

UNCOV
37
      const location = request.isIcebergBucket
1,085✔
38
        ? new PassThroughLocation(request.internalIcebergBucketName!)
39
        : tenantLocation
40

UNCOV
41
      request.backend = storageBackend
1,085✔
UNCOV
42
      request.storage = new Storage(storageBackend, database, location)
1,085✔
43
    })
44

45
    fastify.addHook('onClose', async () => {
6,011✔
46
      storageBackend.close()
6,011✔
47
    })
48
  },
49
  { name: 'storage-init' }
50
)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc