This is the definitive, professional-grade version of the cross-platform JavaScript runtime. It has been significantly re-architected to support the advanced, high-performance features required by real-world servers.
-
Dynamic TLS Certificates (SNI): The TLS server now supports a
certificateResolvercallback. During the TLS handshake, your JavaScript function is called with the client's requested server name (SNI), allowing you to dynamically provide the correct pre-parsed{ key, cert }handles for any domain. -
Full DNS Resolver: The
dnsmodule is no longer limited to basic lookups. It now usesuv_dns_queryto resolve any DNS record type (A, AAAA, MX, TXT, SRV, CNAME, etc.). -
Stateful File Descriptor API: The
fsmodule now supports a complete, handle-based API. You canfs.open()a file to get a file descriptor (FileHandle) and then perform stateful operations likefs.read(),fs.write(),fs.fstat(),fs.fsync(), andfs.close()on that handle. -
Robust Handle Management: A central C++
HandleStoremanages the lifecycle of all I/O objects (files, TCP sockets, TLS sockets, TLS contexts, keys, certs). A JavaScriptFinalizationRegistryautomatically cleans up C++ resources when JS objects are garbage collected.
You need development libraries for V8, libuv, and OpenSSL, plus standard build tools.
- Open MSYS2 MINGW64 shell.
- Install toolchain and dependencies:
pacman -S \ mingw-w64-x86_64-toolchain \ mingw-w64-x86_64-cmake \ mingw-w64-x86_64-ninja \ mingw-w64-x86_64-pkg-config \ mingw-w64-x86_64-v8 \ mingw-w64-x86_64-libuv \ mingw-w64-x86_64-openssl
- V8 headers and libs are under
/mingw64. The build usesV8_DIRto locate them.
sudo apt-get update
sudo apt-get install -y \
build-essential cmake ninja-build pkg-config \
libuv1-dev libssl-dev
# V8: install from your distro or custom build; set V8_DIR accordinglyapk add --no-cache \
build-base cmake ninja pkgconfig \
libuv-dev openssl-dev
# V8: install from community repo or custom build; set V8_DIR accordingly- The CMake project uses
V8_DIRto locate V8 headers and libraries. - By default,
CMakeLists.txtsets:set(V8_DIR "/mingw64") - You can override in your shell:
export V8_DIR=/mingw64
From the project root:
rm -rf build && mkdir build && cd build
cmake ..
ninja # or: cmake --build . or: mingw32-makeMSYS_NO_PATHCONV=1 openssl req -x509 -newkey rsa:2048 -nodes -keyout a.key -out a.crt -days 365 -subj "/CN=a.example.com"
MSYS_NO_PATHCONV=1 openssl req -x509 -newkey rsa:2048 -nodes -keyout b.key -out b.crt -days 365 -subj "/CN=b.example.com"From the build directory:
./runtime ../main.js- Build system: C++20, CMake, Ninja/MinGW.
- Links against:
v8,v8_libbase,v8_libplatform,libuv,OpenSSL::SSL,OpenSSL::Crypto(plus Windows system libs).