Skip to content

Instantly share code, notes, and snippets.

@ethanniser
Last active September 15, 2023 00:28
Show Gist options
  • Save ethanniser/998522056c046d5911c0e05f69eb94a5 to your computer and use it in GitHub Desktop.
Save ethanniser/998522056c046d5911c0e05f69eb94a5 to your computer and use it in GitHub Desktop.
Seperate Files in Elysia
export const ctx = new Elysia({
name: "@app/ctx",
})
.use(plugin())
.decorate("db", db)
.decorate("config", config)
import { ctx } from "./base"
export const todos = new Elysia()
.use(ctx)
.get("/todos", async () => {
const data = await db.select().from(todos);
return data;
})
import { todos } from "./handlers"
const app = new Elysia()
.use(todos)
// ...
.listen(3000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment