nodefony-add-service

Creates injectable services registered in the Nodefony dependency injection container.

Updated Dec 19, 2023
One-click install
npx skills add https://github.com/nodefony/nodefony-core --skill nodefony-add-service-nodefony
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nodefony-add-service
Source: https://github.com/nodefony/nodefony-core/tree/main/src/packages/%40nodefony/devkit/skills/nodefony-add-service
Command: npx skills add https://github.com/nodefony/nodefony-core --skill nodefony-add-service-nodefony

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Hand-written Nodefony services often compile and pass tests yet remain invisible to the dependency injection container, producing silent undefined failures at runtime. This Skill ensures services are created with the generator and properly registered so the container actually knows them. ## Core Features & Use Cases - Service scaffolding: Runs nodefony create service to generate an @injectable() class extending Service, its interface, and its registration in the target's @services([...]) declaration. - Dependency wiring: Uses --inject to declare constructor dependencies via @inject, with pre-write validation that refuses missing targets and self-injection. - Name disambiguation: Clarifies the distinction between the class name used by @inject("BillingService") and the instance name used by container.get("billing"). - Verification workflow: Uses nodefony doctor and nodefony inspect services to prove the container actually holds the service at boot. - Use Case: You need shared business logic (e.g., a Billing service) callable from other services; the Skill generates it, registers it, injects its dependencies, and verifies container registration. ## Quick Start Ask the assistant to create an injectable Nodefony service named Billing and verify it appears in the container with nodefony inspect services.

Frequently Asked Questions about nodefony-add-service

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

FAQPage Schema
How do I create an injectable service in Nodefony?

Run npx nodefony create service Billing to generate an @injectable() class extending Service, its interface, and its registration in the target's @services([...]) list. The generator creates the registration even if none exists yet.

How do I inject one Nodefony service into another?

Use npx nodefony create service Invoice --inject Billing to declare the dependency with @inject at the constructor. The command refuses to write if the target service does not exist and rejects self-injection.

Why is my Nodefony service undefined in the container?

A class with @injectable that is never declared in a @services([...]) list stays invisible to the container, producing undefined at runtime with no compile error. Run npx nodefony doctor to detect the orphan and npx nodefony inspect services to confirm registration.

What is the difference between @inject and container.get in Nodefony?

@inject("X") at the constructor declares the dependency so startup ordering respects it, and is the default choice. container.get("x") at usage time suits optional, late, or runtime-chosen dependencies, but declaring is preferred over looking up.

What is the difference between a Nodefony service class name and instance name?

The class name (e.g., BillingService) is what @inject("BillingService") references, while the instance name passed to super("billing", ...) is what container.get("billing") uses. Confusing the two causes silent undefined lookups.