config endpoint

This commit is contained in:
cirroskais 2024-03-18 19:03:19 -04:00
parent eaa2d29aff
commit a01abce47b
No known key found for this signature in database
GPG key ID: 5FC73EBF2678E33D
2 changed files with 11 additions and 2 deletions

View file

@ -1,13 +1,14 @@
import token from "./routes/token";
import config from "./routes/config";
Bun.serve({
port: 3000,
async fetch(req) {
const url = new URL(req.url);
console.log(`${new Date()} ${req.method} ${url.pathname}`);
console.log(`${new Date().toUTCString()} ${req.method} ${url.pathname}`);
if (url.pathname === "/") return new Response("hello yes this is garf");
if (url.pathname === "/") return await config(req);
if (url.pathname === "/token") return await token(req);
return new Response("garf dont know what want...");
},

8
src/routes/config.ts Normal file
View file

@ -0,0 +1,8 @@
export default async function (req: Request): Promise<Response> {
return new Response(
JSON.stringify({
DISCORD_CLIENT_ID: process.env.DISCORD_CLIENT_ID,
}),
{ headers: { "Content-Type": "application/json" } }
);
}