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

@kenniy/godeye-data-contracts

v1.3.6

Published

Enterprise-grade base repository architecture for GOD-EYE microservices with zero overhead and maximum code reuse

Readme

@kenniy/godeye-data-contracts v1.2.6

npm version TypeScript License: MIT

Enterprise Repository Architecture with Intelligent Search

Zero runtime overhead. Maximum code reuse. Enterprise-ready performance.

Eliminates 82.5% of repository repetition across TypeORM and Mongoose services with:

  • WhereConfig Pattern: Clean separation of backend control and frontend requests
  • Intelligent Search: Multi-algorithm fuzzy search with typo tolerance
  • Auto-Response Detection: ResponseFactory automatically formats pagination/array/single entity
  • Graceful Error Handling: Relations fail silently with detailed metadata
  • Performance Monitoring: Built-in query timing and metrics
  • Enhanced Swagger UI: Smart documentation with description optimization
  • Deep Relations: Nested population with dot notation support

📖 Quick Navigation

🚀 Quick Start

npm install @kenniy/[email protected]
# or
pnpm add @kenniy/[email protected]
import {
  BaseTypeORMRepository,
  FindManyDto,
  IWhereConfig,
  SearchStrategy,
  ResponseFactory,
  bootstrap
} from '@kenniy/godeye-data-contracts';

Bootstrap Your Service

// One-line service setup with enhanced Swagger
const app = await bootstrap(AppModule, {
  serviceName: 'my-service',
  port: 3003,
  enableSwagger: true,
  swaggerConfig: {
    title: 'My Service API',
    description: 'Complete API documentation',
    maxDisplayRequestSize: 10000,
    maxDisplayResponseSize: 10000
  }
});

⚡ Core Pattern - WhereConfig + QueryDto

The cleanest way to handle complex search with backend control:

@Controller('users')
export class UsersController {
  @Get()
  async getUsers(@Query() queryDto: FindManyDto) {
    // Backend defines search intelligence and conditions
    const whereConfig: IWhereConfig = {
      conditions: {
        status: 'active',
        isDeleted: false
      },
      searchConfig: [
        {
          fields: ["firstName", "lastName"],
          defaultStrategy: SearchStrategy.FUZZY, // Handles typos
          priority: 10,
          weight: 1.0
        }
      ]
    };

    // Clean separation: backend config + frontend request
    const result = await this.userRepository.findWithPagination(whereConfig, queryDto);

    // Auto-detects format (pagination/array/single)
    return ResponseFactory.success(result);
  }
}

Frontend sends simple request:

GET /users?search=kenniy&include=profile,business&page=1&limit=20

Gets back sophisticated response:

{
  "success": true,
  "data": {
    "items": [
      {
        "firstName": "Kenny",  // Fuzzy matched "kenniy"
        "profile": { ... },
        "business": { ... }
      }
    ],
    "total": 147,
    "page": 1,
    "limit": 20
  },
  "metadata": {
    "queryTime": "23ms",
    "searchAlgorithms": ["fuzzy"],
    "relationsLoaded": ["profile", "business"]
  }
}

🔍 Intelligent Search Features

Search Strategies

| Strategy | Example | Use Case | |----------|---------|----------| | EXACT | john = john | IDs, emails | | FUZZY | kenniyKenny | Names (typo tolerance) | | CONTAINS | java in javascript | Skills, descriptions | | STARTS_WITH | john in john123 | Prefix matching |

Field Groups

{
  // Multiple fields, same algorithm
  fields: ["firstName", "lastName", "displayName"],
  defaultStrategy: SearchStrategy.FUZZY,
  priority: 10,
  weight: 1.0
}

Array Fields

{
  // Database array field
  field: "skills",
  isArray: true,
  defaultStrategy: SearchStrategy.CONTAINS,
  priority: 7,
  weight: 0.7
}

📚 Repository Methods

1. Pagination Search

const result = await userRepository.findWithPagination(whereConfig, queryDto);
// Returns: { items: [...], total: 147, page: 1, metadata: {...} }

2. Single Entity

const user = await userRepository.findById(id, whereConfig, queryDto);
// Returns: { data: {...}, metadata: {...} }

3. Array Search

const users = await userRepository.find(whereConfig, queryDto);
// Returns: { items: [...], metadata: {...} }

🏗️ Entity Setup

TypeORM

import { BaseTypeORMRepository } from '@kenniy/godeye-data-contracts';

@Injectable()
export class UserRepository extends BaseTypeORMRepository<User> {
  // Inherits all intelligent functionality
}

Mongoose

import { BaseMongooseRepository } from '@kenniy/godeye-data-contracts';

@Injectable()
export class UserRepository extends BaseMongooseRepository<User> {
  // Works with MongoDB too!
}

📋 Quick Examples

See comprehensive examples in the Implementation Examples section below, or jump directly to:

🚦 Response Factory Auto-Detection

The ResponseFactory automatically detects your data format:

// Pagination data → Pagination response
ResponseFactory.success({
  items: [...],
  total: 100,
  page: 1,
  limit: 20
});

// Single entity → Entity response
ResponseFactory.success({
  data: { id: "123", name: "John" },
  metadata: { queryTime: "12ms" }
});

// Array data → Array response
ResponseFactory.success({
  items: [...],
  metadata: { count: 5 }
});

🎯 Key Benefits

  • Frontend Simplicity: Just search, include, page, limit
  • Backend Control: Full algorithm and condition control
  • Auto-Population: Deep relations with graceful error handling
  • Performance: Optimized queries with monitoring
  • Type Safety: Full TypeScript support
  • Universal: Works with TypeORM and Mongoose
  • Enterprise Ready: Error handling, logging, metrics
  • Enhanced Swagger: Smart documentation with description optimization
  • Aggregate Queries: Replace 3-5 database calls with single optimized query

📊 Performance

  • Query Optimization: ~10-20ms for complex searches
  • Parallel Execution: Count and data queries run in parallel
  • Relation Validation: Auto-discovery prevents invalid JOINs
  • Memory Efficient: Optimized query builders
  • Monitoring: Built-in performance tracking

🛠️ Advanced Configuration

Dynamic Conditions

const whereConfig: IWhereConfig = {
  conditions: { status: 'active' },
  dynamicConditions: (criteria) => {
    // Add conditions based on search context
    if (criteria.search?.term) {
      return { profileComplete: true };
    }
    return {};
  }
};

Custom Search Fields

searchConfig: [
  {
    fields: ["firstName", "lastName"],
    defaultStrategy: SearchStrategy.FUZZY,
    priority: 10,
    weight: 1.0
  },
  {
    field: "skills",
    isArray: true,
    defaultStrategy: SearchStrategy.CONTAINS,
    priority: 7,
    weight: 0.7
  }
]

📝 Migration from Old Pattern

Old Way:

const criteria = queryDto.toICriteria();
return repository.findWithPagination(criteria);

New Way:

const whereConfig = { conditions: { status: 'active' } };
return repository.findWithPagination(whereConfig, queryDto);

📚 Complete Documentation

Core Documentation (/docs)

Implementation Examples (/examples)

Performance & Testing

🧪 Testing

The package includes comprehensive tests demonstrating all functionality:

npm test

🔄 What's New in v1.2.6

Complete Documentation Suite

  • NEW: Comprehensive documentation in /docs directory
  • NEW: API Reference with all classes, methods, and interfaces
  • NEW: Migration Guide for version upgrades and pattern transitions
  • NEW: Best Practices Guide for enterprise implementation
  • NEW: Troubleshooting Guide with solutions for common issues
  • Updated README with navigation and comprehensive linking

Enhanced Swagger UI

  • Smart description truncation with external doc linking
  • Custom CSS and responsive design improvements
  • Dynamic service titles and enhanced navigation
  • Configurable display limits for better performance

Deep Population Support

  • Enhanced schemas for deeply nested objects
  • Rich metadata tracking for performance analysis
  • Support for complex populated responses

Description Optimization

  • Intelligent truncation respects sentence boundaries
  • External documentation integration
  • Cleaner API documentation

📄 License

MIT © kenniy


Ready to use in production! This architecture powers high-performance microservices with intelligent search capabilities.