first iteration on frontend, done by claude because i'm lazy with frontend

This commit is contained in:
2026-05-20 12:02:51 -06:00
parent 887ad1e981
commit 64efed0809
49 changed files with 11864 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import client from './client'
import type { User } from '@/stores/auth'
export interface LoginPayload {
email: string
password: string
}
export interface AuthResponse {
token: string
user: User
}
export const authApi = {
login: (payload: LoginPayload) =>
client.post<AuthResponse>('/auth/login', payload),
me: () =>
client.get<User>('/me'),
}
+25
View File
@@ -0,0 +1,25 @@
import axios from 'axios'
const client = axios.create({
baseURL: '/api',
headers: { 'Content-Type': 'application/json' },
})
client.interceptors.request.use((config) => {
const token = localStorage.getItem('token')
if (token) config.headers.Authorization = `Bearer ${token}`
return config
})
client.interceptors.response.use(
(res) => res,
(err) => {
if (err.response?.status === 401) {
localStorage.removeItem('token')
window.location.href = '/login'
}
return Promise.reject(err)
}
)
export default client