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

supabase / storage / 30379780849

28 Jul 2026 04:45PM UTC coverage: 53.191% (-27.1%) from 80.307%
30379780849

Pull #1269

github

web-flow
Merge 2846843fa into 20927735c
Pull Request #1269: fix: update pool reliably upon config changes

3671 of 7490 branches covered (49.01%)

Branch coverage included in aggregate %.

42 of 47 new or added lines in 4 files covered. (89.36%)

3545 existing lines in 156 files now uncovered.

7065 of 12694 relevant lines covered (55.66%)

71.05 hits per line

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

25.0
/src/http/routes/render/renderSignedImage.ts
1
import { SIGNED_URL_SCOPE_DOWNLOAD } from '@internal/auth'
2
import { getTenantConfig } from '@internal/database'
3
import { ImageRenderer } from '@storage/renderer'
4
import { FastifyInstance } from 'fastify'
5
import { FromSchema } from 'json-schema-to-ts'
6
import { getConfig } from '../../../config'
7
import { sharedErrorResponseSchemas } from '../../schemas/error'
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
    token: {
25
      type: 'string',
26
      examples: [
27
        'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1cmwiOiJidWNrZXQyL3B1YmxpYy9zYWRjYXQtdXBsb2FkMjMucG5nIiwiaWF0IjoxNjE3NzI2MjczLCJleHAiOjE2MTc3MjcyNzN9.uBQcXzuvXxfw-9WgzWMBfE_nR3VOgpvfZe032sfLSSk',
28
      ],
29
    },
30
    download: { type: 'string', examples: ['filename.png'] },
31
  },
32
  required: ['token'],
33
} as const
34

35
interface renderImageRequestInterface {
36
  Params: FromSchema<typeof renderAuthenticatedImageParamsSchema>
37
  Querystring: FromSchema<typeof renderImageQuerySchema>
38
}
39

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

UNCOV
60
      const { url, transformations, exp } = await request.storage
×
61
        .from(request.params.bucketName)
62
        .verifyObjectSignature(token, request.params['*'], SIGNED_URL_SCOPE_DOWNLOAD)
63

UNCOV
64
      const s3Key = `${request.tenantId}/${url}`
×
65

UNCOV
66
      const [bucketName, ...objParts] = url.split('/')
×
UNCOV
67
      const obj = await request.storage
×
68
        .asSuperUser()
69
        .from(bucketName)
70
        .findObject(objParts.join('/'), 'id,version,metadata')
71

UNCOV
72
      const renderer = request.storage.renderer('image') as ImageRenderer
×
73

UNCOV
74
      if (isMultitenant) {
×
75
        const tenantConfig = await getTenantConfig(request.tenantId)
×
76
        renderer.setLimits({
×
77
          maxResolution: tenantConfig.features.imageTransformation.maxResolution,
78
        })
79
      }
80

UNCOV
81
      return renderer
×
82
        .setTransformationsFromString(transformations || '')
×
83
        .render(request, response, {
84
          bucket: storageS3Bucket,
85
          key: s3Key,
86
          version: obj.version,
87
          download,
88
          expires: new Date(exp * 1000).toUTCString(),
89
          xRobotsTag: obj.metadata?.['xRobotsTag'] as string | undefined,
90
          signal: request.signals.disconnect.signal,
91
        })
92
    }
93
  )
94
}
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