# Node.js Express Code Examples

Reference examples for each rule area. Read the relevant section when generating code for that area.

---

## Express Rules

```javascript
// ✅ Good: Controller calls service
export const createUser = async (req, res, next) => {
    const userData = req.body;
    const user = await userService.create(userData);
    res.status(201).json(user);
};
```

---

## Testing

```javascript
// Example test
import request from 'supertest';
import app from '../app';

describe('POST /api/users', () => {
    it('should create a new user', async () => {
        const response = await request(app)
            .post('/api/users')
            .send({ email: 'test@example.com', password: 'password123' });
        expect(response.status).toBe(201);
    });
});
```
