Skip to main content

Basic Example

Let's create a simple Yelix server that responds with "Hello World!" when you access the /api/hello endpoint.

main.ts
import { Yelix } from 'jsr:@murat/yelix';

const app = new Yelix();
app.loadEndpointsFromFolder('api');

await app.serve();

api/hello.ts
import { Ctx } from 'jsr:@murat/yelix';

export async function GET(ctx: Ctx) {
return await ctx.text('Hello world!', 200);
}

export const path = '/api/hello';