Skip to content

Instantly share code, notes, and snippets.

View FredKSchott's full-sized avatar

Fred K. Schott FredKSchott

View GitHub Profile
@FredKSchott
FredKSchott / als.mjs
Created February 22, 2023 22:03 — forked from cyco130/als.mjs
AsyncLocalStorage-based Node server framework
import { createServer } from "node:http";
import { AsyncLocalStorage } from "node:async_hooks";
const asyncLocalStorage = new AsyncLocalStorage();
createServer((req, res) => {
asyncLocalStorage.run({ req, res }, () => {
asyncHandler().catch((err) => {
console.error(err);
if (!res.writableEnded) {