@qianxude/shared

v0.2.8

Published

qian shared types and classes

Readme

qian shared types and classes for other libraries

Install

pn add @qianxude/shared

Global Types

The Logger interface is available as a global type. To use it in your project without imports:

Setup

Add the following to your tsconfig.json:

{
  "include": [
    "src/**/*.ts",
    "node_modules/@qianxude/shared/dist/global.d.ts"
  ]
}

Usage

Once configured, you can use Logger directly without importing:

class MyService {
  private logger!: Logger; // No import needed
}

The Logger type is still available via regular import if preferred:

import type { Logger } from '@qianxude/shared';

Production Logger

For production-ready logger implementations, see @qianxude/logger which provides:

  • Pretty console logger for development
  • Duo-target logger (console + file with rotation)
  • PinoLogger class implementing the Logger interface
pn add @qianxude/logger
import { createDuoTargetPino, PinoLogger } from '@qianxude/logger';

const pinoLogger = createDuoTargetPino({
  level: 'info',
  file: './logs/app.log',
  frequency: 'daily',
});

const logger = new PinoLogger(pinoLogger, { service: 'my-app' });

Downstream Project Configuration

Downstream projects need to include the global types in their tsconfig.json:

{ "include": [ "src/**/*.ts", "../shared/dist/global.d.ts" ] }

Or via typeRoots if preferred:

{ "compilerOptions": { "typeRoots": ["./node_modules/@types", "../shared/dist"] } }

Publish

pn publish pkgs/shared --dry-run --filter @qianxude/shared
pn publish pkgs/shared --filter @qianxude/shared