pikku-services

Creates singleton and per-request dependency injection services for Pikeu apps.

56|Updated Apr 18, 2021
One-click install
npx skills add https://github.com/pikkujs/pikku --skill pikku-services
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: pikku-services
Source: https://github.com/pikkujs/pikku/tree/main/.claude/skills/pikku-services
Command: npx skills add https://github.com/pikkujs/pikku --skill pikku-services

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Dependency injection is central to building scalable Pikku apps; this skill provides factory functions to create singleton and per-request services, enabling clean separation of concerns and robust testability.

Core Features & Use Cases

  • Defines pikkuServices for singleton services that initialize once at startup.
  • Defines pikkuWireServices for per-request services that are created per transport/context.
  • Includes typing guidance, built-in services reference, and tree-shaking optimizations via dynamic imports.

Quick Start

Create and wire a singleton service with pikkuServices and a per-request service with pikkuWireServices in your app.

Frequently Asked Questions about pikku-services

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure dependency injection for singleton services in a TypeScript app?

To configure dependency injection for singleton services in TypeScript, you use the pikkuServices factory function. This initializes singleton services once at application startup, providing clean separation of concerns and ensuring robust testability across your app.

What is the difference between singleton and per-request services when wiring dependencies?

The difference between singleton and per-request services lies in their lifecycle. Singleton services initialize once at startup via pikkuServices, while per-request services are created dynamically per transport or context using the pikkuWireServices factory function.

How do I optimize service manifests for tree-shaking using dynamic imports?

You optimize service manifests for tree-shaking by leveraging the auto-generated manifest and dynamic import optimization. This built-in feature ensures that only required services are loaded, reducing the final bundle size of your TypeScript project.

Can I use built-in services like ConsoleLogger and JoseJWTService in my dependency injection setup?

Yes, you can use built-in services like ConsoleLogger and JoseJWTService in your dependency injection setup. These services are included as part of the framework's typing guidance, allowing you to wire them directly into your singleton or per-request service configurations.

What's the best way to wire per-request services for specific transports in a Pikku project?

The best way to wire per-request services for specific transports in a Pikku project is by using the pikkuWireServices factory. This function dynamically creates and injects dependencies based on the individual transport or context of each incoming request.