All files / src/lib/core constants.ts

100% Statements 227/227
100% Branches 0/0
0% Functions 0/6
100% Lines 227/227

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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 2281x 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 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  
/**
 * Application Constants
 *
 * Centralized location for application-wide constants.
 * Domain-specific constants remain in their respective modules.
 */
 
// =============================================================================
// API ENDPOINTS
// =============================================================================
 
export const API_ROUTES = {
  // Auth
  AUTH: {
    SIGNUP: "/api/auth/signup",
    LOGIN: "/api/auth/callback/credentials",
    LOGOUT: "/api/auth/signout",
    SESSION: "/api/auth/session",
    VERIFY_EMAIL: "/api/auth/verify-email",
    RESET_PASSWORD: "/api/auth/reset-password",
    RESEND_VERIFICATION: "/api/auth/resend-verification"},
  // User
  USER: {
    PROFILE: "/api/user/profile",
    ADDRESSES: "/api/user/addresses",
    PASSWORD: "/api/user/password"},
  // Products
  PRODUCTS: {
    LIST: "/api/products",
    DETAIL: (id: number | string) => `/api/products/${id}`,
    SEARCH: "/api/products/search",
    SUGGESTIONS: "/api/products/search/suggestions",
    FILTERS: "/api/products/filters"},
  // Cart
  CART: {
    BASE: "/api/cart",
    ITEM: (id: number | string) => `/api/cart/${id}`,
    MERGE: "/api/cart/merge"},
  // Wishlist
  WISHLIST: {
    BASE: "/api/wishlist",
    ITEM: (id: number | string) => `/api/wishlist/${id}`},
  // Orders
  ORDERS: {
    BASE: "/api/orders",
    DETAIL: (id: number | string) => `/api/orders/${id}`},
  // Reviews
  REVIEWS: {
    BASE: "/api/reviews",
    DETAIL: (id: number | string) => `/api/reviews/${id}`},
  // Categories
  CATEGORIES: "/api/categories",
  // Comparison
  COMPARISON: "/api/comparison",
  // Payments
  PAYMENTS: {
    BASE: "/api/payments",
    CREATE_INTENT: "/api/payments/create-intent"},
  // Admin
  ADMIN: {
    DASHBOARD: "/api/admin/dashboard",
    PRODUCTS: "/api/admin/products",
    ORDERS: "/api/admin/orders",
    CATEGORIES: "/api/admin/categories",
    REPORTS: "/api/admin/reports",
    IMAGES: {
      AUDIT: "/api/admin/images/audit",
      UPLOAD: "/api/admin/products/images"}}} as const;
 
// =============================================================================
// APPLICATION ROUTES
// =============================================================================
 
export const APP_ROUTES = {
  HOME: "/",
  SHOP: "/shop",
  PRODUCT: (id: number | string) => `/product/${id}`,
  CART: "/cart",
  CHECKOUT: "/checkout",
  WISHLIST: "/wishlist",
  COMPARE: "/compare",
  ACCOUNT: "/my-account",
  LOGIN: "/signin",
  SIGNUP: "/signup",
  CONTACT: "/contact",
  ABOUT: "/about",
  // Admin Routes
  ADMIN: {
    DASHBOARD: "/admin",
    PRODUCTS: "/admin/products",
    ORDERS: "/admin/orders",
    CATEGORIES: "/admin/categories",
    USERS: "/admin/users"}} as const;
 
// =============================================================================
// PAGINATION DEFAULTS
// =============================================================================
 
export const PAGINATION = {
  DEFAULT_PAGE: 1,
  DEFAULT_LIMIT: 12,
  MAX_LIMIT: 100,
  PRODUCTS_PER_PAGE_OPTIONS: [9, 12, 18, 24, 36] as const} as const;
 
// =============================================================================
// VALIDATION LIMITS
// =============================================================================
 
export const LIMITS = {
  // Text lengths
  NAME_MIN: 2,
  NAME_MAX: 100,
  EMAIL_MAX: 255,
  PASSWORD_MIN: 8,
  PASSWORD_MAX: 128,
  PHONE_MAX: 20,
  DESCRIPTION_MAX: 5000,
  REVIEW_MAX: 2000,
  // Numeric
  MIN_PRICE: 0,
  MAX_PRICE: 1000000,
  MIN_QUANTITY: 1,
  MAX_QUANTITY: 99,
  MAX_CART_ITEMS: 50,
  MAX_WISHLIST_ITEMS: 100,
  // File sizes (bytes)
  MAX_IMAGE_SIZE: 5 * 1024 * 1024, // 5MB
  MAX_FILE_SIZE: 10 * 1024 * 1024, // 10MB
} as const;
 
// =============================================================================
// HTTP STATUS CODES
// =============================================================================
 
export const HTTP_STATUS = {
  OK: 200,
  CREATED: 201,
  NO_CONTENT: 204,
  BAD_REQUEST: 400,
  UNAUTHORIZED: 401,
  FORBIDDEN: 403,
  NOT_FOUND: 404,
  CONFLICT: 409,
  UNPROCESSABLE: 422,
  TOO_MANY_REQUESTS: 429,
  INTERNAL_ERROR: 500,
  SERVICE_UNAVAILABLE: 503} as const;
 
// =============================================================================
// ERROR CODES
// =============================================================================
 
export const ERROR_CODES = {
  // Auth
  INVALID_CREDENTIALS: "INVALID_CREDENTIALS",
  EMAIL_NOT_VERIFIED: "EMAIL_NOT_VERIFIED",
  ACCOUNT_LOCKED: "ACCOUNT_LOCKED",
  SESSION_EXPIRED: "SESSION_EXPIRED",
  // Validation
  VALIDATION_ERROR: "VALIDATION_ERROR",
  INVALID_INPUT: "INVALID_INPUT",
  // Resources
  NOT_FOUND: "NOT_FOUND",
  ALREADY_EXISTS: "ALREADY_EXISTS",
  CONFLICT: "CONFLICT",
  // Rate limiting
  RATE_LIMIT_EXCEEDED: "RATE_LIMIT_EXCEEDED",
  // Server
  INTERNAL_ERROR: "INTERNAL_ERROR",
  SERVICE_UNAVAILABLE: "SERVICE_UNAVAILABLE",
  // Database
  DATABASE_ERROR: "DATABASE_ERROR"} as const;
 
// =============================================================================
// DATE/TIME FORMATS
// =============================================================================
 
export const DATE_FORMATS = {
  DISPLAY: "MMM d, yyyy",
  DISPLAY_WITH_TIME: "MMM d, yyyy h:mm a",
  ISO: "yyyy-MM-dd",
  ISO_WITH_TIME: "yyyy-MM-dd'T'HH:mm:ss"} as const;
 
// =============================================================================
// CURRENCY
// =============================================================================
 
export const CURRENCY = {
  CODE: "USD",
  SYMBOL: "$",
  LOCALE: "en-US"} as const;
 
// =============================================================================
// BREAKPOINTS (match Tailwind defaults)
// =============================================================================
 
export const BREAKPOINTS = {
  SM: 640,
  MD: 768,
  LG: 1024,
  XL: 1280,
  "2XL": 1536} as const;
 
// =============================================================================
// STORAGE KEYS
// =============================================================================
 
export const STORAGE_KEYS = {
  CART: "cart",
  WISHLIST: "wishlist",
  RECENT_PRODUCTS: "recent_products",
  COMPARISON: "comparison_products",
  THEME: "theme",
  DEVICE_ID: "device_id",
  ANONYMOUS_SESSION: "anonymous_session"} as const;
 
// =============================================================================
// COOKIE NAMES
// =============================================================================
 
export const COOKIE_NAMES = {
  SESSION: "next-auth.session-token",
  CSRF: "next-auth.csrf-token",
  CART: "cart",
  DEVICE_ID: "device_id",
  ANONYMOUS_SESSION: "anon_session_id",
  CART_VERSION: "cart_version"} as const;