This project is a WebSocket tunneling library that currently uses Deno-specific APIs. The migration will focus on replacing Deno APIs with Node.js equivalents while maintaining the same functionality.
- Remove Deno-specific scripts (
deno test,deno fmt, etc.) - Add Node.js scripts (
npm test,npm run build, etc.) - Add required Node.js dependencies:
ws,undici,@types/ws - Update existing devDependencies as needed
- Replace
import denoJSON from "./deno.json" assert { type: "json" }; - Use
fs.readFileSync+JSON.parseto read package.json version - Update version reference from
denoJSON.versionto package.json version
- Replace
Deno.serve()with Node.jshttp.createServer() - Update
serve()function return type fromDeno.HttpServer<Deno.NetAddr> - Maintain same handler interface for compatibility
- Replace
Deno.upgradeWebSocket(req)withwslibrary WebSocket upgrade - Update
upgradeWebSocket()function to use Node.js WebSocket implementation - Maintain same return interface
{ socket: WebSocket; response: Response }
- Replace
Deno.createHttpClient()withundicior native fetch - Update client HTTP requests to use Node.js APIs
- Maintain same configuration options
- Replace Deno Worker API with Node.js
worker_threads - Update worker permissions and message passing
- Maintain same interface for service worker functionality
- Create
tsconfig.jsonfor TypeScript compilation - Configure ESM module resolution
- Set up proper Node.js target and lib settings
- Add
.jsextensions to relative imports for Node.js ESM compatibility - Ensure all imports work with Node.js module resolution
- Update any dynamic imports if needed
- Delete
deno.json - Delete
deno.lock - Clean up any Deno-specific configuration
| Deno API | Node.js Replacement |
|---|---|
Deno.serve() |
http.createServer() |
Deno.upgradeWebSocket() |
ws library |
Deno.createHttpClient() |
undici or native fetch |
import ... assert { type: "json" } |
fs.readFileSync() + JSON.parse() |
| Deno Worker API | worker_threads |
- Focus on functionality first, tests will be handled later
- Maintain existing TypeScript interfaces and public API
- Keep Cloudflare Workers compatibility (DurableObject class)
- Preserve WebSocket tunneling functionality
- Runtime detection should still work for different environments