Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Latest commit

 

History

History
91 lines (60 loc) · 2.7 KB

File metadata and controls

91 lines (60 loc) · 2.7 KB
self_link https://fart.fart.tools/server-architecture

Fart Server 📡

How to spin up a Fart Server

You can spin up the Fart Serer on your machine in one command (assuming Deno is installed).

deno run --allow-net --allow-read --allow-env --unstable https://github.com/EthanThatOneKid/fart/raw/main/std/server/serve_http.ts
Local Variation
deno run --allow-net --allow-read --allow-env --unstable std/server/serve_http.ts

Simulating a Deno Deploy Environment

If you haven't already, install deployctl, a runtime that simulates Deno Deploy.

deno install --allow-read --allow-write --allow-env --allow-net --allow-run --no-check -f https://deno.land/x/deploy/deployctl.ts

To run the development server, enter the below command into your terminal.

deployctl run --watch std/server/worker.ts

Features

Homepage (GET /)

/middleware/home.ts

This page renders and serves the README.md of https://github.com/EthanThatOneKid/fart/.

Static Files (GET /[...path].*)

/middleware/static.ts

This middleware serves static files located under /std/server/static/.

GitHub Docs (/[...path])

/middleware/gh_docs.ts

Any markdown files located under /docs are rendered and served.

Compile Farts (GET /[registry]/[...path].*)

/middleware/compile.ts

This middleware serves the compiled result of any Fart source file publicly hosted on GitHub.

If no matching public GitHub source Farts can be found, the request checks to see if there is any raw Fart code in the body. If so, the server will generate the code based on the source Fart from the request body.

URL Composition

This is a more detailed diagram of the pattern that the compilation middlware snags on.

/[registry]/[owner]/[project_name]/[branch]/[...path].*

Compilation Endpoint Examples

  • /go/EthanThatOneKid/fart/main/ex/pokemon/mod.go
  • /ts/EthanThatOneKid/fart/main/ex/pokemon/mod.ts
  • /ts.deno/EthanThatOneKid/fart/main/ex/pokemon/mod.ts
  • /ts.deno.api/EthanThatOneKid/fart/main/ex/pokemon/mod.ts
  • /html.highlight/EthanThatOneKid/fart/main/ex/pokemon/mod.html