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

UtilityPurposeKey Functions
CryptoCryptographic operationshash(), compare(), encrypt(), decrypt()
DateDate/time manipulationformat(), parse(), diff(), add()
JSXHTML/JSX responseshtmlContent(), htmlResponse()
ModuleModule detectionisInstalled(), resolve()
ParseData type conversiontoBoolean(), toNumber(), toArray()
PerformanceExecution timingmeasure(), measureAsync()
PromisePromise helpersdelay(), timeout(), retry()
RequestHTTP utilitiesparseMultipart(), contentDisposition()
SchemaZod schema helpersjsonContent(), jsonResponse()
StatusesStatus code constantsStatuses, UserStatuses, CommonStatuses

What's in This Section

Data Processing

  • Crypto - Simple, stateless cryptographic functions for hashing, comparison, and encryption/decryption operations
  • Parse - Functions for parsing and converting data types safely with proper type inference
  • Schema - Helpers for creating and validating Zod schemas, especially 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 retry, timeout, and delay
  • Request - HTTP request utilities for parsing multipart form data and creating secure Content-Disposition headers

Runtime

  • Module - Utility for checking if a Node.js module is installed at runtime

Usage Pattern

All utilities are imported from @venizia/ignis:

typescript
import {
  hash,
  compare,
  formatDate,
  toBoolean,
  jsonContent,
  jsonResponse,
  htmlResponse,
  Statuses,
} from '@venizia/ignis';

// Crypto
const hashed = await hash({ value: 'password123' });
const isMatch = await compare({ value: 'password123', hashed });

// Date
const formatted = formatDate({ date: new Date(), format: 'YYYY-MM-DD' });

// Parse
const boolValue = 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