Skip to main content

Overview

@atproto/common provides shared utilities and helpers for building AT Protocol servers and Node.js applications. This package is specifically designed for server-side usage and is not browser-compatible. For browser-compatible utilities, use @atproto/common-web.
This package re-exports all utilities from @atproto/common-web and adds Node.js-specific functionality.

Installation

Main Exports

Logger Utilities

Structured logging utilities built on Pino.

Environment Variables

Control logging behavior with these environment variables:
  • LOG_ENABLED - Enable/disable logging (true, t, 1 to enable)
  • LOG_LEVEL - Set log level (debug, info, warn, error, fatal)
  • LOG_SYSTEMS - Space or comma-separated list of subsystems to enable
  • LOG_DESTINATION - Path to log file (defaults to stdout)

API

(name: string) => pino.Logger
Create a logger for a specific subsystem. Subsystems can be individually enabled via LOG_SYSTEMS.

Environment Variable Helpers

Utilities for reading and parsing environment variables.

API

(name: string) => number | undefined
Parse environment variable as integer. Returns undefined if not set or invalid.
(name: string) => string | undefined
Get environment variable as string. Returns undefined if not set or empty.
(name: string) => boolean | undefined
Parse environment variable as boolean. Accepts 'true', '1', 'false', '0'. Returns undefined for other values.
(name: string) => string[]
Parse comma-separated environment variable into array. Returns empty array if not set.

Buffer Utilities

Utilities for working with binary data and buffers.

Stream Utilities

Utilities for working with Node.js streams.

File System Utilities

Utilities for file system operations.

IPLD Utilities

Utilities for working with IPLD (InterPlanetary Linked Data).

Date Utilities

Date parsing and validation utilities.

Obfuscation Utilities

Utilities for obfuscating sensitive data in logs.

Re-exported from @atproto/common-web

All utilities from @atproto/common-web are also available:
  • TID (Timestamp Identifier) generation
  • Async utilities (retry, wait, bailableWait)
  • Array utilities (chunkArray, dedupeStrs, asyncFilter)
  • Object utilities (omit, noUndefinedVals)
  • DID document utilities
  • String and binary conversion utilities

Usage Example

Complete example of a simple AT Protocol server using common utilities:

TypeScript Types

The package is written in TypeScript and includes complete type definitions. All utilities are fully typed.

@atproto/common-web

Browser-compatible shared utilities

@atproto/xrpc-server

Server-side XRPC implementation

@atproto/pds

Personal Data Server implementation

@atproto/bsky

Bluesky AppView implementation

License

This project is dual-licensed under MIT and Apache 2.0 terms.