Skip to content

contract without schema? #89

@iamyuu

Description

@iamyuu

Hi, I want to use orpc only for clients, but I don't want to add extra bundle to parse the response, is that possible? e.g.

// or maybe you can use `HttpError` as the default error response?
type HttpError = {
  message: string
}

type FilterTodo = {
  search: string
}

type Todo = {
  id: number
  title: string
  completed: boolean
}

const contract = oc.router({
  todo: oc.router({
    all: oc.route({ method: 'GET', path: '/todos' })
      .input<Partial<FilterTodo>>()
      .output<Todo[], HttpError>(),

    create: oc
      .route({ method: 'POST', path: '/todos' })
      .input<Omit<Todo, 'id'>>()
      .output<Todo, HttpError>(),

    completeById: oc
      .route({ method: 'PUT', path: '/todos/{id}' })
      .output<Todo, HttpError>(),
  }),
});

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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