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 🙏

© 2026 – Pkg Stats / Ryan Hefner

nest-ashbyhq

v0.1.7

Published

NestJS package for Ashby HQ client

Readme

Ashby HQ Client for NestJS

A NestJS module for interacting with the Ashby HQ API.

Installation

npm install @your-org/ashbyhq-client

Usage

Module Configuration

You can configure the module in two ways:

  1. Using forRoot:
import { Module } from '@nestjs/common';
import { AshbyhqModule } from '@your-org/ashbyhq-client';

@Module({
  imports: [
    AshbyhqModule.forRoot({
      auth: {
        apiKey: 'your_api_key_here'
      },
      baseURL: 'https://api.ashbyhq.com', // optional
      timeout: 5000 // optional
    })
  ]
})
export class AppModule {}
  1. Using forRootAsync (recommended for dynamic configuration):
import { Module } from '@nestjs/common';
import { ConfigModule, ConfigService } from '@nestjs/config';
import { AshbyhqModule } from '@your-org/ashbyhq-client';

@Module({
  imports: [
    ConfigModule.forRoot(),
    AshbyhqModule.forRootAsync({
      auth: {
        apiKey: process.env.ASHBY_API_KEY
      },
      baseURL: process.env.ASHBY_API_URL, // optional
      timeout: 5000 // optional
    })
  ]
})
export class AppModule {}

Using the Services

Once configured, you can inject and use the services in your application:

import { Injectable } from '@nestjs/common';
import { CandidateService } from '@your-org/ashbyhq-client';

@Injectable()
export class YourService {
  constructor(private readonly candidateService: CandidateService) {}

  async createCandidate() {
    const candidate = await this.candidateService.create({
      name: 'John Doe',
      email: '[email protected]'
    });
    return candidate;
  }
}

Available Services

CandidateService

The CandidateService provides methods for managing candidates:

  • create(input: CreateCandidateInput): Create a new candidate
  • list(pagination?: Pagination): List candidates
  • search(input: GetCandidateInput): Search candidates
  • find(id: string, idType?: 'internal' | 'external'): Find a candidate by ID
  • update(id: string, input: UpdateCandidateInput): Update a candidate
  • uploadResume(candidateId: string, formData: FormData): Upload a resume for a candidate

Environment Variables

When using forRootAsync, you can configure these environment variables:

ASHBY_API_KEY=your_api_key_here
ASHBY_API_URL=https://api.ashbyhq.com

Error Handling

The client includes built-in error handling for common API responses:

  • UnauthorizedError: 401 authentication errors
  • BadRequestError: 400 validation errors
  • NotFoundError: 404 resource not found
  • InternalError: 500 server errors

Example error handling:

try {
  const candidate = await candidateService.find('non_existent_id');
} catch (error) {
  if (error instanceof NotFoundError) {
    console.log('Candidate not found');
  }
}

Types

The package includes TypeScript definitions for all API responses and inputs. Key types include:

  • ICandidate: Candidate interface
  • CreateCandidateInput: Input for creating candidates
  • UpdateCandidateInput: Input for updating candidates
  • Response<T>: Generic API response
  • ListResponse<T>: Paginated list response

Base Service

import { Injectable } from '@nestjs/common';
import { AshbyhqService } from '@your-org/ashbyhq-client';

@Injectable()
export class YourService {
  constructor(private readonly ashbyhqService: AshbyhqService) {}

  async someMethod() {
    // Use the service methods
    const result = await this.ashbyhqService.getExample();
  }
}

Candidate Service

import { Injectable } from '@nestjs/common';
import { 
  CandidateService, 
  CreateCandidateInput, 
  UpdateCandidateInput,
  ICandidate,
  FindCandidateInput,
  Pagination
} from '@your-org/ashbyhq-client';

@Injectable()
export class YourService {
  constructor(private readonly candidateService: CandidateService) {}

  async createCandidate() {
    const input: CreateCandidateInput = {
      name: 'John Doe',
      email: '[email protected]',
      phoneNumber: '+1234567890',
      linkedinUrl: 'https://linkedin.com/in/johndoe',
      githubUrl: 'https://github.com/johndoe',
      website: 'https://johndoe.com',
      location: {
        city: 'San Francisco',
        region: 'CA',
        country: 'US'
      },
      sourceId: 'source_123',
      creditedToUserId: 'user_123'
    };
    const candidate: ICandidate = await this.candidateService.create(input);
    return candidate;
  }

  async listCandidates() {
    const pagination: Pagination = {
      limit: 10,
      cursor: 'next_page_cursor'
    };
    const { candidates, hasMore, nextCursor } = await this.candidateService.list(pagination);
    return { candidates, hasMore, nextCursor };
  }

  async updateCandidate() {
    const input: UpdateCandidateInput = {
      candidateId: 'candidate_123',
      name: 'John Doe Updated',
      email: '[email protected]',
      socialLinks: [
        { type: 'linkedin', url: 'https://linkedin.com/in/johndoe' }
      ],
      sendNotifications: true
    };
    const candidate = await this.candidateService.update(input);
    return candidate;
  }

  async findCandidate() {
    // Find by ID
    const byId: FindCandidateInput = { id: 'candidate_123' };
    const candidate1 = await this.candidateService.find(byId);

    // Find by external mapping
    const byMapping: FindCandidateInput = { externalMappingId: 'external_123' };
    const candidate2 = await this.candidateService.find(byMapping);
  }

  async searchCandidates() {
    const { candidates, hasMore, nextCursor } = await this.candidateService.search({ 
      email: '[email protected]',
      name: 'John Doe'
    });
    return { candidates, hasMore, nextCursor };
  }

  async uploadResume(candidateId: string, resume: File) {
    const candidate = await this.candidateService.uploadResume({ candidateId, resume });
    return candidate;
  }
}

Response Types

The package includes comprehensive type definitions for all responses:

interface ICandidate {
  readonly id: string;
  readonly createdAt?: string;
  readonly updatedAt?: string;
  readonly name: string;
  readonly primaryEmailAddress?: ContactInfo;
  readonly emailAddresses: ContactInfo[];
  readonly primaryPhoneNumber?: ContactInfo;
  readonly phoneNumbers: ContactInfo[];
  readonly socialLinks: SocialLink[];
  readonly tags: Tag[];
  readonly position?: string;
  readonly company?: string;
  readonly school?: string;
  readonly applicationIds: string[];
  readonly resumeFileHandle?: FileHandle;
  readonly fileHandles: FileHandle[];
  readonly customFields?: ICustomField[];
  readonly profileUrl: string;
  readonly source?: ISource;
  readonly creditedToUser?: ICreditedToUser;
  readonly timezone?: string;
  readonly primaryLocation?: IPrimaryLocation;
}

interface ListResponse<T> {
  readonly success: boolean;
  readonly results: T;
  readonly errors?: string[];
  readonly warnings?: string[];
  readonly moreDataAvailable?: boolean;
  readonly nextCursor?: string;
  readonly syncToken?: string;
}

License

MIT