Skip to content

Some Feedbacks #103

@Julien-R44

Description

@Julien-R44

Hi i've been using tuyau in adonisjs + nextjs monorepo setup, and it's been great for type safety. However i'v encountered a few friction points that, if addressed would significantly improve the DX

  1. Native File support in generated types
    Currently, when handling multipart/form-data, the generated types for request body don't seem recognize the native DOM File object. This forces us to use double casting
// Current workaround
value={(field.state.value ?? []) as unknown as File[]}
onValueChange={(file) => field.handleChange(file as unknown as typeof field.state.value)}
  1. Optional baseUrl wrapping for urlFor
    In monorepo setups, the frontend and backend run on different origins. Manually prepending the environment variable every time we need an asset URL is repetitive
const src = `${process.env.NEXT_PUBLIC_BASE_URL}${tuyauClient.urlFor("attachments", { key: name })}`;

Add an option in urlFor to wrap the path with the baseUrl

  1. Expose safe utility as a standalone export
    The safe utility is excellent for avoiding try-catch blocks. However, it is currently difficult to use it for custom logic or external mutations (like wrapping a TanStack Query mutateAsync call).
const [error, success] = await safe(mutateAsync({ params, body: value }));

Originally posted by @epenflow in #100

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions