Basic Example
Let's create a simple Yelix server that responds with "Hello World!" when you access the /api/hello
endpoint.
- Dynamic Import
- Static Import
main.ts
import { Yelix } from 'jsr:@murat/yelix';
const app = new Yelix();
app.loadEndpointsFromFolder('api');
await app.serve();
main.ts
import { Yelix } from 'jsr:@murat/yelix';
const app = new Yelix();
const helloEndpoints = await import('./api/hello.ts');
app.loadEndpoints([helloEndpoints]);
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';