Your First API Endpoint

Let's create a simple API endpoint. BreezeAPI uses a file-based routing system. Each file in the src/routes directory corresponds to an API endpoint.

Here's an example of a simple endpoint in src/routes/hello/route.ts:

import { t, HttpContext } from '@breezeapi/core';

export const GET_config = {
  response: t.object({
    message: t.string(),
  }),
};

export async function GET(ctx: HttpContext) {
  return Response.json({ message: 'Hello, World!' });
}

With this file in place, you can now access http://localhost:3000/hello and you'll receive a JSON response with the message "Hello, World!".

See Core Concepts for more on routing and handlers.