https://github.com/kt3k/iterable_file_server
Serve items from `AsyncIterable<File>`
https://github.com/kt3k/iterable_file_server
async-iterable deno file-server
Last synced: about 2 months ago
JSON representation
Serve items from `AsyncIterable<File>`
- Host: GitHub
- URL: https://github.com/kt3k/iterable_file_server
- Owner: kt3k
- License: mit
- Created: 2021-05-06T07:35:59.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-10-20T07:49:12.000Z (over 4 years ago)
- Last Synced: 2025-03-09T05:20:31.658Z (over 1 year ago)
- Topics: async-iterable, deno, file-server
- Language: TypeScript
- Homepage:
- Size: 35.2 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iterable_file_server v0.2.0
> Serve items from `AsyncIterable`
# Usage
```ts
import { serve } from "https://deno.land/x/iterable_file_server@v0.2.0/mod.ts";
async function* generateItems() {
yield new File(["foo"], "foo.html");
yield new File(["bar"], "foo/bar.html");
yield new File(["baz"], "foo/bar/baz.html");
// ...
}
const server = serve(generateItems(), { port: 3000 });
// This serves the follwoing paths:
// - http://localhost:3000/foo.html
// - http://localhost:3000/foo/bar.html
// - http://localhost:3000/foo/bar/baz.html
// This also serves the debug page:
// - http://localhost:3000/__debug__
// ...
// When you want to stop the server.
server.close();
```
This depends on native http bindings, so you need `--unstable` flag to use this
module.
# History
- 2021-10-20 v0.2.0 Use `File` interface for a file #5.
- 2021-07-31 v0.1.7 Set `content-type` header #3.
# License
MIT