From 6c555355ac976022ba85773f09a4866932ab89df Mon Sep 17 00:00:00 2001 From: Joshua Date: Wed, 14 Sep 2022 00:41:04 +0200 Subject: [PATCH] initial routes --- src/index.ts | 27 +++++++++++++++++++++++++++ src/routes/api/hewwo.ts | 4 ++++ src/routes/api/index.ts | 9 +++++++++ src/routes/index.ts | 4 ++++ 4 files changed, 44 insertions(+) create mode 100644 src/index.ts create mode 100644 src/routes/api/hewwo.ts create mode 100644 src/routes/api/index.ts create mode 100644 src/routes/index.ts diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..53fe600 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,27 @@ +import { pogo } from "../deps.ts"; +import { database } from "../utils/index.ts" +import routes from "./routes.generated.ts" + +const env = { + port: Number(Deno.env.get("POGO_PORT")) || 3000, +} + +const server = pogo.server({ + port: env.port +}) + +server.router.get('/', async () => { + return `${JSON.stringify(await database.from("void_socials"))}`; +}); + +routes.forEach(route => { + server.route({ method: route.method, handler: route.handler, path: route.route }) +}) + + + + + +await server.start() +console.log(`Dreamland online on Port ${env.port}`) + diff --git a/src/routes/api/hewwo.ts b/src/routes/api/hewwo.ts new file mode 100644 index 0000000..85607e5 --- /dev/null +++ b/src/routes/api/hewwo.ts @@ -0,0 +1,4 @@ +export const method = ['*'] +export const handler = () => { + return "api/hewwo" +} \ No newline at end of file diff --git a/src/routes/api/index.ts b/src/routes/api/index.ts new file mode 100644 index 0000000..ab2c787 --- /dev/null +++ b/src/routes/api/index.ts @@ -0,0 +1,9 @@ +import { database } from "../../../utils/index.ts" + + + +export const method = ['*'] +export const handler = async () => { + return `${JSON.stringify(await database.from("void_socials"))}`; + +} \ No newline at end of file diff --git a/src/routes/index.ts b/src/routes/index.ts new file mode 100644 index 0000000..4407ea8 --- /dev/null +++ b/src/routes/index.ts @@ -0,0 +1,4 @@ +export const method = ['*'] +export const handler = () => { + return "index" +} \ No newline at end of file