Project started 🥂
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { api } from '../index';
|
||||
import type { LoginRequest, LoginResponse } from '../types';
|
||||
|
||||
export const authApi = api.injectEndpoints({
|
||||
endpoints: (build) => ({
|
||||
login: build.mutation<LoginResponse, LoginRequest>({
|
||||
query: (body) => ({ url: '/auth/login', method: 'POST', body }),
|
||||
}),
|
||||
logout: build.mutation<void, void>({
|
||||
query: () => ({ url: '/auth/logout', method: 'POST' }),
|
||||
}),
|
||||
refreshToken: build.mutation<{ accessToken: string; refreshToken: string; expiresIn: number }, { refreshToken: string }>({
|
||||
query: (body) => ({ url: '/auth/refresh', method: 'POST', body }),
|
||||
}),
|
||||
me: build.query<import('../types').User, void>({
|
||||
query: () => '/auth/me',
|
||||
providesTags: ['User'],
|
||||
}),
|
||||
}),
|
||||
overrideExisting: false,
|
||||
});
|
||||
|
||||
export const { useLoginMutation, useLogoutMutation, useMeQuery } = authApi;
|
||||
Reference in New Issue
Block a user