Skip to content

Commit

Permalink
fix(blob): move HEAD /[path] to GET /head/[path] (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
smarroufin authored Apr 5, 2024
1 parent d4ac425 commit 215a79f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
15 changes: 0 additions & 15 deletions src/runtime/server/api/_hub/blob/[...pathname].head.ts

This file was deleted.

11 changes: 11 additions & 0 deletions src/runtime/server/api/_hub/blob/head/[...pathname].get.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { eventHandler, getValidatedRouterParams } from 'h3'
import { z } from 'zod'
import { hubBlob } from '../../../../utils/blob'

export default eventHandler(async (event) => {
const { pathname } = await getValidatedRouterParams(event, z.object({
pathname: z.string().min(1)
}).parse)

return hubBlob().head(pathname)
})
5 changes: 2 additions & 3 deletions src/runtime/server/utils/blob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,9 @@ export function proxyHubBlob(projectUrl: string, secretKey?: string) {
})
},
async head(pathname: string) {
const { headers } = await blobAPI.raw<void>(decodeURI(pathname), {
method: 'HEAD'
return await blobAPI<void>(`/head/${decodeURI(pathname)}`, {
method: 'GET'
})
return JSON.parse(headers.get('x-blob') || '{}') as BlobObject
},
async del(pathnames: string | string[]) {
if (Array.isArray(pathnames)) {
Expand Down

0 comments on commit 215a79f

Please sign in to comment.