leblebijs/example/index.ts

39 lines
674 B
TypeScript
Raw Normal View History

2022-05-21 21:36:48 -05:00
import { endpoint } from "../src";
import { startServer } from "../src/core/server";
2022-05-21 23:33:51 -05:00
import { route } from "../src/routing/router";
2022-05-21 02:31:26 -05:00
2022-05-21 21:36:48 -05:00
type Data = {
name: string;
};
startServer(
2022-05-21 23:33:51 -05:00
endpoint<void, Data>(
route([
{
app: async (req) => {
return {
status: 200,
body: {
name: "foo",
},
};
},
method: "GET",
url: "/",
2022-05-21 21:36:48 -05:00
},
2022-05-21 23:33:51 -05:00
{
app: async (req) => {
return {
status: 200,
body: {
name: "polo",
},
};
},
method: "GET",
url: "/marco",
},
]),
),
2022-05-21 21:36:48 -05:00
);