more routes

This commit is contained in:
Joshua 2022-09-14 23:28:25 +02:00
parent 629538a722
commit 2eaa6da971
7 changed files with 52 additions and 20 deletions

View file

@ -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}`)

View file

@ -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

View file

@ -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}`
}

View file

@ -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`
}

View file

@ -0,0 +1,7 @@
export const method = ['*']
export const handler = () => {
return {
name: "Lio",
url: "lio.cat"
}
}

View file

@ -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")
}

1
src/static/uwu.txt Normal file
View file

@ -0,0 +1 @@
a