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

@joktec/core

v0.2.12

Published

JokTec - Core library

Readme

@joktec/core

Core framework package for JokTec applications and reusable packages.

@joktec/core contains the shared NestJS infrastructure used by the rest of the framework: application bootstrap, gateway and microservice runtime factories, config, logging, metrics, exceptions, base CRUD abstractions, microservice client helpers, Swagger decorators, and pagination contracts.

Install

yarn add @joktec/core

Public Surface

  • bootstrap:
    • Application.bootstrap
    • GatewayModule
    • MicroModule
  • framework modules:
    • ConfigModule
    • LoggerModule
    • MetricModule
    • JwtModule
    • BullModule
    • StaticModule
  • base abstractions:
    • BaseService
    • BaseController
    • BaseResolver
    • ClientController
    • ClientService
    • AbstractClientService
  • shared contracts:
    • IBaseRequest
    • IBaseRepository
    • IBaseService
    • IPaginationResponse
    • PaginationMode
  • pagination DTO factories:
    • PagePaginationResponse
    • OffsetPaginationResponse
    • CursorPaginationResponse
    • BasePaginationResponse
  • cursor utility:
    • CursorPagination
  • decorators, exceptions, interceptors, pipes, transport models, and selected NestJS exports.

Bootstrap Usage

import { Application, ConfigModule, GatewayModule, LoggerModule, Module } from '@joktec/core';

@Module({
  imports: [
    ConfigModule.forRoot({ isGlobal: true }),
    LoggerModule,
    GatewayModule.forRoot({ metric: true }),
  ],
})
export class AppModule {}

Application.bootstrap(AppModule);

Runtime mode is selected from config:

  • gateway config enables HTTP gateway bootstrap.
  • micro config enables microservice bootstrap.
  • Both can exist when a process needs both HTTP and transport listeners.

Base Controller Usage

BaseController creates standard REST endpoints for a DTO:

  • GET /
  • POST /search
  • GET /:id
  • POST /
  • PUT /:id
  • DELETE /:id
import { BaseController, Controller, IControllerProps } from '@joktec/core';
import { Article } from './article.schema';
import { ArticleService } from './article.service';

const props: IControllerProps<Article> = {
  dto: Article,
  paginationMode: 'offset',
  useBearer: true,
  create: { disable: true },
};

@Controller('articles')
export class ArticleController extends BaseController<Article, string>(props) {
  constructor(protected articleService: ArticleService) {
    super(articleService);
  }
}

customDto.paginationDto has priority over paginationMode when a controller needs a custom Swagger response DTO.

Pagination Contract

IBaseRequest supports three pagination styles:

type PaginationMode = 'page' | 'offset' | 'cursor';

Runtime priority is:

  1. cursor when cursor or cursorKey exists
  2. offset when offset exists
  3. page as the default fallback

Page response:

{
  items: T[];
  total: number;
  prevPage: number | null;
  currPage: number;
  nextPage: number | null;
  lastPage: number | null;
}

Offset response:

{
  items: T[];
  total: number;
  prevOffset: number | null;
  currOffset: number;
  nextOffset: number | null;
  lastOffset: number | null;
}

Cursor response:

{
  items: T[];
  total: number;
  hasNextPage: boolean;
  nextCursor: string | null;
}

BaseController.paginationMode controls the representative Swagger response shape. It does not force runtime clients to use only that mode.

Cursor Pagination Utility

CursorPagination creates opaque base64url cursor tokens from ordered item keys. Database packages use it to resolve cursor keys, sort directions, limit + 1 slicing, and nextCursor generation.

import { CursorPagination } from '@joktec/core';

const limit = CursorPagination.getLimit(query.limit);
const cursor = CursorPagination.resolve({
  cursor: query.cursor,
  cursorKey: query.cursorKey,
  defaultKeys: ['createdAt', 'id'],
  tieBreakerKeys: ['id'],
  sort: query.sort,
});

External Client Pattern

Reusable packages that manage external systems normally extend AbstractClientService and use ClientConfig. This preserves shared config validation, conId multi-connection support, lifecycle hooks, and retry/debug behavior.

Repository Layout

  • src/abstractions: base services, controllers, resolvers, and client factories.
  • src/infras: application, gateway, and microservice runtime factories.
  • src/modules: config, logger, metrics, JWT, Bull, and static assets modules.
  • src/models: shared DTO, request, response, repository, and pagination contracts.
  • src/decorators: HTTP, Swagger, metric, and transport decorators.
  • src/exceptions, src/interceptors, src/pipes: cross-cutting runtime concerns.
  • src/index.ts: public package export boundary.

Development

yarn lint --scope @joktec/core
yarn build --scope @joktec/core
yarn test --scope @joktec/core