@jaypie/core
Foundation package providing errors, logging, validation, and HTTP utilities.
Overview
Section titled “Overview”@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
Installation
Section titled “Installation”npm install @jaypie/coreKey Features
Section titled “Key Features”Handler Lifecycle
Section titled “Handler Lifecycle”The core package provides jaypieHandler, which manages a four-phase lifecycle:
- Validate - Request validation
- Setup - Resource initialization
- Handler - Business logic
- Teardown - Cleanup (always runs)
Logging
Section titled “Logging”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 });Validation
Section titled “Validation”Type validation utilities:
import { validate } from "@jaypie/core";
validate.string(value);validate.array(value);validate.optional.number(value);Error Handling
Section titled “Error Handling”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
Section titled “API Documentation”API documentation will be generated from TypeScript definitions.
Related Packages
Section titled “Related Packages”- @jaypie/express - Express.js integration
- @jaypie/lambda - AWS Lambda integration
- @jaypie/errors - Error class definitions