Getting Started
keiro
keiro
(Kee-Ro) is a routing middleware compatible with NodeJS
which uses moderm Web Standards.
Installation
npm add keiro
yarn add keiro
pnpm add keiro
bun add keiro
Setup
Directorysrc
- main.ts
Directoryroutes ** All the routes are located here **
- index.ts
- package.json
For initialize the middleware we import the fileSystemRouter
from keiro/node
or keiro/web
.
import { fileSystemRouter } from "keiro/node";import http from "node:http";
const port = 5000;const origin = `http://localhost:${port}`;
const server = http.createServer(fileSystemRouter({ origin }));server.listen(port, () => console.log(`Listening on ${origin}`));
We define the api handlers on the src/routes/
, this can be changed.
import { defineHandler } from "keiro";
export default defineHandler(() => { return Response.json({ hello: "world" })})
Then run main.ts
on node
you can install tsx and use tsx src/main.ts
.