Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lucacasonato/deno-fetchevent
FetchEvent based server compatible with browser.
https://github.com/lucacasonato/deno-fetchevent
Last synced: 26 days ago
JSON representation
FetchEvent based server compatible with browser.
- Host: GitHub
- URL: https://github.com/lucacasonato/deno-fetchevent
- Owner: lucacasonato
- License: mit
- Created: 2020-06-07T23:09:05.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-06-03T09:17:39.000Z (over 3 years ago)
- Last Synced: 2024-10-06T10:48:59.957Z (about 1 month ago)
- Language: TypeScript
- Size: 20.5 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deno FetchEvent
[![deno doc](https://doc.deno.land/badge.svg)](https://doc.deno.land/https/raw.githubusercontent.com/lucacasonato/deno-fetchevent/master/mod.ts)
This project is a prototype of what a FetchEvent based http server would feel like. For more background, take a look at https://github.com/denoland/deno/issues/4898.
> **DISCLAIMER**: This is not tested at all. Please do not use this for anything important. This is just a prototype and will not be developed further.
## Example
```typescript
import { serve } from "https://raw.githubusercontent.com/lucacasonato/deno-fetchevent/master/mod.ts";console.log("Listening on http://localhost:8080/");
for await (const event of serve(":8080")) {
const { request } = event;console.log("---");
console.log(request.url);
console.log(request.method);
if (request.body) console.log(await request.json());event.respondWith(Response.redirect("https://deno.land", 303));
}
```Quick start:
```
deno run --allow-net https://raw.githubusercontent.com/lucacasonato/deno-fetchevent/master/example.ts
```