Skip to content

Commit 0c147a3

Browse files
committed
chore: enable strict typescript with nodenext resolution
1 parent 32d2f0e commit 0c147a3

19 files changed

Lines changed: 195 additions & 503 deletions

‎package.json‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@
2222
"scripts": {
2323
"build": "unbuild",
2424
"dev": "vitest",
25-
"play": "jiti ./playground",
2625
"lint": "oxlint . && oxfmt --check src test",
2726
"lint:fix": "oxlint . --fix && oxfmt src test",
2827
"prepack": "pnpm run build",
2928
"release": "pnpm test && pnpm build && changelogen --release && npm publish && git push --follow-tags",
30-
"test": "pnpm lint && pnpm test:types && vitest run --coverage",
31-
"test:types": "tsgo --noEmit"
29+
"test": "pnpm lint && pnpm typecheck && vitest run --coverage",
30+
"typecheck": "tsgo --noEmit"
3231
},
3332
"devDependencies": {
3433
"@types/async": "^3.2.25",
3534
"@types/concat-stream": "^2.0.3",
3635
"@types/express": "^5.0.6",
3736
"@types/node": "^25.2.3",
37+
"@types/semver": "^7.7.1",
3838
"@types/sse": "^0.0.0",
3939
"@types/ws": "^8.18.1",
4040
"@typescript/native-preview": "^7.0.0-dev.20260210.1",
@@ -44,8 +44,6 @@
4444
"concat-stream": "^2.0.0",
4545
"eslint-config-unjs": "^0.6.2",
4646
"expect.js": "^0.3.1",
47-
"jiti": "^2.6.1",
48-
"listhen": "^1.9.0",
4947
"ofetch": "^1.5.1",
5048
"oxfmt": "^0.31.0",
5149
"oxlint": "^1.46.0",

‎playground/index.ts‎

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,39 @@
1-
import { listen } from "listhen";
2-
import { createProxyServer } from "../src";
1+
import http from "node:http";
2+
import { createProxyServer } from "../src/index.ts";
33

44
async function main() {
5-
const main = await listen(
6-
(req, res) => {
7-
res.end(
8-
JSON.stringify({
9-
method: req.method,
10-
path: req.url,
11-
headers: req.headers,
12-
}),
13-
);
14-
},
15-
{ port: 3000, name: "main" },
16-
);
5+
const main = http.createServer((req, res) => {
6+
res.end(
7+
JSON.stringify({
8+
method: req.method,
9+
path: req.url,
10+
headers: req.headers,
11+
}),
12+
);
13+
});
14+
await new Promise<void>((resolve) => {
15+
main.listen(3000, "127.0.0.1", resolve);
16+
});
1717

1818
const httpProxy = createProxyServer();
1919

20-
await listen(
21-
async (req, res) => {
22-
try {
23-
await httpProxy.web(req, res, {
24-
target: main.url,
25-
});
26-
} catch (error) {
27-
console.error(error);
28-
res.statusCode = 500;
29-
res.end("Proxy error: " + error.toString());
30-
}
31-
},
32-
{ port: 3001, name: "proxy" },
33-
);
20+
const proxy = http.createServer(async (req, res) => {
21+
try {
22+
await httpProxy.web(req, res, {
23+
target: "http://127.0.0.1:3000",
24+
});
25+
} catch (error) {
26+
console.error(error);
27+
res.statusCode = 500;
28+
res.end("Proxy error: " + (error as Error).toString());
29+
}
30+
});
31+
await new Promise<void>((resolve) => {
32+
proxy.listen(3001, "127.0.0.1", resolve);
33+
});
34+
35+
console.log("main: http://127.0.0.1:3000");
36+
console.log("proxy: http://127.0.0.1:3001");
3437
}
3538

3639
// eslint-disable-next-line unicorn/prefer-top-level-await

0 commit comments

Comments
 (0)