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

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

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 1061x 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  
/**
 * Auth Endpoints
 * Authentication, registration, and password management endpoints
 */
 
import type { ApiEndpoint } from '@/types/api-docs';
 
export const authEndpoints: ApiEndpoint[] = [
  {
    id: 'auth-signup',
    method: 'POST',
    path: '/api/auth/signup',
    summary: 'Register a new user',
    description: 'Creates a new user account with email and password',
    category: 'auth',
    requiresAuth: false,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'email', type: 'string', required: true, description: 'User email address' },
        { name: 'password', type: 'string', required: true, description: 'Password (min 8 characters)' },
        { name: 'name', type: 'string', required: false, description: 'User display name' },
      ],
      example: { email: 'user@example.com', password: 'securepassword123', name: 'John Doe' },
    },
    responses: [
      { status: 201, description: 'User created successfully', example: { success: true, message: 'Account created' } },
      { status: 400, description: 'Invalid input data' },
      { status: 409, description: 'Email already exists' },
    ],
  },
  {
    id: 'auth-forgot-password',
    method: 'POST',
    path: '/api/auth/forgot-password',
    summary: 'Request password reset',
    description: 'Sends a password reset email to the user',
    category: 'auth',
    requiresAuth: false,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'email', type: 'string', required: true, description: 'User email address' },
      ],
      example: { email: 'user@example.com' },
    },
    responses: [
      { status: 200, description: 'Reset email sent (always returns success for security)' },
    ],
  },
  {
    id: 'auth-reset-password',
    method: 'POST',
    path: '/api/auth/reset-password',
    summary: 'Reset password with token',
    description: 'Resets user password using the token from email',
    category: 'auth',
    requiresAuth: false,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'token', type: 'string', required: true, description: 'Reset token from email' },
        { name: 'password', type: 'string', required: true, description: 'New password' },
      ],
      example: { token: 'abc123...', password: 'newpassword123' },
    },
    responses: [
      { status: 200, description: 'Password reset successfully' },
      { status: 400, description: 'Invalid or expired token' },
    ],
  },
  {
    id: 'auth-verify-email',
    method: 'POST',
    path: '/api/auth/verify-email',
    summary: 'Verify email address',
    description: 'Verifies user email with the token sent via email',
    category: 'auth',
    requiresAuth: false,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'token', type: 'string', required: true, description: 'Verification token from email' },
      ],
      example: { token: 'verification-token-123' },
    },
    responses: [
      { status: 200, description: 'Email verified successfully' },
      { status: 400, description: 'Invalid or expired token' },
    ],
  },
  {
    id: 'auth-resend-verification',
    method: 'POST',
    path: '/api/auth/resend-verification',
    summary: 'Resend verification email',
    description: 'Sends a new verification email to the user',
    category: 'auth',
    requiresAuth: true,
    responses: [
      { status: 200, description: 'Verification email sent' },
      { status: 400, description: 'Email already verified' },
    ],
  },
];