@ratesspot/types
v1.0.0
Published
Shared TypeScript types for RatesSpot API and clients
Readme
@ratesspot/types
Shared TypeScript type definitions for RatesSpot API and client applications.
Installation
npm install @ratesspot/types
# or
yarn add @ratesspot/typesUsage
In Frontend Application
import {
Merchant,
CurrentUserResponse,
ApiResponse
} from '@ratesspot/types';
// Use with your API client
class ApiClient {
async getMerchant(): Promise<ApiResponse<Merchant>> {
return this.request<Merchant>('/api/merchants');
}
async getCurrentUser(): Promise<ApiResponse<CurrentUserResponse>> {
return this.request<CurrentUserResponse>('/api/auth/me');
}
}In Backend Application
import {
CurrentUserResponse,
CreateMerchantDto
} from '@ratesspot/types';
export const getCurrentUser = async (
req: Request,
res: Response
): Promise<void> => {
const user: CurrentUserResponse = await getUserDetails(req.user.id);
res.json({ success: true, data: user });
};Available Types
Auth Types
CurrentUserResponse- User profile with merchant associationsMerchantInfo- Merchant information for userJWTPayload- JWT token payload structureApiKeyPayload- API key payloadCreateApiKeyData- API key creation DTOUpdateApiKeyData- API key update DTO
API Types
ApiResponse<T>- Standard API response wrapperPaginationMeta- Pagination metadataPaginatedRequest- Pagination request parameters
Merchant Types
Merchant- Complete merchant entityCreateMerchantDto- Merchant creation DTOUpdateMerchantDto- Merchant update DTO
Development
To add new types:
- Add type definitions to appropriate file in
src/ - Export from the file
- Ensure it's exported from
src/index.ts - Run
npm run buildto compile - Publish new version
Publishing
npm version patch|minor|major
npm publish