The standard library Node.js deserves
Logging, config, validation, HTTP, SQLite, dates, crypto, CLI tools and 500+ helpers. One package, zero dependencies, documented right in your editor.
const nc = require("@ix-xs/node-comfort");
// Checked at startup: every problem is reported at once
const config = nc.env.validate({
PORT: { type: "port", default: 3000 },
DATABASE_URL: { type: "url" },
CACHE_TTL: { type: "duration", default: "5m" },
});
nc.info(`Listening on port ${config.PORT}`);
nc.log("<% green bold ✔ Ready %> in <% dim 42ms %>");const api = nc.http.create({
baseURL: "https://api.example.com/v1/",
auth: { bearer: process.env.API_TOKEN },
timeout: "10s",
retry: { attempts: 3 }, // honours Retry-After
});
const users = new nc.Cache({ max: 1000, ttl: "5m" });
const user = await users.getOrSet(id, async () => (await api.get(`users/${id}`)).data);const { schema: s } = nc;
const User = s.object({
email: s.string().trim().email(),
age: s.number().int().min(18).optional(),
role: s.enum(["admin", "user"]).default("user"),
});
const result = User.safeParse(req.body);
if (!result.success) return res.status(400).json(result.error.flatten());const db = new nc.SQLite("data/app.sqlite");
db.insert("users", { email: "ada@example.com", settings: { theme: "dark" } });
const admins = db.getAll("users", {
role: ["admin", "owner"],
created_at: { gte: nc.time.subtract(new Date(), 30, "days") },
}, { orderBy: "email", limit: 20 });Why node-comfort
Most projects install the same twenty packages, and hundreds of dependencies with them. Node.js can do most of it on its own now. This is the missing layer on top.
Nothing else to install
Built only on Node's own modules: fetch, Intl, node:crypto, node:sqlite. No dependencies, no install scripts, nothing else to audit.
Your editor already knows
Every function, parameter and option is documented and typed. Hover, completion and type checks work in JavaScript and TypeScript.
Loads in about 3 ms
Namespaces load the first time you use them. A script that only logs never loads the database or the HTTP client.
Safe by default
Prototype-pollution-proof objects, scrypt passwords, AES-256-GCM, constant-time comparisons, parameterized SQL, atomic file writes.
Speaks every language
Dates, durations, numbers, currencies and plurals in any language and time zone, through the Intl data Node already ships.
One consistent API
Durations are always "5m" or milliseconds, options always come last, and every error carries a stable code you can check.
Everything in one import
23 namespaces, each with a guide and a full reference.
nc.loggerA console logger that works with zero setup: levels, colors, a small markup for styling,...
nc.fsFiles and folders without try/catch: read and write text or JSON (atomically), copy, move,...
nc.checkerType checks and validators. Every isX accepts anything and never throws, and most of them are...
nc.envEnvironment variables you can trust: .env loading, typed getters, and validate() to check your...
nc.errorsThe errors node-comfort throws. They all extend NodeComfortError (itself a regular Error) and...
nc.utilsEveryday helpers: wait, when, dontCrash, and JSON functions that don't throw. They are also...
nc.strString helpers: case conversion, slugs, truncation, templates, wrapping, fuzzy matching,...
nc.numNumbers: clamping, rounding that gets decimals right, statistics, and formatting for humans...
nc.arrArray helpers. None of them mutate what you pass in, and item types carry through...
nc.objObject helpers: deep clone, merge, equality, diff, typed dot paths, pick and omit. Inputs are...
nc.timeDates and durations: formatting, relative time, calendar math, time zones and scheduling, in...
nc.idUnique ids: UUID v4 and v7, ULID, nanoid-style ids, Snowflakes, tokens and short codes. All of...
nc.schemaValidate data with schemas, in the spirit of zod. Describe your data once and get both a...
nc.funcFunction helpers: debounce, throttle, memoize, retry with backoff, timeouts, error handling...
nc.asyncPromises and concurrency: map with a limit, queues with priorities, mutexes, polling, and...
CacheAn in-memory cache with a size limit (the least recently used entries go first), expiry per...
EmitterA small typed event emitter. Declare your events once, and your editor checks every event name...
nc.httpAn HTTP client on top of fetch: JSON by default, query objects, base URLs, timeouts, safe...
SQLiteSQLite made pleasant, on the engine built into Node.js (22.13+): CRUD with rich filters, JSON...
nc.cliWhat you need for command-line tools: typed arguments with a generated --help, prompts,...
nc.colorTerminal colors you can chain, like chalk. Truecolor is supported and downgraded on older...
nc.sysProcesses and the system: run commands and get their output, find executables, shut down...
nc.cryptoCrypto without the footguns, built on node:crypto: hashes, HMAC, password hashing (scrypt),...
Try it in two minutes
Install it, require it, and type nc. in your editor.