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

@tumbaland/backend-core

v1.17.0

Published

Core shared functionality for Tumbaland backend services

Downloads

171

Readme

@tumbaland/backend-core

Core shared functionality for Tumbaland backend services.

Installation

npm install @tumbaland/backend-core

Usage

Basic Service Setup

import express from 'express';
import {
  logger,
  healthCheck,
  connectDB,
  requestLogger,
  errorHandler,
  correlationMiddleware
} from '@tumbaland/backend-core';

const app = express();

// Environment variables
process.env.SERVICE_NAME = 'my-service';
process.env.SERVICE_DESCRIPTION = 'My awesome service';

// Middleware
app.use(correlationMiddleware);
app.use(requestLogger);

// Routes
app.get('/health', healthCheck);

// Error handling (must be last)
app.use(errorHandler);

// Start server
connectDB()
  .then(() => {
    const PORT = process.env.PORT || 3000;
    app.listen(PORT, () => {
      logger.info(`🚀 Service running on port ${PORT}`);
    });
  })
  .catch((error) => {
    logger.error('Failed to start service:', error);
    process.exit(1);
  });

Using Authentication

import { authenticateToken } from '@tumbaland/backend-core';

app.get('/protected', authenticateToken, (req, res) => {
  const user = (req as any).user;
  res.json({ message: `Hello ${user.name}!` });
});

Structured Logging

import { logger } from '@tumbaland/backend-core';

// Different log levels
logger.error('Database connection failed', { error: err.message });
logger.warn('High memory usage detected', { usage: '85%' });
logger.info('User logged in', { userId: '123', ip: '192.168.1.1' });
logger.debug('Processing request', { correlationId: req.correlationId });

API Responses

import { sendSuccess, sendError } from '@tumbaland/backend-core';

app.get('/api/users', (req, res) => {
  // Success response
  sendSuccess(res, users, 'Users retrieved successfully');

  // Error response
  sendError(res, 'Failed to retrieve users', 500, 'Database error');
});

Environment Variables

  • NODE_ENV: development or production
  • SERVICE_NAME: Name of your service
  • SERVICE_DESCRIPTION: Description of your service
  • LOG_TO_FILE: Set to true to also log to files (development only)

Docker Logging

This library is optimized for Docker deployments:

  • Logs to stdout/stderr by default
  • Use structured JSON in production
  • Integrates with Docker logging drivers
  • Compatible with log aggregation tools (ELK, Loki, etc.)

Development vs Production

Development

  • Colored console output
  • Debug level logging
  • Human-readable format

Production

  • JSON structured logging
  • Info level and above
  • Optimized for log aggregation

📦 Releases & Versioning

This library is a real published npm package (@tumbaland/backend-core), versioned independently of the monorepo with standard-version and Conventional Commits. See the root README's "Commits & Releases" section for the full process and the reasoning behind it — summary: commit with conventional messages, then from this directory run npm run release (never hand-edit version and npm publish directly, or the package, changelog, and tags drift out of sync with each other). Tags for this package are scoped as backend-core-vX.Y.Z so they can't collide with frontend-core's, components', or the monorepo's own app-vX.Y.Z tags.


Contributing

  1. Make changes to source files in src/
  2. Run npm run build to compile TypeScript
  3. Test your changes
  4. Submit a pull request