@eloritzkovitz/server-essentials
    Preparing search index...

    @eloritzkovitz/server-essentials

    Server Essentials

    A collection of reusable utilities, middleware, and services for Node.js server projects.
    This package helps you quickly add common server functionality such as authentication, messaging, file handling, logging, and more.

    • JWT authentication middleware
    • Role-based authorization
    • OTP generation and email delivery
    • Token management and refresh token verification
    • Request helpers
    • Centralized config loader with environment variable support
    • File upload middleware for Express
    • File handling helpers
    • Date formatting and manipulation
    • Number formatting and manipulation
    • String formatting and manipulation
    • Helpers for masking emails/phones and formatting IDs/codes
    • Proxy middleware for API gateway scenarios
    • Winston-based logger with environment-aware configuration
    • Colorized console and file logs in development
    • JSON console logs in production/Docker
    • HTTP request logging middleware
    • Log helpers for error handling, request tracing, and masking sensitive data
    • RabbitMQ service for notifications and RPC
    • Firebase Cloud Messaging sender
    • Health check, ping, and API info endpoints
    • Input validation helpers (email, phone, password, etc.)
    npm install @eloritzkovitz/server-essentials
    

    Import what you need from the package.

    Set required environment variables in your .env file:

    # RabbitMQ
    RABBITMQ_URL=amqp://localhost
    
    # SMTP for OTP
    SMTP_HOST=smtp.example.com
    SMTP_PORT=465
    SMTP_USER=your@email.com
    SMTP_PASS=yourpassword
    SMTP_FROM=your@email.com
    
    # JWT
    TOKEN_SECRET=your_jwt_secret
    
    # Firebase Messaging
    GOOGLE_APPLICATION_CREDENTIALS=path/to/serviceAccount.json
    

    Run all tests and view coverage reports using Jest:

    npm test
    npx jest --coverage

    The coverage report will be generated in the coverage/ folder (which is gitignored by default).

    You can add or run tests for any module in the test/ directory.
    Tests are organized to match the source code structure for easy maintenance.

    Full API documentation is available in the docs folder and can be viewed online via GitHub Pages.

    MIT