# elysia-autoroutes

> File system routing for Elysia.

Latest version **0.5.0** (published 2023-12-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install elysia-autoroutes
pnpm add elysia-autoroutes
yarn add elysia-autoroutes
bun add elysia-autoroutes
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2023-12-28 |
| First published | 2023-07-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 13.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 145 |
| Author | Robert Soriano |
| Maintainers | wobsoriano |
| Keywords | bun |

## Links

- npm: https://www.npmjs.com/package/elysia-autoroutes
- Repository: https://github.com/wobsoriano/elysia-autoroutes
- Homepage: https://github.com/wobsoriano/elysia-autoroutes#readme
- Issues: https://github.com/wobsoriano/elysia-autoroutes/issues
- npm.io page: https://npm.io/package/elysia-autoroutes

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2023-12-28
- 0.4.0 — 2023-09-26
- 0.3.0 — 2023-09-25
- 0.2.2 — 2023-08-06
- 0.2.1 — 2023-08-06
- 0.2.0 — 2023-08-06
- 0.1.8 — 2023-08-06
- 0.1.7 — 2023-08-06
- 0.1.6 — 2023-07-29
- 0.1.5 — 2023-07-28
- 0.1.4 — 2023-07-27
- 0.1.3 — 2023-07-27
- 0.1.2 — 2023-07-27
- 0.1.1 — 2023-07-27
- 0.1.0 — 2023-07-27
- … 3 more at https://npm.io/package/elysia-autoroutes/versions

## README

# elysia-autoroutes

File system routes for [Elysia.js](https://elysiajs.com/).

## Install

```bash
bun install elysia-autoroutes
```

## Usage

### Register the plugin

Note: It uses your project's `/routes` directory as source by default.

```ts
import { Elysia } from 'elysia'
import { autoroutes } from 'elysia-autoroutes'

const app = new Elysia()
  .use(
    autoroutes({
      routesDir: "./routes", // -> optional, defaults to './routes'
      prefix: "/api", // -> optional, defaults to ''
      generateTags: false, // -> optional, defaults to true
    })
  )
  .listen(3000)

export type ElysiaApp = typeof app
```

Create your first route

```ts
// routes/index.ts
import type { ElysiaApp } from './app'

export default (app: ElysiaApp) => app.get('/', { hello: 'world' })
```

### Directory Structure

Files inside your project's `/routes` directory will get matched a url path automatically.

```php
├── app.ts
├── routes
    ├── index.ts // index routes
    ├── posts
        ├── index.ts
        └── [id].ts // dynamic params
    └── users.ts
└── package.json
```

- `/routes/index.ts` → /
- `/routes/posts/index.ts` → /posts
- `/routes/posts/[id].ts` → /posts/:id
- `/routes/users.ts` → /users

## License

MIT

---
_Source: https://npm.io/package/elysia-autoroutes · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
