From 0a1f91d354742074d1a3a16ea6329094a624742e Mon Sep 17 00:00:00 2001 From: EthanThatOneKid <31261035+EthanThatOneKid@users.noreply.github.com> Date: Sat, 18 Dec 2021 01:53:59 -0800 Subject: [PATCH] cleaningisdfmdsf --- fart_server/bonus_features/shortlinks/mod.ts | 1 + .../shortlinks/shortlinks.test.ts | 3 +++ fart_server/serve.ts | 1 + fart_server/serve_http.ts | 19 ------------------- fart_server/worker.ts | 6 ------ 5 files changed, 5 insertions(+), 25 deletions(-) delete mode 100644 fart_server/serve_http.ts delete mode 100644 fart_server/worker.ts diff --git a/fart_server/bonus_features/shortlinks/mod.ts b/fart_server/bonus_features/shortlinks/mod.ts index e69de29..b9c6775 100644 --- a/fart_server/bonus_features/shortlinks/mod.ts +++ b/fart_server/bonus_features/shortlinks/mod.ts @@ -0,0 +1 @@ +export { redirectIfShortlink } from "./shortlinks.ts"; diff --git a/fart_server/bonus_features/shortlinks/shortlinks.test.ts b/fart_server/bonus_features/shortlinks/shortlinks.test.ts index d4bebb2..76f4740 100644 --- a/fart_server/bonus_features/shortlinks/shortlinks.test.ts +++ b/fart_server/bonus_features/shortlinks/shortlinks.test.ts @@ -1 +1,4 @@ +import { assertEquals } from "../../../deps/std/testing.ts"; +import { redirectIfShortlink } from "./shortlinks.ts"; + // TODO(@ethanthatonekid): write tests for shortlinks.ts diff --git a/fart_server/serve.ts b/fart_server/serve.ts index beec884..2174d43 100644 --- a/fart_server/serve.ts +++ b/fart_server/serve.ts @@ -1,4 +1,5 @@ import { redirectToDenoDeployPreviewUrl } from "./bonus_features/versions/mod.ts"; +import { redirectIfShortlink } from "./bonus_features/shortlinks/mod.ts"; import { getSize, inject, register } from "./utils.ts"; export const handleRequest = async (event: Deno.RequestEvent) => { diff --git a/fart_server/serve_http.ts b/fart_server/serve_http.ts deleted file mode 100644 index c603356..0000000 --- a/fart_server/serve_http.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { handleRequest } from "./handle_request.ts"; - -export const serveHttp = async () => { - const server = Deno.listen({ port: 8080 }); - console.log(`HTTP webserver running. Access it at: http://localhost:8080/`); - // Connections to the server will be yielded up as an async iterable. - for await (const connection of server) { - // In order to not be blocking, we need to handle each connection individually - // without awaiting the function. - for await (const event of Deno.serveHttp(connection)) { - const { request, respondWith } = event; - respondWith(await handleRequest(request)); - } - } -}; - -if (import.meta.main) { - await serveHttp(); -} diff --git a/fart_server/worker.ts b/fart_server/worker.ts deleted file mode 100644 index ec3588a..0000000 --- a/fart_server/worker.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { handleRequest } from "./handle_request.ts"; - -addEventListener("fetch", async (event) => { - const response = await handleRequest(event.request); - event.respondWith(response); -});