From 2eaa6da971542dc3db0e47e6d84460380019df59 Mon Sep 17 00:00:00 2001 From: Joshua Date: Wed, 14 Sep 2022 23:28:25 +0200 Subject: [PATCH] more routes --- src/index.ts | 13 +++++++------ src/routes.generated.ts | 31 +++++++++++++++++------------- src/routes/api/clients/[client].ts | 9 +++++++++ src/routes/api/clients/index.ts | 9 +++++++++ src/routes/api/credits.ts | 7 +++++++ src/routes/api/index.ts | 2 +- src/static/uwu.txt | 1 + 7 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 src/routes/api/clients/[client].ts create mode 100644 src/routes/api/clients/index.ts create mode 100644 src/routes/api/credits.ts create mode 100644 src/static/uwu.txt diff --git a/src/index.ts b/src/index.ts index 53fe600..5e0859b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ -import { pogo } from "../deps.ts"; -import { database } from "../utils/index.ts" +import { pogo, serve } from "../deps.ts"; import routes from "./routes.generated.ts" const env = { @@ -10,11 +9,13 @@ const server = pogo.server({ port: env.port }) -server.router.get('/', async () => { - return `${JSON.stringify(await database.from("void_socials"))}`; -}); +server.router.get('/public/{file*}', (r, h) => { + return h.directory("./public/") +}) + routes.forEach(route => { + // console.log(`Adding ${route.route}`) server.route({ method: route.method, handler: route.handler, path: route.route }) }) @@ -22,6 +23,6 @@ routes.forEach(route => { +console.log(`Dreamland (should be) online on Port ${env.port}`) await server.start() -console.log(`Dreamland online on Port ${env.port}`) diff --git a/src/routes.generated.ts b/src/routes.generated.ts index 6e7910e..df731fc 100644 --- a/src/routes.generated.ts +++ b/src/routes.generated.ts @@ -2,21 +2,26 @@ // Do not edit this File manually // run `vr routes` to regenerate this File -import { method as method_0, handler as handler_0 } from "./routes/api/hewwo.ts"; -import { method as method_1, handler as handler_1 } from "./routes/api/index.ts"; -import { method as method_2, handler as handler_2 } from "./routes/index.ts"; - -interface PageRoute { - method: string | string[] - handler: void | any - route: string -} +import PageRoute from "../utils/types/PageRoute.ts" +import { method as method_0, handler as handler_0 } from "./routes/api/clients/index.ts"; +import { method as method_1, handler as handler_1 } from "./routes/api/clients/[client].ts"; +import { method as method_2, handler as handler_2 } from "./routes/api/credits.ts"; +import { method as method_3, handler as handler_3 } from "./routes/api/hewwo.ts"; +import { method as method_4, handler as handler_4 } from "./routes/api/index.ts"; +import { method as method_5, handler as handler_5 } from "./routes/index.ts"; +import { method as method_6, handler as handler_6 } from "./routes/s/index.ts"; +import { method as method_7, handler as handler_7 } from "./routes/s/[slug].ts"; const routes: PageRoute[] = [ - { method: method_0, handler: handler_0, route: "/api/hewwo"}, - { method: method_1, handler: handler_1, route: "/api"}, - { method: method_2, handler: handler_2, route: "/"} - ] + { method: method_0, handler: handler_0, route: "/api/clients" }, + { method: method_1, handler: handler_1, route: "/api/clients/{client}" }, + { method: method_2, handler: handler_2, route: "/api/credits" }, + { method: method_3, handler: handler_3, route: "/api/hewwo" }, + { method: method_4, handler: handler_4, route: "/api" }, + { method: method_5, handler: handler_5, route: "/" }, + { method: method_6, handler: handler_6, route: "/s" }, + { method: method_7, handler: handler_7, route: "/s/{slug}" } +] export default routes diff --git a/src/routes/api/clients/[client].ts b/src/routes/api/clients/[client].ts new file mode 100644 index 0000000..d1a8894 --- /dev/null +++ b/src/routes/api/clients/[client].ts @@ -0,0 +1,9 @@ +// import { Request } from "https://deno.land/x/pogo@v0.5.2/main.ts" + +import { pogo } from "../../../../deps.ts" + +export const method = ['*'] +export const handler = (req: pogo.Request) => { + console.log(`${req.params.client}`) + return `${req.params.client}` +} \ No newline at end of file diff --git a/src/routes/api/clients/index.ts b/src/routes/api/clients/index.ts new file mode 100644 index 0000000..3748099 --- /dev/null +++ b/src/routes/api/clients/index.ts @@ -0,0 +1,9 @@ +// import { Request } from "https://deno.land/x/pogo@v0.5.2/main.ts" + +import { pogo } from "../../../../deps.ts" + +export const method = ['*'] +export const handler = (req: pogo.Request) => { + // console.log(`${req.params.client}`) + return `api/client/index` +} \ No newline at end of file diff --git a/src/routes/api/credits.ts b/src/routes/api/credits.ts new file mode 100644 index 0000000..6942039 --- /dev/null +++ b/src/routes/api/credits.ts @@ -0,0 +1,7 @@ +export const method = ['*'] +export const handler = () => { + return { + name: "Lio", + url: "lio.cat" + } +} \ No newline at end of file diff --git a/src/routes/api/index.ts b/src/routes/api/index.ts index ab2c787..1e42359 100644 --- a/src/routes/api/index.ts +++ b/src/routes/api/index.ts @@ -4,6 +4,6 @@ import { database } from "../../../utils/index.ts" export const method = ['*'] export const handler = async () => { - return `${JSON.stringify(await database.from("void_socials"))}`; + return await database.from("void_socials") } \ No newline at end of file diff --git a/src/static/uwu.txt b/src/static/uwu.txt new file mode 100644 index 0000000..2e65efe --- /dev/null +++ b/src/static/uwu.txt @@ -0,0 +1 @@ +a \ No newline at end of file