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

@nxtoai/gati

v1.0.13

Published

A flexible Aerospike service for NestJS applications

Downloads

27

Readme

Gati - Aerospike Service for NestJS

A flexible and powerful Aerospike service for NestJS applications, providing a simple interface for Aerospike operations.

Installation

npm install @nxtoai/gati

Configuration

Import the GatiModule in your application module:

import { Module } from '@nestjs/common';
import { GatiModule } from '@nxtoai/gati';

@Module({
  imports: [
    GatiModule.forRoot({
      hosts: ['localhost'],
      port: 3000,
      namespace: 'test'
    }),
  ],
})
export class AppModule {}

Usage

Inject the GatiService into your service:

import { Injectable } from '@nestjs/common';
import { GatiService } from '@nxtoai/gati';

@Injectable()
export class UserService {
  constructor(private readonly gati: GatiService) {}

  // Example: Storing user data in multiple bins
  async createUser(userId: string, userData: any) {
    await this.gati.put('users', userId, {
      id_bin: {
        id: userId,
        created_at: new Date().toISOString()
      },
      email_bin: {
        email: userData.email,
        email_verified: false
      },
      data_bin: {
        ...userData,
        updated_at: new Date().toISOString()
      }
    }, { ttl: 86400 });
  }

  // Example: Retrieving data from multiple bins
  async getUserData(userId: string) {
    const userData = await this.gati.get('users', userId);
    if (!userData) return null;

    return {
      id: userData.id_bin?.id,
      created_at: userData.id_bin?.created_at,
      email: userData.email_bin?.email,
      email_verified: userData.email_bin?.email_verified,
      ...userData.data_bin
    };
  }

  // Example: Updating specific bins
  async updateUserEmail(userId: string, email: string) {
    const currentData = await this.gati.get('users', userId);
    if (!currentData) return;

    await this.gati.put('users', userId, {
      ...currentData,
      email_bin: {
        email,
        email_verified: false,
        updated_at: new Date().toISOString()
      }
    });
  }

  // Example: Checking if specific bins exist
  async checkUserBins(userId: string) {
    const userData = await this.gati.get('users', userId);
    if (!userData) return { hasId: false, hasEmail: false, hasData: false };

    return {
      hasId: !!userData.id_bin,
      hasEmail: !!userData.email_bin,
      hasData: !!userData.data_bin
    };
  }
}

API Reference

put(set: string, key: string, bins: RecordBins, options?: { ttl?: number }): Promise

Stores data in Aerospike.

// Example: Storing user data in multiple bins
const userId = 'user:123';
const userData = {
  name: 'John Doe',
  age: 30,
  address: {
    street: '123 Main St',
    city: 'New York',
    country: 'USA'
  },
  preferences: {
    theme: 'dark',
    notifications: true
  }
};

await gati.put('users', userId, {
  id_bin: {
    id: userId,
    created_at: new Date().toISOString()
  },
  email_bin: {
    email: '[email protected]',
    email_verified: false
  },
  data_bin: userData
}, { ttl: 86400 });

get(set: string, key: string): Promise<RecordBins | null>

Retrieves data from Aerospike.

// Example: Getting data from multiple bins
const userId = 'user:123';
const userData = await gati.get('users', userId);

if (userData) {
  console.log('User ID:', userData.id_bin?.id);
  console.log('Created at:', userData.id_bin?.created_at);
  console.log('Email:', userData.email_bin?.email);
  console.log('Email verified:', userData.email_bin?.email_verified);
  console.log('User data:', userData.data_bin);
}

exists(set: string, key: string): Promise

Checks if a record exists.

// Example: Checking if user exists
const userId = 'user:123';
const exists = await gati.exists('users', userId);
console.log('User exists:', exists);

remove(set: string, key: string): Promise

Removes a record.

// Example: Removing user data
const userId = 'user:123';
await gati.remove('users', userId);

scan(set: string, options?: ScanOptions): Promise<RecordBins[]>

Scans all records in the set.

// Example: Scanning all users
const users = await gati.scan('users');
console.log(`Found ${users.length} users`);

// Example: Scanning with options
const limitedUsers = await gati.scan('users', { limit: 10 });
console.log(`Retrieved ${limitedUsers.length} users`);

close(): Promise

Closes the Aerospike connection.

// Example: Closing the connection
await gati.close();

Error Handling

The service includes comprehensive error handling and logging:

try {
  await gati.put('users', 'key', { value: 'data' });
} catch (error) {
  if (error instanceof GatiValidationError) {
    console.error('Validation error:', error.message);
  } else {
    console.error('Operation error:', error.message);
  }
}

License

This project is licensed under the MIT License - see the LICENSE file for details.