elysia
elysia copied to clipboard
redirect routes
What is the problem this feature would solve?
write less code
What is the feature you are proposing to solve the problem?
const app = new Elysia()
.redirect('/', '/docs')
// or
.redirect({
'/': '/docs',
'/old-docs': '/docs'
})
will be nice with serve.static (oven-sh/bun#13540)
What alternatives have you considered?
.get('/', ({ redirect }) => redirect('/docs'))
import { Elysia } from "elysia";
const app = new Elysia()
.get("/", ({ set }) => (set.redirect = "/redirected"))
.get("/redirected", () => "redirected")
.listen(3000);
@RaphaelNJ
we already have
app.get('/', ({ redirect }) => redirect('/docs'))
my idea is write less code and use new serve.static option, which makes such routes faster
You can now inline redirect to Elysia handler, which will be added to serve.routes
import { redirect } from 'elysia'
const app = new Elysia()
.get('/', redirect('/thing'))
.get('/thing', 'thing')
Closing as complete