Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(blob): move HEAD /[path] to GET /head/[path] #48

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading