fix(webrequest): complete rewrite to v4: migrate API to fetch-compatible function and new WebrequestClient, update tests and docs, and bump dependencies

This commit is contained in:
2026-03-02 13:49:27 +00:00
parent 1bed95d96e
commit 9972272f00
8 changed files with 5771 additions and 4063 deletions

View File

@@ -2,42 +2,31 @@ import { expect, tap } from '@git.zone/tstest/tapbundle';
import { webrequest } from '../ts/index.js';
// test dependencies
import * as typedserver from '@api.global/typedserver';
import { TypedServer } from '@api.global/typedserver';
let testServer: typedserver.servertools.Server;
let testServer: TypedServer;
tap.test('setup test server', async () => {
testServer = new typedserver.servertools.Server({
testServer = new TypedServer({
cors: false,
forceSsl: false,
port: 2345,
});
testServer.addRoute(
'/apiroute1',
new typedserver.servertools.Handler('GET', (req, res) => {
res.status(500);
res.end();
}),
);
testServer.addRoute('/apiroute1', 'GET', async (ctx) => {
return new Response(null, { status: 500 });
});
testServer.addRoute(
'/apiroute2',
new typedserver.servertools.Handler('GET', (req, res) => {
res.status(500);
res.end();
}),
);
testServer.addRoute('/apiroute2', 'GET', async (ctx) => {
return new Response(null, { status: 500 });
});
testServer.addRoute(
'/apiroute3',
new typedserver.servertools.Handler('GET', (req, res) => {
res.status(200);
res.send({
hithere: 'hi',
});
}),
);
testServer.addRoute('/apiroute3', 'GET', async (ctx) => {
return new Response(JSON.stringify({ hithere: 'hi' }), {
status: 200,
headers: { 'Content-Type': 'application/json' },
});
});
await testServer.start();
});