nuxt-hub / core

Build full-stack applications with Nuxt on CloudFlare, with zero configuration.
https://hub.nuxt.com
Apache License 2.0
802 stars 35 forks source link

Export blob types #141

Open Barbapapazes opened 3 weeks ago

Barbapapazes commented 3 weeks ago

Hello 👋,

Do you thing that the blob types, https://github.com/nuxt-hub/core/blob/main/src/runtime/server/utils/blob.ts#L734-L739, could be exported? This could be helpful.

I'm validating a file on the frontend using zod and then on the backend using ensureBlob and I want common size and format so I use variables. My issue is that I'm not able to correctly type theses variables for the ensureBlob because I do no have access to these types.

Atinux commented 3 weeks ago

Sounds good to me to export some of them yes, happy to open a PR?

Barbapapazes commented 3 weeks ago

Hey,

I'm not sure how to solve this. When I take a look at other packages like nuxt/content or nuxt/fonts, they handle exported types differently. How should I proceed? Is there any recommended way?

Atinux commented 3 weeks ago

Would love to get your expertise on this @farnabaz

farnabaz commented 2 weeks ago

So far I think the best way to expose types in modules is to create a types/index.ts file inside src directory and export it via module.ts. This way, users can import types easily via module package

import { type Foo } from `package`

As for nuxt/content, we discussed it and in next version types will be exposed from main package too.

Update: Seems that nuxt/image also do the same thing https://github.com/nuxt/image/blob/e7242fbc2bb37d484f1c903e8a28532973b11ddb/src/module.ts#L24

Update2: We can implement this in/after https://github.com/nuxt-hub/core/pull/138

Barbapapazes commented 2 weeks ago

If you think you can do it in #130, let's go! Otherwise, I'll wait and make a PR using your advices!