npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@beaver-social/client

v0.0.1

Published

The Beaver Social Client for interacting with Beaver Social

Readme

Beaver Social Client SDK

A TypeScript SDK for interacting with the Beaver Social platform.

Overview

The Beaver Client SDK provides a simple interface for interacting with the Beaver Social API. It handles authentication, data fetching, and data manipulation operations. The SDK is designed to work with both web and mobile applications.

Project Structure

packages/lib/beaver-client/
├── src/
│   ├── comment/        # Comment-related functionality
│   ├── identity/       # User identity and authentication
│   ├── logger/         # Logging utilities
│   ├── post/           # Post creation, retrieval, and interaction
│   ├── styles/         # Style-related utilities
│   ├── utils/          # Helper functions
│   ├── index.ts        # Main entry point
│   └── types.ts        # TypeScript type definitions
├── package.json        # Package configuration
└── tsconfig.json       # TypeScript configuration

$$

Development Setup

  1. Install dependencies:

    bun install
  2. Build the SDK:

    bun run build
  3. Run in development mode (with watch):

    bun run dev

Architecture

The SDK follows a modular architecture with these key components:

BeaverClient

The main client class that initializes the SDK and provides access to all modules.

const client = new BeaverClient(surface, config);
await client.initialize();

Identity Module

Handles user authentication, profile creation, and profile updates.

Post Module

Manages post-related operations like creating, updating, deleting posts, and interactions (likes, reposts, etc.).

Comment Module

Handles comment-related functionality.

Code Conventions

1. Module Structure

Each feature module follows this pattern:

  • Class-based implementation
  • Constructor that takes defaults and logger parameters
  • Public methods for API interactions
  • Private helper methods when needed

2. API Interaction Pattern

API calls follow this pattern:

  1. Extract client and parameters
  2. Prepare request data
  3. Sign data when required
  4. Make API request using Hono client
  5. Return response or handle errors

Example:

public async create(options: { /* parameters */ }) {
  const { apiClient, surface } = this.defaults;
  const { /* extract parameters */ } = options;

  // Prepare payload
  const payload = JSON.stringify({ /* payload data */ });

  // Sign if needed
  const messageBytes = new TextEncoder().encode(payload);
  const signatureResult = await tryCatch(surface.signPersonalMessage(messageBytes));

  // Handle potential signing errors
  if (signatureResult.error) {
    this.logger.error(`error message: ${signatureResult.error}`);
    throw new Error(`error message: ${signatureResult.error}`);
  }

  // Make API call
  return apiClient.some.endpoint.$post({
    json: { /* request data */ },
    query: { signature: signatureResult.data.signature },
  });
}

3. Error Handling

  • Use the tryCatch utility for operations that might fail
  • Log errors with appropriate context
  • Throw meaningful errors for client applications

4. Documentation

  • Use JSDoc comments for all public methods
  • Document parameters, return types, and possible errors
  • Include examples when appropriate

Contributing Guidelines

Adding New Features

  1. Understand Existing Patterns: Review similar modules before adding new ones
  2. Add New Module: Create a new directory in src/ for the feature
  3. Implement Class: Create an index.ts with a class following the established pattern
  4. Export in Main Index: Add your module to the main index.ts file
  5. Document: Add JSDoc comments to all public methods
  6. Test: Verify functionality works as expected

Modifying Existing Code

  1. Follow Existing Patterns: Maintain consistency with the codebase
  2. Preserve Interface: Avoid breaking changes to public methods
  3. Update Documentation: Ensure JSDoc comments are updated

API Integration

When integrating with API routes:

  1. Use the Hono client from this.defaults.apiClient
  2. Follow the route structure defined in the server package
  3. Use proper parameter types and response handling

Building for Production

Run the build command to generate production-ready distribution files:

npm run build

This generates:

  • CJS format (CommonJS)
  • ESM format (ES Modules)
  • TypeScript declaration files

Generating Documentation

Run the docs command to generate API documentation:

npm run docs

Documentation will be generated in the docs/ directory.

VERIFY THE FOLLOWING CHANGES @MARSIAN

  • [ ] is the tsconfig/base.json file correct?
  • [ ] why did we have JSDoc comments in the methods? (i removed them for now, let me know if we need them) $$w $$