New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

deno-http-worker

Package Overview
Dependencies
Maintainers
0
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

deno-http-worker

[![NPM version](https://img.shields.io/npm/v/deno-http-worker.svg?style=flat)](https://npmjs.org/package/deno-http-worker)

  • 0.0.16
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
41
decreased by-41.43%
Maintainers
0
Weekly downloads
 
Created
Source

deno-http-worker

NPM version

Similarly to deno-vm, deno-http-worker lets you securely spawn Deno http servers.

Usage

import { newDenoHTTPWorker } from 'deno-http-worker';

let worker = await newDenoHTTPWorker(
    `export default {
        async fetch(req: Request): Promise<Response> {
            return Response.json({ ok: req.url });
        },
    }`,
    { printOutput: true, runFlags: ["--allow-net"] }
);

const body = await new Promise((resolve, reject) => {
    const req = worker.request("https://hello/world?query=param", {}, (resp) => {
        const body = [];
        resp.on("error", reject);
        resp.on("data", (chunk) => {
            body.push(chunk);
        });
        resp.on("end", () => {
            resolve(Buffer.concat(body).toString());
        });
    })
    req.end();
})
console.log(body) // => {"ok":"https://hello/world?query=param"}

worker.terminate();

Internals

Deno-http-worker connects to the Deno process over a Unix socket to make requests. As a result, the worker does not provide an address or url, but instead returns request function that calls http.request under the hood, but modifies the request attributes to work over the socket.

If you need more advanced usage here, or run into bugs, please open an issue.

FAQs

Package last updated on 30 Jun 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc