Skip to content

createApp function with context and onError #3

@qantrepreneur

Description

@qantrepreneur

What to build

Implement the createApp function — the root configuration entry point for framework users. It accepts a config object with context (a function that receives a Request and returns custom context) and onError (a global error handler).

export default createApp({
  context: (request) => ({
    sdk: new SDK({ apiKey: "..." }),
  }),
  onError: (error, request) => {
    console.error(error);
    return new Response("Internal Server Error", { status: 500 });
  },
});

The return type of context should propagate through the type system so that ctx in loaders is fully typed with the user's custom properties + route params.

Acceptance criteria

  • createApp accepts { context, onError } config
  • context function receives Request and returns user-defined context
  • onError is optional, receives (error: unknown, request: Request)
  • Return type preserves the context type for downstream inference
  • Unit tests for createApp with and without onError

Blocked by

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions