saas-maker
v0.0.18-rc.1
Published
Collection of utilities for building SaaS applications
Downloads
144
Readme
saas-maker
Collection of utilities for building SaaS applications.
Installation
npm install saas-maker
# or
yarn add saas-maker
# or
pnpm add saas-makerFeatures
- Composable route builder:
createRoute()→.parse()→.handle() - Error handling utilities:
tryCatch(),throwOnError(),unwrapData() - React helper:
devmode,UserProvider
Usage
import { throwOnNull, throwIfFalsy, tryCatch } from "saas-maker";
// Example usage
const processUser = (userId: string | null) => {
// Will throw if userId is null
throwOnNull(userId, "User ID is required");
// Rest of your code
};
// Try-catch wrapper
const result = tryCatch(() => {
// Your code that might throw
return "success";
});
// result will be { success: true, data: 'success' } or { success: false, error: Error }Notes
Error handling:
- Add global error handling in your server handler and client side. Check for error which is instance of
AppError(or usegetErrorInfo)
License
MIT
