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

supabase / storage / 24368240723

13 Apr 2026 09:38PM UTC coverage: 81.027% (+0.04%) from 80.986%
24368240723

Pull #1017

github

web-flow
Merge 0ee93c4c0 into a49ab6a7b
Pull Request #1017: feat: add tenant config per request hit ratio

3284 of 4261 branches covered (77.07%)

Branch coverage included in aggregate %.

133 of 156 new or added lines in 30 files covered. (85.26%)

1 existing line in 1 file now uncovered.

30774 of 37772 relevant lines covered (81.47%)

318.68 hits per line

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

93.02
/src/http/routes/render/renderAuthenticatedImage.ts
1
import { getTenantConfig } from '@internal/database'
1✔
2
import { ImageRenderer } from '@storage/renderer'
1✔
3
import { FastifyInstance } from 'fastify'
1✔
4
import { FromSchema } from 'json-schema-to-ts'
1✔
5
import { getConfig } from '../../../config'
1✔
6
import { transformationOptionsSchema } from '../../schemas/transformations'
1✔
7
import { ROUTE_OPERATIONS } from '../operations'
1✔
8

1✔
9
const { storageS3Bucket, isMultitenant } = getConfig()
1✔
10

1✔
11
const renderAuthenticatedImageParamsSchema = {
1✔
12
  type: 'object',
1✔
13
  properties: {
1✔
14
    bucketName: { type: 'string', examples: ['avatars'] },
1✔
15
    '*': { type: 'string', examples: ['folder/cat.png'] },
1✔
16
  },
1✔
17
  required: ['bucketName', '*'],
1✔
18
} as const
1✔
19

1✔
20
const renderImageQuerySchema = {
1✔
21
  type: 'object',
1✔
22
  properties: {
1✔
23
    ...transformationOptionsSchema,
1✔
24
    download: { type: 'string', examples: ['filename.png'] },
1✔
25
  },
1✔
26
} as const
1✔
27

1✔
28
interface renderImageRequestInterface {
1✔
29
  Params: FromSchema<typeof renderAuthenticatedImageParamsSchema>
1✔
30
  Querystring: FromSchema<typeof renderImageQuerySchema>
1✔
31
}
1✔
32

1✔
33
export default async function routes(fastify: FastifyInstance) {
1✔
34
  const summary = 'Render an authenticated image with the given transformations'
257✔
35
  fastify.get<renderImageRequestInterface>(
257✔
36
    '/authenticated/:bucketName/*',
257✔
37
    {
257✔
38
      schema: {
257✔
39
        params: renderAuthenticatedImageParamsSchema,
257✔
40
        querystring: renderImageQuerySchema,
257✔
41
        summary,
257✔
42
        response: { '4xx': { $ref: 'errorSchema#', description: 'Error response' } },
257✔
43
        tags: ['transformation'],
257✔
44
      },
257✔
45
      config: {
257✔
46
        operation: { type: ROUTE_OPERATIONS.RENDER_AUTH_IMAGE },
257✔
47
      },
257✔
48
    },
257✔
49
    async (request, response) => {
257✔
50
      const { download } = request.query
1✔
51
      const { bucketName } = request.params
1✔
52
      const objectName = request.params['*']
1✔
53

1✔
54
      const obj = await request.storage
1✔
55
        .from(bucketName)
1✔
56
        .findObject(objectName, 'id,version,metadata')
1✔
57

1✔
58
      const s3Key = request.storage.location.getKeyLocation({
1✔
59
        tenantId: request.tenantId,
1✔
60
        bucketId: bucketName,
1✔
61
        objectName,
1✔
62
      })
1✔
63

1✔
64
      const renderer = request.storage.renderer('image') as ImageRenderer
1✔
65

1✔
66
      if (isMultitenant) {
1!
NEW
67
        const tenantConfig = await getTenantConfig(request.tenantId, { reqId: request.id })
×
68
        renderer.setLimits({
×
69
          maxResolution: tenantConfig.features.imageTransformation.maxResolution,
×
70
        })
×
71
      }
×
72

1✔
73
      return renderer.setTransformations(request.query).render(request, response, {
1✔
74
        bucket: storageS3Bucket,
1✔
75
        key: s3Key,
1✔
76
        version: obj.version,
1✔
77
        download,
1✔
78
        xRobotsTag: obj.metadata?.['xRobotsTag'] as string | undefined,
1✔
79
        signal: request.signals.disconnect.signal,
1✔
80
      })
1✔
81
    }
1✔
82
  )
257✔
83
}
257✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc