Guides

In-depth tutorials for advanced features and best practices.

Best Practices

1. Organize Your Endpoints

Use clear, RESTful naming conventions for your endpoints:

  • GET /users - List all users
  • GET /users/:id - Get specific user
  • POST /users - Create new user
  • PATCH /users/:id - Update user
  • DELETE /users/:id - Delete user

2. Keep Mock Data Realistic

Use realistic data structures and values that match your production API:

{
  "user": {
    "id": "usr_1a2b3c4d",
    "email": "sarah.connor@example.com",
    "firstName": "Sarah",
    "lastName": "Connor",
    "role": "admin",
    "createdAt": "2026-01-15T09:30:00Z",
    "lastLogin": "2026-01-22T08:15:00Z"
  }
}

3. Use Workspaces for Different Projects

Create separate workspaces for:

  • Different applications or microservices
  • Development, staging, and testing environments
  • Client projects
  • Team experiments

4. Version Your Mock APIs

Include version numbers in your paths for better compatibility:

✓ Good: /v1/users

✓ Good: /v2/users

✗ Avoid: /users (no version)

Authentication & Security

Simulating Authentication

MockBoost doesn't enforce auth on your mock endpoints by default, allowing easy testing. However, you can simulate auth flows:

Login Endpoint Example

Create a POST /auth/login endpoint with response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "user": {
    "id": 1,
    "email": "user@example.com"
  },
  "expiresIn": 3600
}

Unauthorized Response (401)

Create another endpoint with status code 401:

{
  "error": "Unauthorized",
  "message": "Invalid credentials"
}

Testing Error Scenarios

Create multiple endpoints with different status codes to test error handling:

  • 200 OK: Successful response
  • 400 Bad Request: Validation errors
  • 401 Unauthorized: Authentication required
  • 403 Forbidden: Insufficient permissions
  • 404 Not Found: Resource doesn't exist
  • 500 Server Error: Backend failure

🔒 Security Recommendations

  • Don't use MockBoost for production data
  • Avoid storing sensitive information in mock responses
  • Keep workspace invitations limited to trusted team members
  • Regularly review and remove unused endpoints

Webhooks & Integrations

🚀 Coming Soon

Webhook support and third-party integrations are currently in development. Stay tuned for updates!

Planned Features

  • Webhook endpoints to trigger external services
  • Slack notifications for API requests
  • GitHub integration for syncing mock data
  • Zapier integration for workflow automation

Testing with MockBoost

Frontend Testing

Use MockBoost to test your frontend without a backend:

// React example
const API_URL = process.env.NEXT_PUBLIC_API_URL || 
  'http://localhost:3001';

fetch(`${API_URL}/v1/workspaces/your-workspace/users`)
  .then(res => res.json())
  .then(data => setUsers(data));

End-to-End Testing

Configure your E2E tests to use MockBoost endpoints:

// Cypress example
describe('User Dashboard', () => {
  beforeEach(() => {
    cy.intercept('GET', '/api/users', {
      fixture: 'mockboost-users.json'
    });
  });

  it('displays user list', () => {
    cy.visit('/dashboard');
    cy.get('.user-item').should('have.length', 5);
  });
});

API Contract Testing

Ensure your frontend matches backend expectations:

  1. Create mock data matching your API contract
  2. Test frontend against mock endpoints
  3. Verify all required fields are handled
  4. Test error states and edge cases
  5. Update mocks when API contract changes

Performance Tips

Optimize Mock Data Size

Keep your mock responses lightweight:

  • Limit array sizes to realistic pagination limits
  • Remove unnecessary nested objects
  • Use pagination parameters to control data size
  • Compress large text fields

Caching Strategy

MockBoost responses can be cached by your application:

// Cache mock responses during development
const cache = new Map();

async function fetchMockData(url) {
  if (cache.has(url)) {
    return cache.get(url);
  }
  
  const data = await fetch(url).then(r => r.json());
  cache.set(url, data);
  return data;
}

⚡ JSONB + GIN Performance

MockBoost uses PostgreSQL's JSONB with GIN indexing for ultra-fast queries:

  • < 50ms latency: Even with large datasets
  • O(1) access: Direct key lookups
  • Dynamic filtering: Query deep JSON structures
  • Zero overhead: No performance penalty for complex queries

Migrating to Production

When to Switch from Mocks

MockBoost is perfect for development and testing, but you should migrate to a real API when:

  • Your backend is ready and deployed
  • You need real data persistence
  • You're moving to production
  • You need complex business logic

Smooth Transition

Use environment variables to switch between mock and production APIs:

// .env.development
NEXT_PUBLIC_API_URL=http://localhost:3001

// .env.production
NEXT_PUBLIC_API_URL=https://api.yourapp.com

// Your code
const API_URL = process.env.NEXT_PUBLIC_API_URL;