npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@empe/base-app

v2.5.0

Published

A foundation package providing common utilities, error handling, middleware, and environment management for Empe applications. This package standardizes core functionality across services in the Empe ecosystem.

Readme

@empe/base-app

A foundation package providing common utilities, error handling, middleware, and environment management for Empe applications. This package standardizes core functionality across services in the Empe ecosystem.

Installation

npm install @empe/base-app
# or
yarn add @empe/base-app

Features

  • Environment Management: Utilities for accessing and validating environment variables
  • Error Handling: Standardized error classes and middleware
  • Request Validation: Middleware for validating request parameters using Joi
  • Logging: Integration with @empe/logger for consistent logging
  • Rate Limiting: Configurable rate limiting for API endpoints
  • Async Handling: Utilities for handling async Express routes

Usage

Environment Management

import { getHost, getPort, getNodeEnv } from '@empe/base-app/tools';

// Get environment variables with validation
const host = getHost(); // e.g., 'https://example.com'
const port = getPort(); // e.g., 3000
const nodeEnv = getNodeEnv(); // 'development', 'production', or 'test'

Logging

The base-app package provides a convenient wrapper around the @empe/logger package. The actual logger implementation is in the @empe/logger package, while base-app only provides a simplified createLogger function that injects environment variables:

// Implementation in base-app/tools/logger.ts
export const createLogger = (name: string) => createLoggerInstance(name, getNodeEnv(), getLogLevel(), getLogsDir());

This makes it easy to create a properly configured logger without manually handling environment variables:

import { createLogger } from '@empe/base-app/tools';

// Create a logger for your service
const logger = createLogger('MyService');

logger.info('Service starting');
logger.debug('Debug information', { userId: 123 });
logger.error('Error occurred', { error: new Error('Something went wrong') });

The logger automatically uses the appropriate environment variables (NODE_ENV, LOG_LEVEL, LOG_DIR) and applies consistent formatting across all services.

Error Handling

import { errorMiddleware } from '@empe/base-app/middlewares';
import { InvalidRequestError } from '@empe/base-app/errors';
import { createLogger } from '@empe/base-app/tools';

const logger = createLogger('MyService');
const app = express();

// Add routes
app.get('/resource/:id', (req, res) => {
    const { id } = req.params;
    if (!id) {
        throw new InvalidRequestError('ID is required');
    }
    // Process request
});

// Add error handling middleware
app.use(errorMiddleware(logger));

Request Validation

import { validateRequest } from '@empe/base-app/middlewares';
import Joi from 'joi';

const userSchema = Joi.object({
    name: Joi.string().required(),
    email: Joi.string().email().required(),
    age: Joi.number().integer().min(18).required(),
});

app.post('/users', validateRequest({ body: userSchema }), (req, res) => {
    // Request body is validated and typed
    const user = req.body;
    // Process user
    res.status(201).json(user);
});

Async Route Handling

import { asyncHandler } from '@empe/base-app/tools';

app.get(
    '/users/:id',
    asyncHandler(async (req, res) => {
        const user = await userService.findById(req.params.id);
        res.json(user);
        // No need for try/catch - errors are automatically passed to error middleware
    })
);

Rate Limiting

import { globalRateLimiter } from '@empe/base-app/middlewares';

// Apply rate limiting to all routes
app.use(globalRateLimiter);

// Or apply to specific routes
app.post('/login', globalRateLimiter, loginHandler);

Exports

The package provides the following export paths:

  • @empe/base-app/tools - Environment utilities, logger, and async handlers
  • @empe/base-app/errors - Error classes for different types of application errors
  • @empe/base-app/middlewares - Express middleware for validation, error handling, and rate limiting
  • @empe/base-app/schemas - Common Joi schemas for validation

License

MIT