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

@smooai/utils

v1.3.2

Published

A collection of shared utilities and tools used across SmooAI projects. This package provides common functionality to standardize and simplify development across all SmooAI repositories.

Downloads

426

Readme

About SmooAI

SmooAI is an AI-powered platform for helping businesses multiply their customer, employee, and developer experience.

Learn more on smoo.ai

SmooAI Packages

Check out other SmooAI packages at npmjs.com/org/smooai

About @smooai/utils

The foundation that eliminates boilerplate - Battle-tested utilities that handle the repetitive tasks so you can focus on building features, not infrastructure.

NPM Version NPM Downloads NPM Last Update

GitHub License GitHub Actions Workflow Status GitHub Repo stars

Why @smooai/utils?

Ever found yourself writing the same error handler for the 50th time? Debugging Lambda functions without proper request tracking? Wrestling with phone number validation that works everywhere except production? You're not alone.

We built @smooai/utils because we were tired of:

  • 🔁 Copy-pasting the same utility functions across projects
  • 🐛 Inconsistent error handling breaking production deploys
  • 🔍 Losing request context across AWS services
  • 📱 Phone numbers failing validation in different formats
  • 🗺️ HTTP headers losing their case-sensitivity battles
  • 🎯 Writing custom validators for every data type

Now, with one package, you get:

  • ✅ Production-tested utilities used across all SmooAI services
  • ✅ Type-safe implementations with full TypeScript support
  • ✅ AWS Lambda integration that just works
  • ✅ Human-readable error messages your team will thank you for
  • ✅ Zero configuration needed - sensible defaults out of the box

Install

pnpm add @smooai/utils

Real-World Solutions

🚀 Lambda Error Handling That Actually Works

Stop writing try-catch blocks in every Lambda function. Our battle-tested apiHandler does it all:

import { apiHandler } from '@smooai/utils';

// Before: Boilerplate everywhere
export const handler = async (event, context) => {
    try {
        // Parse body
        // Validate input
        // Handle errors
        // Format response
        // Log everything
    } catch (error) {
        // More error handling
    }
};

// After: Focus on your logic
export const handler = apiHandler(async (event, context) => {
    const user = await createUser(event.body);
    return { statusCode: 201, body: user };
});
// Automatic error handling, logging, and response formatting ✨

🎯 Validation With Human-Readable Errors

Your users (and your support team) deserve better than "ValidationError at path[0].nested.field":

import { handleSchemaValidation, HumanReadableSchemaError } from '@smooai/utils';

const userSchema = z.object({
    email: z.string().email(),
    phone: validateAndTransformPhoneNumber,
    age: z.number().min(18),
});

try {
    const user = handleSchemaValidation(userSchema, data);
    // user.phone is guaranteed to be E.164 format: +12125551234
} catch (error) {
    if (error instanceof HumanReadableSchemaError) {
        console.log(error.humanReadableMessage);
        // "Email must be a valid email address. Phone must be a valid phone number. Age must be at least 18."
    }
}

🔍 Case-Insensitive Collections for HTTP Headers

Because Content-Type, content-type, and CONTENT-TYPE should all just work:

import { CaseInsensitiveMap } from '@smooai/utils';

const headers = new CaseInsensitiveMap([
    ['Content-Type', 'application/json'],
    ['X-API-KEY', 'secret'],
]);

headers.get('content-type'); // 'application/json' ✅
headers.has('X-Api-Key'); // true ✅
headers.get('CONTENT-TYPE'); // 'application/json' ✅

🏭 Production-Ready Hono Apps for Lambda

Set up a fully-configured API with one line:

import { createAwsLambdaHonoApp } from '@smooai/utils';

const app = createAwsLambdaHonoApp();

app.get('/health', (c) => c.json({ status: 'healthy' }));

app.post('/users', async (c) => {
    // Automatic request ID tracking
    // Built-in error handling
    // Pretty JSON in development
    const user = await createUser(await c.req.json());
    return c.json(user, 201);
});

export const handler = handle(app);

📁 Smart File Discovery

Find configuration files without hardcoding paths:

import { findFile } from '@smooai/utils';

// Searches up the directory tree until it finds the file
const configPath = await findFile('smoo.config.json');
const packageJson = await findFile('package.json');

// Perfect for:
// - Finding project root
// - Loading environment-specific configs
// - Locating test fixtures

🌍 Environment Detection Made Simple

import { isRunningInProd, isRunningLocally } from '@smooai/utils';

if (isRunningLocally()) {
    // Enable debug logging
    // Use local database
    // Show detailed errors
}

if (isRunningInProd()) {
    // Use production services
    // Enable monitoring
    // Sanitize error messages
}

More Powerful Examples

🛡️ Type-Safe Error Handling

Transform cryptic errors into actionable messages:

import { ApiError, errorHandler } from '@smooai/utils';

const processPayment = errorHandler(
    async (orderId: string) => {
        // Throws ApiError with 404 status
        if (!order) throw new ApiError('Order not found', 404);

        // Validation errors become 400s with details
        const validated = handleSchemaValidation(schema, data);

        // Unexpected errors are logged and sanitized
        return await chargeCard(order);
    },
    {
        logger: console,
        onError: (error) => notifyOps(error),
    },
);

⏱️ Smart Async Utilities

import { sleep } from '@smooai/utils';

// Rate limiting made easy
for (const batch of batches) {
    await processBatch(batch);
    await sleep(1000); // Wait 1 second between batches
}

// Retry with exponential backoff
async function retryWithBackoff(fn, attempts = 3) {
    for (let i = 0; i < attempts; i++) {
        try {
            return await fn();
        } catch (error) {
            if (i === attempts - 1) throw error;
            await sleep(Math.pow(2, i) * 1000);
        }
    }
}

📞 Phone Number Validation That Works Globally

import { validateAndTransformPhoneNumber } from '@smooai/utils';

// Accepts multiple formats, outputs E.164
const phoneSchema = z.object({
    phone: validateAndTransformPhoneNumber,
});

phoneSchema.parse({ phone: '(212) 555-1234' });
// ✅ { phone: '+12125551234' }

phoneSchema.parse({ phone: '+44 20 7946 0958' });
// ✅ { phone: '+442079460958' }

phoneSchema.parse({ phone: '555-1234' });
// ❌ Throws: "Phone must be a valid phone number"

Built for Production

Every utility in this package is:

  • 🔒 Type-safe - Full TypeScript support with strict types
  • Performance tested - Optimized for real-world usage
  • 📊 Battle-tested - Used in production at SmooAI
  • 📚 Well-documented - Clear examples and use cases
  • 🔄 Maintained - Regular updates and improvements

Testing

pnpm test

Linting

pnpm lint

Contributing

We're currently developing our contribution processes. If you're interested in contributing to this package or have questions, please reach out to us through the contact information below.

Contact

Brent Rager

Smoo Github: https://github.com/SmooAI