Skip to content

@jaypie/core

Foundation package providing errors, logging, validation, and HTTP utilities.

@jaypie/core is the foundational package of the Jaypie library. It provides essential utilities for:

  • Error handling and custom error classes
  • Structured JSON logging
  • Request/response validation
  • HTTP utilities and constants
  • Handler lifecycle management
Terminal window
npm install @jaypie/core

The core package provides jaypieHandler, which manages a four-phase lifecycle:

  1. Validate - Request validation
  2. Setup - Resource initialization
  3. Handler - Business logic
  4. Teardown - Cleanup (always runs)

Structured JSON logger with multiple log levels:

import { log } from "@jaypie/core";
log.info("Application started");
log.error("An error occurred", { error });
log.debug("Debug information", { data });

Type validation utilities:

import { validate } from "@jaypie/core";
validate.string(value);
validate.array(value);
validate.optional.number(value);

Custom error classes for common HTTP status codes:

import { BadRequestError, NotFoundError } from "@jaypie/core";
throw new BadRequestError("Invalid input");
throw new NotFoundError("Resource not found");

API documentation will be generated from TypeScript definitions.