chore: Set up Deno project with Docker, environment configuration, and basic server

This commit is contained in:
Mauricio Siu
2025-02-23 20:13:56 -06:00
parent d525138542
commit 818be08214
8 changed files with 106 additions and 21 deletions

24
deno/main.ts Normal file
View File

@@ -0,0 +1,24 @@
import "jsr:@std/dotenv/load";
import { serveFile } from "jsr:@std/http/file-server";
const PORT = Deno.env.get("PORT") || 8000;
const handler = async (req: Request): Promise<Response> => {
const url = new URL(req.url);
if (url.pathname === "/") {
return await serveFile(req, "./public/index.html");
} else if (url.pathname === "/greet") {
const greeting = Deno.env.get("GREETING") || "Hello from Deno 2!";
return new Response(greeting);
} else {
return new Response("Not Found", { status: 404 });
}
};
// Error handling
try {
Deno.serve({ port: Number(PORT) }, handler);
} catch (err) {
console.error("Error starting the server:", err);
}