Skip to content

Utilities ​

Pure, standalone functions providing common, reusable logic for the IGNIS framework. All utilities are stateless and easy to use.

Quick Reference ​

UtilityPackagePurposeKey Functions
Durationignis-helpersDuration units and conversionDurationUnits, DurationMultipliers.toMilliseconds(), .parseToMilliseconds()
JSXignisHTML/JSX responseshtmlContent(), htmlResponse()
Moduleignis-helpersOptional peer loadingModuleUtility
Parseignis-helpersData type conversionint(), float(), toBoolean(), toCamel()
Performanceignis-helpersExecution timingexecuteWithPerformanceMeasure(), getPerformanceCheckpoint()
Promiseignis-helpersPromise helpersexecutePromiseWithLimit(), isPromiseLike(), getDeepProperty()
Requestignis-helpersHTTP utilitiesparseMultipartBody(), sanitizeFilename(), createContentDispositionHeader()
Retryignis-helpersBackoff-driven retriesRetryHelper
SchemaignisZod schema helpersjsonContent(), jsonResponse(), requiredString(), idParamsSchema()
StatusesignisStatus code constantsStatuses, CommonStatuses, UserStatuses, RoleStatuses
Timingignis-helpersPause and measuresleep(), hrTime()

Calendar dates - parsing, formatting, adding a month in a time zone - live in TemporalHelper.

What's in This Section ​

Data Processing ​

  • Parse - Functions for parsing and converting data types safely (integers, floats, booleans, camelCase, array-to-map)
  • Schema - Helpers for creating Zod schemas for OpenAPI request/response validation
  • Statuses - Standardized status code constants for entity lifecycle management

Time & Performance ​

  • Timing - sleep() to pause, hrTime() to read a high-resolution clock
  • Duration - A unit vocabulary, written-duration parsing, and conversion between units and milliseconds
  • Performance - Utilities for measuring code execution time and performance profiling

Async & HTTP ​

  • JSX - HTML and JSX response utilities for server-side rendering and OpenAPI documentation
  • Promise - Helper functions for working with Promises including concurrency limiting and value transformation
  • Request - HTTP request utilities for parsing multipart form data and creating secure Content-Disposition headers
  • Retry - Backoff-driven retry helpers on RetryHelper - error-triggered (executeWithRetry) and predicate-driven (executeWithRetryUntil)

Runtime ​

  • Module - Utility for validating that required Node.js modules are installed at runtime

Usage Pattern ​

Utilities are imported from @venizia/ignis (schema, JSX, and status helpers) or @venizia/ignis-helpers (runtime utilities):

typescript
import { jsonContent, jsonResponse, htmlResponse, requiredString, Statuses } from '@venizia/ignis';
import { sleep, int, float, toBoolean } from '@venizia/ignis-helpers';

// Timing
await sleep(1000);

// Parse
const myInt = int('1,000'); // 1000
const myFloat = float('1,234.567', 2); // 1234.57
const myBool = toBoolean('true'); // true

// Schema (for OpenAPI JSON routes)
const responseSchema = jsonResponse({
  description: 'User data',
  schema: z.object({ id: z.string(), name: z.string() }),
});

// JSX (for HTML routes)
const htmlResponseSchema = htmlResponse({
  description: 'Dashboard page',
});

// Statuses
const order = { status: Statuses.COMPLETED };
if (Statuses.isCompleted(order.status)) {
  console.log('Order is complete');
}

Timing ​

Two small functions with no page of their own. Both ship from the root of @venizia/ignis-helpers.

FunctionSignatureWhat it does
sleepsleep(ms: number): Promise<unknown>Resolves after ms milliseconds, through setTimeout
hrTimehrTime(): numberSeconds from process.hrtime(), to nine decimals - for measuring, not for dates. Node and Bun only
typescript
import { hrTime, sleep } from '@venizia/ignis-helpers';

const startedAt = hrTime();
await sleep(250);
const elapsedSeconds = hrTime() - startedAt; // about 0.25

Files:

Related: Helpers Reference | Core Concepts Guide