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

supabase / storage / 30107678327

24 Jul 2026 04:01PM UTC coverage: 53.251% (-27.1%) from 80.35%
30107678327

Pull #1264

github

web-flow
Merge 69f9dd22b into e2912273d
Pull Request #1264: chore(deps): bump @fastify/multipart from 9.4.0 to 10.1.0

3708 of 7546 branches covered (49.14%)

Branch coverage included in aggregate %.

7095 of 12741 relevant lines covered (55.69%)

70.93 hits per line

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

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

10
const { storageS3Bucket, isMultitenant } = getConfig()
8✔
11

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

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

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

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

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

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

65
      const renderer = request.storage.renderer('image') as ImageRenderer
×
66

67
      if (isMultitenant) {
×
68
        const tenantConfig = await getTenantConfig(request.tenantId)
×
69
        renderer.setLimits({
×
70
          maxResolution: tenantConfig.features.imageTransformation.maxResolution,
71
        })
72
      }
73

74
      return renderer.setTransformations(request.query).render(request, response, {
×
75
        bucket: storageS3Bucket,
76
        key: s3Key,
77
        version: obj.version,
78
        download,
79
        xRobotsTag: obj.metadata?.['xRobotsTag'] as string | undefined,
80
        signal: request.signals.disconnect.signal,
81
      })
82
    }
83
  )
84
}
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