abipulli-types
v1.0.49
Published
Shared TypeScript types for frontend and backend
Readme
abipulli-types
A TypeScript types package for sharing common types between frontend and backend applications.
Installation
# Install as a dev dependency
npm install -D abipulli-types
# or
yarn add -D abipulli-typesUsage
Import the types you need in your TypeScript files:
import { User, UserRole, Order, OrderStatus, OrderItem } from "abipulli-types";
// Example User
const user: User = {
id: "123",
email: "[email protected]",
firstName: "John",
lastName: "Doe",
createdAt: new Date(),
updatedAt: new Date(),
isActive: true,
role: UserRole.USER,
};
// Example Order
const order: Order = {
id: "456",
userId: user.id,
total: 99.99,
status: OrderStatus.PENDING,
items: [
{
id: "789",
productId: "prod_123",
quantity: 2,
price: 49.99,
subtotal: 99.98,
},
],
createdAt: new Date(),
updatedAt: new Date(),
};Available Types
User Types (types/user.ts)
User: Main user interfaceUserRole: Enum for user roles (ADMIN, USER, GUEST)UserCreateInput: Type for creating new usersUserUpdateInput: Type for updating existing users
Order Types (types/order.ts)
Order: Main order interfaceOrderItem: Interface for items within an orderOrderStatus: Enum for order statusesOrderCreateInput: Type for creating new ordersOrderUpdateInput: Type for updating existing orders
API Types (types/api.ts)
ApiResponse<T>: Generic type for API responsesPaginatedResponse<T>: Generic type for paginated responsesApiError: Type for API error responses
Development
- Make changes to the types in the
src/typesdirectory - Build the package:
npm run build - Commit and push your changes
- Publish to npm:
npm publish
Project Structure
src/
├── types/
│ ├── user.ts # User-related types
│ ├── order.ts # Order-related types
│ └── api.ts # API-related types
└── index.ts # Main exports