Websocket : how to forward traffic in Node.js

Many solutions exist to serve remote content on proxies : webpack-dev-server, next.js, http-proxy, or just my own local-traffic.While these solutions offer an efficient way to route http traffic, they sometimes have support for websocket, which correspond to a different protocol (tcp messages but not exactly http) The client only sends a http request once, then… Read More »

jest : how to cheat with time

Of course I could spend some time mirroring the jest docsite, even though the description is comprehensive and the examples are relevant. (https://jestjs.io/docs/timer-mocks) jest.useFakeTimers(); jest.spyOn(global, 'setTimeout'); Once you have this code, you can freeze the time and execute tasks that should have been deferred to later in real conditionsYou can even advance in time by… Read More »

Use typescript … while exporting “.mjs” modules

Typescript offers great safety against data corruption, it verifies every part of the data flow in your app and compares it against the libraries signature.If anything seems wrong, it asks you to double check at compile time.Ecmascript modules is probably the convergence of frontend and backend javascript : it is seamless across different environments and… Read More »

jscodeshift, run programmatically

jscodeshift is a great tool for running migrations on frontend codebase. It saves days of team syncup, cross team collaboration and prioritization,my team is looking at building a tool to automatically upgrade applications that consume our libraries, instead of giving an upgrade doc and deadlines.the jscodeshift is a command line interface and works the same… Read More »

WebAssembly in javascript : load and run with ease

WebAssembly libraries looks like unicorns in the sky, but they need to be prepared to be used efficiently ;most of the time, you start by naively pass values in functions before realizing that only pointers are read. const webAssemblyModule = await WebAssembly.compile(wasmData);const instance = await WebAssembly.instantiate(webAssemblyModule,{env: {memory: newMemory}, exports: { memory: newMemory }});instance.exports.foo("bar"); // but… Read More »