-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add readme, fix package.json and add deno.json to test dir
- Loading branch information
Showing
3 changed files
with
33 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# deno-http-worker | ||
|
||
Similarly to [deno-vm](https://github.com/casual-simulation/node-deno-vm), deno-http-worker lets you securely spawn Deno http servers. | ||
|
||
## Usage | ||
|
||
```ts | ||
import { newDenoHTTPWorker } from 'deno-http-worker'; | ||
|
||
let worker = await newDenoHTTPWorker( | ||
`export default async function (req: Request): Promise<Response> { | ||
return Response.json({ ok: req.url }) | ||
}`, | ||
{ printOutput: true, runFlags: ["--alow-net"] } | ||
); | ||
|
||
let json = await worker.client | ||
.get("https://hello/world?query=param") | ||
.json(); | ||
console.log(json) // => { ok: 'https://hello/world?query=param' } | ||
|
||
worker.terminate(); | ||
``` | ||
|
||
## Internals | ||
|
||
When spawning the Deno process deno-http-worker connects to the process over a Unix socket. This is for performance and efficiency. As a result, the worker does not provide an address to make requests to, but instead returns an instance of a [got](https://www.npmjs.com/package/got) client that you can make requests with. This ensures that only the underlying `http2.ClientHttp2Session` is used to make requests. | ||
|
||
If you need more advanced usage that cannot be covered by `got`, please open a ticket. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "lock": false } |