Инициализация проекта
Загрузка проекта на GIT
This commit is contained in:
61
front_vue/src/api.js
Normal file
61
front_vue/src/api.js
Normal file
@@ -0,0 +1,61 @@
|
||||
// Базовый URL API (берётся из внешнего config.js)
|
||||
const API_BASE = window.APP_CONFIG?.API_BASE || 'http://localhost'
|
||||
|
||||
// Базовая функция запроса
|
||||
const request = async (endpoint, options = {}) => {
|
||||
const res = await fetch(`${API_BASE}${endpoint}`, options)
|
||||
return res.json()
|
||||
}
|
||||
|
||||
// ==================== AUTH ====================
|
||||
export const authApi = {
|
||||
login: (data) => request('/auth', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data)
|
||||
}),
|
||||
check: () => request('/check-auth', { credentials: 'include' }),
|
||||
logout: () => request('/logout', { credentials: 'include' })
|
||||
}
|
||||
|
||||
// ==================== DEPARTMENTS ====================
|
||||
export const departmentsApi = {
|
||||
getAll: () => request('/departments', { credentials: 'include' })
|
||||
}
|
||||
|
||||
// ==================== LABELS ====================
|
||||
export const labelsApi = {
|
||||
getAll: () => request('/labels', { credentials: 'include' })
|
||||
}
|
||||
|
||||
// ==================== COLUMNS ====================
|
||||
export const columnsApi = {
|
||||
getAll: () => request('/columns', { credentials: 'include' })
|
||||
}
|
||||
|
||||
// ==================== CARDS ====================
|
||||
export const cardsApi = {
|
||||
getAll: () => request('/cards', { credentials: 'include' }),
|
||||
create: (data) => request('/cards', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data)
|
||||
}),
|
||||
update: (id, data) => request(`/cards/${id}`, {
|
||||
method: 'PUT',
|
||||
credentials: 'include',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(data)
|
||||
}),
|
||||
delete: (id) => request(`/cards/${id}`, {
|
||||
method: 'DELETE',
|
||||
credentials: 'include'
|
||||
})
|
||||
}
|
||||
|
||||
// ==================== USERS ====================
|
||||
export const usersApi = {
|
||||
getAll: () => request('/users', { credentials: 'include' })
|
||||
}
|
||||
Reference in New Issue
Block a user