chore: init project

This commit is contained in:
cesnimda
2026-06-30 15:53:32 +02:00
commit f43ef5f945
94 changed files with 4405 additions and 0 deletions
+57
View File
@@ -0,0 +1,57 @@
import axios from 'axios';
// Cookie-based auth (Google OAuth2 session), so send credentials with each call.
const api = axios.create({ baseURL: '/api/v1', withCredentials: true });
api.interceptors.response.use(
(r) => r,
(err) => {
if (err.response?.status === 401) {
// Not signed in — kick off the Google login flow.
window.location.href = '/api/v1/auth/login?returnUrl=/';
}
return Promise.reject(err);
}
);
export const AuthApi = {
me: () => api.get('/auth/me').then((r) => r.data),
logout: () => api.post('/auth/logout')
};
export const SyncApi = {
status: () => api.get('/sync/status').then((r) => r.data),
full: () => api.post('/sync/full'),
incremental: () => api.post('/sync/incremental')
};
export const AnalyticsApi = {
dashboard: () => api.get('/analytics/dashboard').then((r) => r.data),
health: () => api.get('/analytics/health').then((r) => r.data),
topSenders: (take = 20) => api.get(`/analytics/top-senders?take=${take}`).then((r) => r.data),
volume: (days = 90) => api.get(`/analytics/volume?days=${days}`).then((r) => r.data),
heatmap: () => api.get('/analytics/heatmap').then((r) => r.data),
attachments: () => api.get('/analytics/attachments').then((r) => r.data)
};
export const CleanupApi = {
preview: (req) => api.post('/cleanup/preview', req).then((r) => r.data),
execute: (req) => api.post('/cleanup/execute', req).then((r) => r.data)
};
export const UnsubscribeApi = {
detect: () => api.post('/unsubscribe/detect'),
safeList: () => api.get('/unsubscribe/safe-list').then((r) => r.data),
process: (req) => api.post('/unsubscribe/process', req).then((r) => r.data)
};
export const LayoutApi = {
get: () => api.get('/widgetlayout').then((r) => r.data),
save: (layout) => api.put('/widgetlayout', layout)
};
export const ExportApi = {
reportUrl: (format) => `/api/v1/export/report?format=${format}`
};
export default api;