
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
connect-to-fetch
Advanced tools
Use Connect-style Node handlers with Fetch environments such as `Bun.serve` and `Deno.serve`.
Use Connect-style Node handlers with Fetch environments such as Bun.serve
and
Deno.serve
.
Use Vite's dev-server middleware with application that uses Bun.serve
.
bun add connect-to-fetch
Pass one or more handlers or middleware to connectToFetch
.
Example with single handler:
import { connectToFetch } from 'connect-to-fetch';
const getResponse = connectToFetch((req, res) => {
res.setHeader('Content-type', 'text/plain');
res.end('Hello world');
});
Bun.serve({
async fetch(request: Request) {
try {
return await getResponse(request);
} catch (e) {
const error = e as Error;
if (error.message === 'UNHANDLED') {
return new Response('Not Found', { status: 404 });
}
console.error(error);
return new Response('Server Error', { status: 500 });
}
},
});
Example with multiple handlers:
import { connectToFetch } from 'connect-to-fetch';
const getResponse = connectToFetch([
(req, res, next) => {
console.log(req.method, req.path);
next();
},
(req, res) => {
res.setHeader('Content-type', 'text/plain');
res.end('Hello world');
},
]);
Adapted from vike-node, MIT License.
Tests use Bun.serve
, so you'll need to have Bun installed to test.
FAQs
Use Connect-style Node handlers with Fetch environments such as `Bun.serve` and `Deno.serve`.
The npm package connect-to-fetch receives a total of 3 weekly downloads. As such, connect-to-fetch popularity was classified as not popular.
We found that connect-to-fetch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.