Skip to content

Commit a9ed86b

Browse files
committed
docs: add coverage badges and onboarding guide
- Add test coverage (95%) and type coverage (100%) badges to README - Create comprehensive onboarding guide for SDK contributors - Guide covers: setup, API key configuration, testing, type safety Focus on practical examples with visual structure.
1 parent 0ead388 commit a9ed86b

File tree

2 files changed

+221
-0
lines changed

2 files changed

+221
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[![Socket Badge](https://socket.dev/api/badge/npm/package/@socketsecurity/sdk)](https://socket.dev/npm/package/@socketsecurity/sdk)
44
[![CI](https://github.com/SocketDev/socket-sdk-js/actions/workflows/ci.yml/badge.svg)](https://github.com/SocketDev/socket-sdk-js/actions/workflows/ci.yml)
5+
![Test Coverage](https://img.shields.io/badge/test--coverage-95%25-brightgreen)
6+
![Type Coverage](https://img.shields.io/badge/type--coverage-100%25-brightgreen)
57

68
[![Follow @SocketSecurity](https://img.shields.io/twitter/follow/SocketSecurity?style=social)](https://twitter.com/SocketSecurity)
79
[![Follow @socket.dev on Bluesky](https://img.shields.io/badge/Follow-@socket.dev-1DA1F2?style=social&logo=bluesky)](https://bsky.app/profile/socket.dev)

docs/onboarding-guide.md

Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
# Onboarding Guide
2+
3+
**New Contributor Quickstart** — Start contributing to the Socket.dev SDK in 5 minutes.
4+
5+
---
6+
7+
## 📋 Prerequisites
8+
9+
```
10+
Required:
11+
✓ Node.js 20+ (LTS recommended)
12+
✓ pnpm 9+
13+
✓ Git
14+
✓ Socket.dev API key (for integration tests)
15+
```
16+
17+
---
18+
19+
## 🚀 Quick Start
20+
21+
### 1. Clone & Setup
22+
23+
```bash
24+
# Clone
25+
git clone https://github.com/SocketDev/socket-sdk-js.git
26+
cd socket-sdk-js
27+
28+
# Install & verify
29+
pnpm install
30+
pnpm test
31+
```
32+
33+
**Expected:** ✓ 95% test coverage, ✓ 100% type coverage
34+
35+
---
36+
37+
### 2. Project Structure
38+
39+
```
40+
socket-sdk-js/
41+
├── src/ # Source code
42+
│ ├── api/ # API client implementation
43+
│ ├── types/ # TypeScript types
44+
│ ├── utils/ # Helper utilities
45+
│ └── index.ts # Main SDK exports
46+
47+
├── test/ # Tests
48+
│ ├── unit/ # Unit tests
49+
│ └── integration/ # Integration tests
50+
51+
├── scripts/ # Build scripts
52+
└── docs/ # Documentation
53+
├── api-reference.md # Complete API docs
54+
├── usage-examples.md # Code samples
55+
├── when-to-use-what.md
56+
├── quota-management.md
57+
└── dev/ # Developer docs
58+
└── testing.md
59+
```
60+
61+
---
62+
63+
### 3. Essential Commands
64+
65+
```bash
66+
# Development
67+
pnpm run dev # Watch mode
68+
pnpm build # Build for production
69+
70+
# Testing
71+
pnpm test # Unit tests
72+
pnpm test:integration # Integration tests (requires API key)
73+
pnpm run cover # With coverage
74+
75+
# Quality
76+
pnpm run check # Type check + lint
77+
pnpm run fix # Auto-fix issues
78+
```
79+
80+
---
81+
82+
## 🔑 API Key Setup
83+
84+
For integration tests, set your Socket.dev API key:
85+
86+
```bash
87+
# .env file
88+
SOCKET_API_KEY=your-api-key-here
89+
90+
# Or export directly
91+
export SOCKET_API_KEY=your-api-key-here
92+
```
93+
94+
Get your API key at [socket.dev/settings/api-keys](https://socket.dev/settings/api-keys)
95+
96+
---
97+
98+
## 💡 Development Workflow
99+
100+
```
101+
1. Branch → git checkout -b feature/my-change
102+
2. Implement → Edit src/ files
103+
3. Test → pnpm test (unit + integration)
104+
4. Verify → pnpm run fix && pnpm test
105+
5. Docs → Update API docs if needed
106+
6. Commit → Conventional commits
107+
7. PR → Submit pull request
108+
```
109+
110+
---
111+
112+
## 📚 Key Concepts
113+
114+
### 1. API Versioning
115+
116+
The SDK wraps the Socket.dev REST API v0:
117+
118+
```typescript
119+
import { SocketSdk } from '@socketsecurity/sdk'
120+
121+
const sdk = new SocketSdk('your-api-key')
122+
```
123+
124+
### 2. Rate Limiting
125+
126+
Be mindful of API quotas:
127+
- Check rate limits before large operations
128+
- Use quota management utilities
129+
130+
See [docs/quota-management.md](./quota-management.md)
131+
132+
### 3. Type Safety
133+
134+
Full TypeScript support for all API responses:
135+
136+
```typescript
137+
import type { PackageMetadata } from '@socketsecurity/sdk'
138+
139+
const metadata: PackageMetadata = await sdk.getPackage('npm', 'lodash')
140+
```
141+
142+
### 4. Error Handling
143+
144+
All API errors are properly typed:
145+
146+
```typescript
147+
try {
148+
await sdk.getPackage('npm', 'nonexistent')
149+
} catch (error) {
150+
if (error.statusCode === 404) {
151+
// Handle not found
152+
}
153+
}
154+
```
155+
156+
---
157+
158+
## 🧪 Testing
159+
160+
### Unit Tests
161+
162+
Test business logic without API calls:
163+
164+
```typescript
165+
// test/unit/utils/parse-purl.test.ts
166+
import { describe, it, expect } from 'vitest'
167+
import { parsePurl } from '../../../src/utils/parse-purl'
168+
169+
describe('parsePurl', () => {
170+
it('parses npm purl', () => {
171+
expect(parsePurl('pkg:npm/lodash@4.17.21')).toEqual({
172+
ecosystem: 'npm',
173+
name: 'lodash',
174+
version: '4.17.21'
175+
})
176+
})
177+
})
178+
```
179+
180+
### Integration Tests
181+
182+
Test actual API calls (requires API key):
183+
184+
```typescript
185+
// test/integration/package.test.ts
186+
import { SocketSdk } from '../../src'
187+
188+
const sdk = new SocketSdk(process.env.SOCKET_API_KEY!)
189+
190+
it('fetches package metadata', async () => {
191+
const data = await sdk.getPackage('npm', 'lodash')
192+
expect(data.name).toBe('lodash')
193+
})
194+
```
195+
196+
---
197+
198+
## 📖 Additional Resources
199+
200+
- [API Reference](./api-reference.md) - Complete method docs
201+
- [Usage Examples](./usage-examples.md) - Common patterns
202+
- [When to Use What](./when-to-use-what.md) - Method selection guide
203+
- [Quota Management](./quota-management.md) - Rate limiting
204+
- [Testing Guide](./dev/testing.md) - Testing best practices
205+
- [CLAUDE.md](../CLAUDE.md) - Development standards
206+
207+
---
208+
209+
## ✅ Checklist
210+
211+
- [ ] Installed dependencies (`pnpm install`)
212+
- [ ] Set up API key (for integration tests)
213+
- [ ] Tests passing (`pnpm test`)
214+
- [ ] Read [API Reference](./api-reference.md)
215+
- [ ] Understand rate limiting
216+
- [ ] Know commit format (conventional commits)
217+
- [ ] Ready to contribute!
218+
219+
**Welcome!** 🎉

0 commit comments

Comments
 (0)