hm-nodejs-business-logic

Implements service layer, repository pattern, and dependency injection in Fastify TypeScript projects.

Updated Apr 26, 2026
One-click install
npx skills add https://github.com/ArkhiMuttaqina/publisher-for-campuss --skill hm-nodejs-business-logic-arkhimuttaqina
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: hm-nodejs-business-logic
Source: https://github.com/ArkhiMuttaqina/publisher-for-campuss/tree/main/skills/hm-nodejs-business-logic
Command: npx skills add https://github.com/ArkhiMuttaqina/publisher-for-campuss --skill hm-nodejs-business-logic-arkhimuttaqina

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? It prevents business logic from leaking into HTTP route handlers by enforcing a strict three-layer architecture where services own domain rules, repositories own Prisma queries, and controllers only handle HTTP concerns. ## Core Features & Use Cases - Repository Pattern: Encapsulates all Prisma queries behind clean interfaces so services never import @prisma/client directly. - Service Layer with DI: Provides factory-function dependency injection and guidance on when to adopt containers like tsyringe. - Transactions & Background Jobs: Covers Prisma interactive transactions and dispatching BullMQ jobs from services. - Use Case: When building an order module in a Fastify + TypeScript API, use this Skill to structure order.service.ts, order.repository.ts, and wire them in module.ts with proper error handling and job dispatch. ## Quick Start Ask the AI to create a new service and repository for an order module following the three-layer architecture with Prisma and BullMQ.

Frequently Asked Questions about hm-nodejs-business-logic

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

FAQPage Schema
How do I structure business logic in a Node.js Fastify project?▼

Place all business logic in a service layer between controllers and repositories. Controllers handle HTTP request/response, services enforce domain rules and call repositories, and repositories encapsulate all Prisma queries.

How to implement the repository pattern with Prisma in TypeScript?▼

Create a repository module that wraps Prisma client methods like findUnique, findMany, create, update, and delete behind a clean interface. Services depend on this interface, never importing @prisma/client directly, which makes repositories mockable in tests.

When should I use a DI container like tsyringe in Node.js?▼

Start with factory functions and constructor injection for simple projects. Move to a DI container like tsyringe or inversify only when manual wiring becomes painful, typically around 10 or more services with cross-dependencies.

Can I call external APIs inside a Prisma transaction?▼

No, external API calls should never happen inside a Prisma interactive transaction. Long-running transactions hold database locks, so keep transactions short and move external calls outside the transaction boundary.

How do I dispatch background jobs from a service layer?▼

Dispatch BullMQ jobs from the service using queue.add with a plain serializable payload, such as sending an order confirmation email after order creation. Services dispatch jobs but never process them; workers handle processing, and jobs should be idempotent.