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
Cryptoignis-helpersCryptographic hashinghash()
Dateignis-helpersDate/time manipulationdayjs, sleep(), isWeekday(), getDateTz(), hrTime()
JSXignisHTML/JSX responseshtmlContent(), htmlResponse()
Moduleignis-helpersModule validationvalidateModule()
Parseignis-helpersData type conversionint(), float(), toBoolean(), toCamel(), getNumberValue()
Performanceignis-helpersExecution timingexecuteWithPerformanceMeasure(), getPerformanceCheckpoint()
Promiseignis-helpersPromise helpersexecutePromiseWithLimit(), isPromiseLike(), getDeepProperty()
Requestignis-helpersHTTP utilitiesparseMultipartBody(), sanitizeFilename(), createContentDispositionHeader()
SchemaignisZod schema helpersjsonContent(), jsonResponse(), requiredString(), idParamsSchema()
StatusesignisStatus code constantsStatuses, CommonStatuses, UserStatuses, RoleStatuses

What's in This Section

Data Processing

  • Crypto - Simple, stateless cryptographic functions for hashing (SHA256 HMAC, MD5)
  • Parse - Functions for parsing and converting data types safely (integers, floats, booleans, camelCase, locale-aware numbers, 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

  • Date - Date and time manipulation functions built on dayjs with timezone support
  • 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

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 { hash, dayjs, sleep, int, float, toBoolean, getNumberValue } from '@venizia/ignis-helpers';

// Crypto
const md5Hash = hash('some text', { algorithm: 'MD5', outputType: 'hex' });

// Date
const now = dayjs();
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');
}

Related: Helpers Reference | Core Concepts Guide