router-query/examples/deny_network.mjs
Version 663282b0ebbc.bb1 · MIT. This preview displays packaged text and does not execute code. Treat the contents as untrusted instructions.
← Return to resource and package checksum
import http from 'node:http';
import https from 'node:https';
import net from 'node:net';
import tls from 'node:tls';
import { syncBuiltinESMExports } from 'node:module';
export const networkAttempts=[];
const deny=(method)=>(...args)=>{networkAttempts.push({method});throw new Error(`Native fixture denied network: ${method}`);};
http.request=deny('http.request');http.get=deny('http.get');
https.request=deny('https.request');https.get=deny('https.get');
net.connect=deny('net.connect');net.createConnection=deny('net.createConnection');
net.Socket.prototype.connect=deny('Socket.connect');tls.connect=deny('tls.connect');
globalThis.fetch=deny('fetch');syncBuiltinESMExports();