Last active
September 15, 2023 00:28
-
-
Save ethanniser/998522056c046d5911c0e05f69eb94a5 to your computer and use it in GitHub Desktop.
Seperate Files in Elysia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const ctx = new Elysia({ | |
name: "@app/ctx", | |
}) | |
.use(plugin()) | |
.decorate("db", db) | |
.decorate("config", config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ctx } from "./base" | |
export const todos = new Elysia() | |
.use(ctx) | |
.get("/todos", async () => { | |
const data = await db.select().from(todos); | |
return data; | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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