1
+ import { Obj } from '@storage/schemas'
1
2
import { HeadRenderer } from './head'
2
- import { FastifyRequest } from 'fastify'
3
+ import { FastifyRequest , FastifyReply } from 'fastify'
3
4
import { AssetResponse , RenderOptions } from './renderer'
4
- import { Obj } from '@storage/schemas'
5
- import { FastifyReply } from 'fastify/types/reply'
6
5
7
6
/**
8
7
* HeadRenderer
@@ -16,7 +15,18 @@ export class InfoRenderer extends HeadRenderer {
16
15
17
16
return {
18
17
...headAsset ,
19
- body : obj ,
18
+ body : {
19
+ id : obj . id ,
20
+ name : obj . name ,
21
+ version : obj . version ,
22
+ size : obj . metadata ?. size ?? null ,
23
+ content_type : obj . metadata ?. mimetype ?? null ,
24
+ cache_control : obj . metadata ?. cacheControl ?? null ,
25
+ etag : obj . metadata ?. eTag ?? null ,
26
+ metadata : obj . user_metadata ,
27
+ last_modified : obj . metadata ?. lastModified ?? null ,
28
+ created_at : obj . created_at ,
29
+ } ,
20
30
}
21
31
}
22
32
@@ -26,6 +36,12 @@ export class InfoRenderer extends HeadRenderer {
26
36
data : AssetResponse ,
27
37
options : RenderOptions
28
38
) {
29
- // no-op
39
+ response
40
+ . status ( data . metadata . httpStatusCode ?? 200 )
41
+ . header ( 'Content-Type' , 'application/json' )
42
+ . header ( 'ETag' , data . metadata . eTag )
43
+ . header ( 'Content-Length' , data . metadata . contentLength )
44
+ . header ( 'Last-Modified' , data . metadata . lastModified ?. toUTCString ( ) )
45
+ . header ( 'CacheControl' , data . metadata . cacheControl )
30
46
}
31
47
}
0 commit comments