Prerequisites
Before installing StatusFlow, ensure you have:- Node.js - Version 14 or higher
- Express - Version 4 or 5 (peer dependency)
- TypeScript (optional) - Version 4.5 or higher for TypeScript projects
Install StatusFlow
Install StatusFlow using your preferred package manager:Install Express (Peer Dependency)
If you don’t already have Express installed, you’ll need to add it:TypeScript Setup
StatusFlow is written in TypeScript and includes type definitions out of the box. If you’re using TypeScript, follow these steps:Configure tsconfig.json
Ensure your
tsconfig.json has the following settings:tsconfig.json
The
resolveJsonModule option is important because StatusFlow uses JSON data files for HTTP status information.JavaScript Setup
For JavaScript projects, no additional configuration is needed:Verify Installation
Create a simple test file to verify StatusFlow is working correctly:Package Exports
StatusFlow provides the following exports:| Export | Type | Description |
|---|---|---|
StatusFlow | Function | Generate status responses with bilingual support |
StatusFlowCodes | Object | Constants for all HTTP status codes |
statusFlowMiddleware | Function | Express middleware for StatusFlow error handling |
httpErrorMiddleware | Function | Express middleware for exception-based error handling |
HttpException | Class | Base exception class |
BadRequestException | Class | 400 Bad Request exception |
UnauthorizedException | Class | 401 Unauthorized exception |
ForbiddenException | Class | 403 Forbidden exception |
NotFoundException | Class | 404 Not Found exception |
ConflictException | Class | 409 Conflict exception |
InternalServerErrorException | Class | 500 Internal Server Error exception |
createHttpResponse | Function | Create response from HttpException |
createSuccessResponse | Function | Create success response with data |
Common Installation Issues
Next Steps
Quick Start Guide
Learn how to build a complete Express API with StatusFlow