generated from fahricansecer/boilerplate-fe
Initial commit
This commit is contained in:
50
src/lib/api/example/auth/service.ts
Normal file
50
src/lib/api/example/auth/service.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import { apiRequest } from "@/lib/api/api-service";
|
||||
import { ApiResponse } from "@/types/api-response";
|
||||
import { LoginDto, RegisterDto, RefreshTokenDto, AuthResponse } from "./types";
|
||||
|
||||
/**
|
||||
* Auth Service - Example Implementation
|
||||
* Matches Backend: /api/auth/*
|
||||
*/
|
||||
|
||||
const login = (data: LoginDto) => {
|
||||
return apiRequest<ApiResponse<AuthResponse>>({
|
||||
url: "/auth/login",
|
||||
client: "auth",
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
const register = (data: RegisterDto) => {
|
||||
return apiRequest<ApiResponse<AuthResponse>>({
|
||||
url: "/auth/register",
|
||||
client: "auth",
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
const refreshToken = (data: RefreshTokenDto) => {
|
||||
return apiRequest<ApiResponse<AuthResponse>>({
|
||||
url: "/auth/refresh",
|
||||
client: "auth",
|
||||
method: "post",
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
const logout = () => {
|
||||
return apiRequest<ApiResponse<null>>({
|
||||
url: "/auth/logout",
|
||||
client: "auth",
|
||||
method: "post",
|
||||
});
|
||||
};
|
||||
|
||||
export const authService = {
|
||||
login,
|
||||
register,
|
||||
refreshToken,
|
||||
logout,
|
||||
};
|
||||
Reference in New Issue
Block a user