0.1.6 • Published 2 years ago

elysia-fs-router v0.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

elysia-fs-router

Getting Started

Run bun install elysia-fs-router.

Usage

these can also be found in the examples folder

import Elysia from "elysia";
import { Config, elysiaFsRouter } from "elysia-fs-router";
const config: Config = {
    serverDir: '/example/server',
    apiPrefix: 'api'
}
const app = new Elysia()
.use(elysiaFsRouter(config))
.listen(3006)
// example/server/hello.ts
import { Context } from "elysia";

const GET = (ctx: Context) => {
    return "Hello," + `${ctx.request.method}`;
}

export default {GET}
//example/server/hi.ts
//  delete request to http://localhost:3030/api/hi
export function DELETE(ctx: Context){
    console.log(ctx.query);
    return "hi," + `${ctx.request.method}`;
}
//example/server/posts/[id]-[name].ts
//this will be registered as
/// http://localhost:3030/api/posts/{id}/{name}
import { Context } from "elysia";

export default(ctx: Context) => {

    return {id: ctx.params?.id, name: ctx.params?.name};
}
// example/server/posts/[...all].ts
// http://localhost:3030/api/posts/*
import { Context } from "elysia";

export default(ctx: Context) => {
    return {params: ctx.params};
}

License

MIT

0.1.4

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4-beta.4

2 years ago

0.1.4-beta.3

2 years ago

0.1.4-beta.2

2 years ago

0.1.4-beta.1

2 years ago

0.1.4-beta.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago