const API_BASE_URL = import.meta.env.VITE_API_BASE_URL || 'http://localhost:8000';

const API_V1_PREFIX = '/api/v1';

const API_SOURCES = {
    AUTH: `${API_BASE_URL}${API_V1_PREFIX}/auth`,
    USERS: `${API_BASE_URL}${API_V1_PREFIX}/users`,
    TASKS: `${API_BASE_URL}${API_V1_PREFIX}/tasks`,
}

const API_ENDPOINTS = {
    AUTH: {
        LOGIN: `${API_SOURCES.AUTH}/login`,
        REFRESH: `${API_SOURCES.AUTH}/refresh`,
        LOGOUT: `${API_SOURCES.AUTH}/logout`,
        ME: `${API_SOURCES.AUTH}/me`,
        REGISTER: `${API_SOURCES.AUTH}/signup`,
    },

    USERS: {
        LIST: API_SOURCES.USERS,
        BY_ID: (id) => `${API_SOURCES.USERS}/${id}`,
        TASKS: (id) => `${API_SOURCES.USERS}/${id}/tasks`,
        UPDATE: (id) => `${API_SOURCES.USERS}/${id}`,
        DELETE: (id) => `${API_SOURCES.USERS}/${id}`,
    },

    TASKS: {
        BY_ID: (id) => `${API_SOURCES.TASKS}/${id}`,
        CREATE: `${API_SOURCES.TASKS}`,
        UPDATE: (id) => `${API_SOURCES.TASKS}/${id}`,
        DELETE: (id) => `${API_SOURCES.TASKS}/${id}`,
    },
};


export { API_BASE_URL, API_V1_PREFIX, API_SOURCES, API_ENDPOINTS };