This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
psn-api is a JavaScript library that provides access to PlayStation Network data including trophies, user profiles, and game information. It's designed to be modular, supports tree-shaking, and works in both Node.js and browser environments.
# Install dependencies
pnpm i
# Run development mode with watch
pnpm dev
# Run the playground file (for testing)
pnpm playground
# Run tests
pnpm test
# Run tests with coverage
pnpm test:coverage
# Format code (oxfmt)
pnpm format
pnpm format:check
# Lint code (oxlint)
pnpm lint
pnpm lint:fix
# Build the project
pnpm build
# Verify everything (format, lint, test, build)
pnpm verifysrc/- Source codeauthenticate/- Authentication-related functionsgraphql/- GraphQL API interactionsmodels/- TypeScript interfaces and typessearch/- Search-related functionstrophy/- Trophy-related functionstitle/- Game/title trophy functionsuser/- User trophy functions
user/- User-related functionsutils/- Utility functions for API calls
Tests are written using Vitest. Each API function has a corresponding .test.ts file. The project maintains 100% test coverage for branches, functions, lines, and statements.
To run a single test file:
pnpm test -- -t "name of test or test file"-
All API functions follow a similar pattern:
- They accept an authorization object as their first parameter
- Additional parameters follow
- Each function is well-typed with appropriate request/response interfaces
-
Testing:
- Mock responses are used to test API endpoints
- Each function has tests for successful responses and error handling
-
Documentation:
- Each function is documented in both the code and on the documentation website
- Node.js >= 20.x
- pnpm >= 10.x
The project uses semantic-release for versioning and releases. Commit messages should follow the conventional commits specification.