@jaypie/express
Express.js handlers, CORS, and route utilities.
Overview
Section titled âOverviewâ@jaypie/express provides Express.js integration for the Jaypie library, including:
- Express handler wrapper with lifecycle management
- CORS configuration
- Route utilities
- Request/response helpers
Installation
Section titled âInstallationânpm install @jaypie/expressKey Features
Section titled âKey FeaturesâExpress Handler
Section titled âExpress HandlerâWraps Express.js routes with Jaypieâs handler lifecycle:
import { expressHandler } from "@jaypie/express";
app.get("/api/users", expressHandler(async (req, res) => { // Handler logic return { users: [] };}));Lifecycle Phases
Section titled âLifecycle PhasesâThe expressHandler extends the base handler lifecycle with an additional locals phase:
- Validate - Request validation
- Locals - Populate
req.localswith static values or function results - Setup - Resource initialization
- Handler - Business logic
- Teardown - Cleanup (always runs)
CORS Support
Section titled âCORS SupportâBuilt-in CORS configuration for Express applications.
Supertest Integration
Section titled âSupertest IntegrationâSupports testing mode for use with supertest:
import { mock } from "@jaypie/testkit";import request from "supertest";
const app = mock.expressHandler(handler);await request(app).get("/api/users").expect(200);API Documentation
Section titled âAPI DocumentationâAPI documentation will be generated from TypeScript definitions.
Related Packages
Section titled âRelated Packagesâ- @jaypie/core - Core utilities
- @jaypie/lambda - AWS Lambda integration
- @jaypie/testkit - Testing utilities