nodejslisted
Install: claude install-skill Squirrelfishcityhall150/claude-code-kit
# Node.js Backend Patterns
## Purpose
Core patterns for building scalable Node.js backend applications with TypeScript, emphasizing clean architecture, error handling, and testability.
## When to Use This Skill
- Building Node.js backend services
- Implementing async/await patterns
- Error handling and logging
- Configuration management
- Testing backend code
- Layered architecture (routes → controllers → services → repositories)
---
## Quick Start
### Layered Architecture
```
src/
├── api/
│ ├── routes/ # HTTP route definitions
│ ├── controllers/ # Request/response handling
│ ├── services/ # Business logic
│ └── repositories/ # Data access
├── middleware/ # Express middleware
├── types/ # TypeScript types
├── config/ # Configuration
└── utils/ # Utilities
```
**Flow:** Route → Controller → Service → Repository → Database
---
## Async/Await Error Handling
### Basic Pattern
```typescript
async function fetchUser(id: string): Promise<User> {
try {
const user = await db.user.findUnique({ where: { id } });
if (!user) {
throw new Error('User not found');
}
return user;
} catch (error) {
console.error('Error fetching user:', error);
throw error;
}
}
```
### Async Controller Pattern
```typescript
class UserController {
async getUser(req: Request, res: Response): Promise<void> {
try {
const { id } = req.params;
const user = await this.userService.