leblebijs/example/index.ts

39 lines
674 B
TypeScript

import { endpoint } from "../src";
import { startServer } from "../src/core/server";
import { route } from "../src/routing/router";
type Data = {
name: string;
};
startServer(
endpoint<void, Data>(
route([
{
app: async (req) => {
return {
status: 200,
body: {
name: "foo",
},
};
},
method: "GET",
url: "/",
},
{
app: async (req) => {
return {
status: 200,
body: {
name: "polo",
},
};
},
method: "GET",
url: "/marco",
},
]),
),
);