created proxy for parser backend

This commit is contained in:
2025-05-22 23:31:17 +05:00
parent 9faf3f7618
commit 8e4ce66cc4
14 changed files with 146 additions and 15 deletions
+46
View File
@@ -0,0 +1,46 @@
class AuthService {
private API_BASE = '/api/auth'
private hashPassword(password: string) {
// TODO: password hashing
return password
}
async login(email: string, password: string) {
const response = await fetch(`${this.API_BASE}/login`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email,
password: this.hashPassword(password),
}),
})
if (!response.ok) {
throw new Error('Login failed')
}
return await response.json()
}
async register(name: string, email: string, password: string) {
const response = await fetch(`${this.API_BASE}/register`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
name,
email,
password: this.hashPassword(password),
}),
})
if (!response.ok) {
throw new Error('Registration failed')
}
return await response.json()
}
}
// Export a singleton instance
export const authService = new AuthService()