https://github.com/ofabiodev/elysia-routing
🧠Declarative routing for Elysia that turns simple definitions into clean predictable routes.
https://github.com/ofabiodev/elysia-routing
autoroute autorouting elysia elysia-plugin elysiajs middleware
Last synced: 5 months ago
JSON representation
🧠Declarative routing for Elysia that turns simple definitions into clean predictable routes.
- Host: GitHub
- URL: https://github.com/ofabiodev/elysia-routing
- Owner: ofabiodev
- License: mit
- Created: 2026-01-16T14:33:18.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2026-01-16T14:36:02.000Z (6 months ago)
- Last Synced: 2026-01-17T04:41:43.950Z (6 months ago)
- Topics: autoroute, autorouting, elysia, elysia-plugin, elysiajs, middleware
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/elysia-routing
- Size: 38.1 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
Elysia Routing
File-based routing for Elysia with built-in type-safe validation.
## Why Elysia Routing?
Stop manually registering routes. **elysia-routing** scans your file structure and automatically creates routes based on filenames. Add type-safe validation with zero dependencies, keep your codebase organized, and scale without the boilerplate.
## Installation
```bash
# Using Bun
bun add elysia-routing
```
```bash
# Using NPM
npm install elysia-routing
```
```bash
# Using Yarn
yarn add elysia-routing
```
## Supported Conventions
Convention
Example
Result
(group)
(admin)/dashboard.get.ts
GET /dashboard
[param]
users/[id]/index.get.ts
GET /users/:id
index
users/index.post.ts
POST /users
name.method
users/profile.get.ts
GET /users/profile
.all
health.all.ts
All HTTP methods
## Examples
routes/index.get.ts
```ts
import { defineRoute } from "elysia-routing"
export default defineRoute({
handler: () => ({ message: "Hello World" })
})
```
routes/users/[id]/index.get.ts
```ts
import { defineRoute, v } from "elysia-routing"
export default defineRoute({
schema: {
params: v.object({
id: v.string()
})
},
handler: ({ params }) => ({
user: { id: params.id }
})
})
```
routes/users/index.post.ts
```ts
import { defineRoute, v } from "elysia-routing"
export default defineRoute({
schema: {
body: v.object({
name: v.string().min(3),
email: v.string().regex(/^[^\s@]+@[^\s@]+\.[^\s@]+$/),
age: v.number().min(18)
})
},
handler: ({ body }) => ({
created: body
})
})
```
## License
[MIT](LICENSE) © [ofabiodev](https://github.com/ofabiodev)