mirror of
https://github.com/hatchet-dev/hatchet.git
synced 2025-12-30 13:19:44 -06:00
* api changes * doc changes * move docs * generated * generate * pkg * backmerge main * revert to main * revert main * race? * remove go tests
Snips Library
A TypeScript utility library for use within the Hatchet monorepo.
Installation
This package is intended for internal use within the Hatchet monorepo. You can add it to your project by adding it as a dependency in your package.json:
{
"dependencies": {
"@hatchet/snips": "workspace:*"
}
}
Usage
import { createClient, wrapResult } from '@hatchet/snips';
// Create a configured client
const client = createClient({
baseUrl: 'https://api.example.com',
});
// Use the wrapResult utility to handle errors
const fetchData = async () => {
const result = await wrapResult(fetch('https://api.example.com/data'));
if (result.success) {
return result.data;
} else {
console.error(result.error);
}
};
Development
# Install dependencies
pnpm install
# Build the package
pnpm build
# Watch for changes during development
pnpm dev
# Lint code
pnpm lint:check
# Fix linting issues
pnpm lint:fix
Adding to the Library
When adding new functionality to this library, please follow these guidelines:
- Add types to
src/types.ts - Add utility functions to appropriate files in
src/ - Export public API from
src/index.ts - Update documentation
- Run tests if applicable