All files / src/lib/api-docs/endpoints products.ts

100% Statements 159/159
100% Branches 0/0
100% Functions 0/0
100% Lines 159/159

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 1601x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * Products Endpoints
 * Product catalog, search, and filtering endpoints
 */
 
import type { ApiEndpoint } from '@/types/api-docs';
 
export const productsEndpoints: ApiEndpoint[] = [
  {
    id: 'products-list',
    method: 'GET',
    path: '/api/products',
    summary: 'List all products',
    description: 'Returns paginated list of products with optional filters',
    category: 'products',
    requiresAuth: false,
    parameters: [
      { name: 'page', type: 'number', required: false, location: 'query', description: 'Page number', example: 1 },
      { name: 'limit', type: 'number', required: false, location: 'query', description: 'Items per page', example: 20 },
      { name: 'category', type: 'string', required: false, location: 'query', description: 'Filter by category slug' },
      { name: 'search', type: 'string', required: false, location: 'query', description: 'Search term' },
      { name: 'minPrice', type: 'number', required: false, location: 'query', description: 'Minimum price filter' },
      { name: 'maxPrice', type: 'number', required: false, location: 'query', description: 'Maximum price filter' },
      { name: 'sort', type: 'string', required: false, location: 'query', description: 'Sort field', enum: ['price', 'name', 'createdAt'] },
      { name: 'order', type: 'string', required: false, location: 'query', description: 'Sort order', enum: ['asc', 'desc'] },
    ],
    responses: [
      {
        status: 200,
        description: 'List of products',
        example: {
          success: true,
          data: {
            products: [
              { id: 1, name: 'Product', price: 99.99, slug: 'product-1', categoryId: 1 },
            ],
            pagination: { page: 1, limit: 20, total: 100, totalPages: 5 },
          },
        },
      },
    ],
  },
  {
    id: 'products-get',
    method: 'GET',
    path: '/api/products/{id}',
    summary: 'Get product by ID',
    description: 'Returns a single product with full details',
    category: 'products',
    requiresAuth: false,
    parameters: [
      { name: 'id', type: 'number', required: true, location: 'path', description: 'Product ID' },
    ],
    responses: [
      {
        status: 200,
        description: 'Product details',
        example: {
          success: true,
          data: {
            id: 1,
            name: 'Product Name',
            description: 'Product description',
            price: 99.99,
            slug: 'product-name',
            images: ['/images/product1.jpg'],
            category: { id: 1, name: 'Category' },
            reviews: [],
          },
        },
      },
      {
        status: 404,
        description: 'Product not found',
        example: { success: false, error: { code: 'NOT_FOUND', message: 'Product not found' } },
      },
    ],
  },
  {
    id: 'products-search',
    method: 'GET',
    path: '/api/products/search',
    summary: 'Search products',
    description: 'Search products by query with full-text search',
    category: 'products',
    requiresAuth: false,
    parameters: [
      { name: 'q', type: 'string', required: true, location: 'query', description: 'Search query' },
      { name: 'page', type: 'number', required: false, location: 'query', description: 'Page number' },
      { name: 'limit', type: 'number', required: false, location: 'query', description: 'Items per page' },
    ],
    responses: [
      {
        status: 200,
        description: 'Search results',
        example: {
          success: true,
          data: {
            results: [
              { id: 1, name: 'Product', price: 99.99, slug: 'product-1' },
            ],
            pagination: { page: 1, limit: 20, total: 10, totalPages: 1 },
          },
        },
      },
    ],
  },
  {
    id: 'products-search-suggestions',
    method: 'GET',
    path: '/api/products/search/suggestions',
    summary: 'Get search suggestions',
    description: 'Returns autocomplete suggestions for product search',
    category: 'products',
    requiresAuth: false,
    parameters: [
      { name: 'q', type: 'string', required: true, location: 'query', description: 'Search query', example: 'chair' },
      { name: 'limit', type: 'number', required: false, location: 'query', description: 'Max suggestions', example: 5 },
    ],
    responses: [
      {
        status: 200,
        description: 'List of suggestions',
        example: {
          success: true,
          data: {
            suggestions: [
              { id: 1, title: 'Office Chair', slug: 'office-chair' },
              { id: 2, title: 'Gaming Chair', slug: 'gaming-chair' },
            ],
          },
        },
      },
    ],
  },
  {
    id: 'products-filters',
    method: 'GET',
    path: '/api/products/filters',
    summary: 'Get available filters',
    description: 'Returns available filter options based on current products',
    category: 'products',
    requiresAuth: false,
    responses: [
      {
        status: 200,
        description: 'Filter options',
        example: {
          success: true,
          data: {
            categories: [{ id: 1, name: 'Category', slug: 'category' }],
            priceRange: { min: 0, max: 1000 },
            brands: ['Brand A', 'Brand B'],
          },
        },
      },
    ],
  },
];