An open API service indexing awesome lists of open source software.

https://github.com/smooai/utils

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.
https://github.com/smooai/utils

utilities

Last synced: about 1 year ago
JSON representation

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.

Awesome Lists containing this project

README

          





SmooAI Logo

## About SmooAI

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

Learn more on [smoo.ai](https://smoo.ai)

## SmooAI Packages

Check out other SmooAI packages at [npmjs.com/org/smooai](https://www.npmjs.com/org/smooai)

## About @smooai/utils

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.

![NPM Version](https://img.shields.io/npm/v/%40smooai%2Futils?style=for-the-badge)
![NPM Downloads](https://img.shields.io/npm/dw/%40smooai%2Futils?style=for-the-badge)
![NPM Last Update](https://img.shields.io/npm/last-update/%40smooai%2Futils?style=for-the-badge)

![GitHub License](https://img.shields.io/github/license/SmooAI/utils?style=for-the-badge)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/SmooAI/utils/release.yml?style=for-the-badge)
![GitHub Repo stars](https://img.shields.io/github/stars/SmooAI/utils?style=for-the-badge)

### Installation

```sh
pnpm add @smooai/utils
```

### Available Utilities

#### API Handling

- `ApiError` - Custom error class for handling API-specific errors with status codes
- `apiHandler` - Lambda function wrapper for standardized API error handling and responses
- `createAwsLambdaHonoApp` - Factory for creating Hono apps configured for AWS Lambda

#### Collections

- `CaseInsensitiveMap` - Map implementation with case-insensitive string keys
- `CaseInsensitiveSet` - Set implementation with case-insensitive string values

#### Error Handling

- `errorHandler` - Generic error handler with logging and type-specific error processing

#### File Operations

- `findFile` - Async utility to find files in parent directories
- `findFileSync` - Synchronous version of findFile

#### Environment

- `isRunningLocally` - Check if code is running in local development
- `isRunningInProd` - Check if code is running in production

#### Data Validation

- `validateAndTransformPhoneNumber` - Zod validator for phone numbers with E.164 formatting

#### Utilities

- `sleep` - Promise-based delay function

### Features

- AWS Lambda integration
- Standardized error handling
- Case-insensitive collections
- File system utilities
- Environment detection
- Data validation tools
- HTTP request handling with Hono

(back to top)

### Testing

```sh
pnpm test
```

### Linting

```sh
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 - [Email](mailto:brent@smoo.ai)
[Instagram](https://www.instagram.com/brentragertech/)
[LinkedIn](https://www.linkedin.com/in/brentrager/)
[Threads](https://www.threads.net/@brentragertech)

Smoo Github: [https://github.com/SmooAI](https://github.com/SmooAI)

(back to top)

[sst.dev-url]: https://reactjs.org/
[sst]: https://img.shields.io/badge/sst-EDE1DA?style=for-the-badge&logo=sst&logoColor=E27152
[sst-url]: https://sst.dev/
[next]: https://img.shields.io/badge/next.js-000000?style=for-the-badge&logo=nextdotjs&logoColor=white
[next-url]: https://nextjs.org/
[aws]: https://img.shields.io/badge/aws-232F3E?style=for-the-badge&logo=amazonaws&logoColor=white
[aws-url]: https://tailwindcss.com/
[tailwindcss]: https://img.shields.io/badge/tailwind%20css-0B1120?style=for-the-badge&logo=tailwindcss&logoColor=#06B6D4
[tailwindcss-url]: https://tailwindcss.com/
[zod]: https://img.shields.io/badge/zod-3E67B1?style=for-the-badge&logoColor=3E67B1
[zod-url]: https://zod.dev/
[sanity]: https://img.shields.io/badge/sanity-F36458?style=for-the-badge
[sanity-url]: https://www.sanity.io/
[vitest]: https://img.shields.io/badge/vitest-1E1E20?style=for-the-badge&logo=vitest&logoColor=#6E9F18
[vitest-url]: https://vitest.dev/
[pnpm]: https://img.shields.io/badge/pnpm-F69220?style=for-the-badge&logo=pnpm&logoColor=white
[pnpm-url]: https://pnpm.io/
[turborepo]: https://img.shields.io/badge/turborepo-000000?style=for-the-badge&logo=turborepo&logoColor=#EF4444
[turborepo-url]: https://turbo.build/