Skip to content

Commit

Permalink
make optional
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusmarminge committed Feb 13, 2025
1 parent 511dc21 commit 0bfa25f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions packages/uploadthing/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const isValidFileSize = (
* @public
*/
export const genUploader = <TRouter extends FileRouter>(
initOpts: GenerateUploaderOptions,
initOpts?: GenerateUploaderOptions,
) => {
const routeRegistry = createIdentityProxy<RouteRegistry<TRouter>>();

Expand All @@ -108,11 +108,11 @@ export const genUploader = <TRouter extends FileRouter>(

const utReporter = createUTReporter({
endpoint: String(endpoint),
package: initOpts.package,
url: resolveMaybeUrlArg(initOpts.url),
package: initOpts?.package ?? "uploadthing/client",
url: resolveMaybeUrlArg(initOpts?.url),
headers: opts.headers,
});
const fetchFn: FetchEsque = initOpts.fetch ?? window.fetch;
const fetchFn: FetchEsque = initOpts?.fetch ?? window.fetch;

const presigneds = await Micro.runPromise(
utReporter("upload", {
Expand Down Expand Up @@ -256,13 +256,13 @@ export const genUploader = <TRouter extends FileRouter>(
>,
) => {
const endpoint = typeof slug === "function" ? slug(routeRegistry) : slug;
const fetchFn: FetchEsque = initOpts.fetch ?? window.fetch;
const fetchFn: FetchEsque = initOpts?.fetch ?? window.fetch;

return uploadFilesInternal<TRouter, TEndpoint>(endpoint, {
...opts,
skipPolling: {} as never, // Remove in a future version, it's type right not is an ErrorMessage<T> to help migrations.
url: resolveMaybeUrlArg(initOpts.url),
package: initOpts.package,
url: resolveMaybeUrlArg(initOpts?.url),
package: initOpts?.package ?? "uploadthing/client",
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
input: (opts as any).input as inferEndpointInput<TRouter[TEndpoint]>,
})
Expand Down
2 changes: 1 addition & 1 deletion packages/uploadthing/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export type GenerateUploaderOptions = {
*
* This is used to identify the client in the server logs
*/
package: string;
package?: string;
};

export type EndpointArg<
Expand Down

0 comments on commit 0bfa25f

Please sign in to comment.