Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Nov 26, 2021
1 parent 0965508 commit e837ab0
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 2 deletions.
12 changes: 12 additions & 0 deletions fart_server/bonus_features/doc_generator/deno_doc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// deno-lint-ignore-file

/**
* @param url ex: <https://deno.land/x/[email protected]/lib/fart.ts>
* @returns raw HTML generated from [`deno doc`](https://deno.land/[email protected]/tools/documentation_generator)
* @todo @ethanthatonekid mirror https://doc.deno.land/https/deno.land%2Fx%2Ffart%40v0.1%2Flib%2Ffart.ts
* @todo @ethanthatonekid serve any static files
* @todo @ethanthatonekid remove deno-lint-ignore-file
*/
export const fetchDenoDoc = async (url: string): Promise<string> => {
return "";
};
10 changes: 10 additions & 0 deletions fart_server/bonus_features/doc_generator/gh_doc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// deno-lint-ignore-file

/**
* @param url ex: <https://etok.codes/fart/blob/main/docs/pokemon-example.md>
* @returns raw HTML of parsed documentation found on <https://etok.codes/fart/>
* @todo @ethanthatonekid refactor https://github.com/EthanThatOneKid/fart/blob/c43f2333458b2cbc40d167610d87e2a2e3f89885/std/server/middleware/gh_docs.ts
*/
export const fetchGitHubDoc = async (url: string): Promise<string> => {
return "";
};
2 changes: 2 additions & 0 deletions fart_server/bonus_features/doc_generator/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { fetchGitHubDoc } from "./gh_doc.ts";
export { fetchDenoDoc } from "./deno_doc.ts";
2 changes: 0 additions & 2 deletions fart_server/bonus_features/docs/mod.ts

This file was deleted.

13 changes: 13 additions & 0 deletions fart_server/handle_request.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
// deno-lint-ignore-file

import {
fetchDenoDoc,
fetchGitHubDoc,
} from "./bonus_features/doc_generator/mod.ts";

/**
* This function handles any request sent to the Fart server. This includes
* custom routing, and more.
* @todo @ethanthatonekid fledge out the rest of the features
*/
export const handleRequest = async (request: Request): Promise<Response> => {
return Response.redirect("/");
};
13 changes: 13 additions & 0 deletions fart_server/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// deno-lint-ignore-file

/**
* Routes a given HTTP request to the intended `bonus_features` and
* sets the appropriate content type header.
* @param request incoming http request
* @returns routed Fart server response
*/
export const route = async (request: Request): Promise<Response> => {
// TODO(@ethanthatonekid): double-check proper index checking
const isIndex = request.url.length === 0 || request.url === "/";
return Response.redirect("/");
};
6 changes: 6 additions & 0 deletions fart_server/worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { handleRequest } from "./handle_request.ts";

addEventListener("fetch", async (event) => {
const response = await handleRequest(event.request);
event.respondWith(response);
});

1 comment on commit e837ab0

@deno-deploy
Copy link

@deno-deploy deno-deploy bot commented on e837ab0 Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

failed to fetch 'https://raw.githubusercontent.com/EthanThatOneKid/fart/e837ab025d825b4b1b5c695997258f4da964308e/std/server/worker.ts': HTTP status client error (404 Not Found) for url (https://raw.githubusercontent.com/EthanThatOneKid/fart/e837ab025d825b4b1b5c695997258f4da964308e/std/server/worker.ts)

Please sign in to comment.