This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The satisfies operator, introduced in TS 4.9, enforces | |
a constraint on a value without changing the inferred | |
type. It's super useful when you want to keep the most | |
specific type that can be inferred. | |
*/ | |
type Data = { | |
value: number | string; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const http = require("http"); | |
const esbuild = require("esbuild"); | |
const serve = async (servedir, listen) => { | |
// Start esbuild's local web server. Random port will be chosen by esbuild. | |
const { host, port } = await esbuild.serve({ servedir }, {}); | |
// Create a second (proxy) server that will forward requests to esbuild. | |
const proxy = http.createServer((req, res) => { | |
// forwardRequest forwards an http request through to esbuid. |