feat: add staff and user authentication APIs with request handling

This commit is contained in:
Ardeman
2025-03-03 15:42:12 +08:00
parent 1b4ff4c3e7
commit ba19a4dc5b
7 changed files with 66 additions and 6 deletions
+20
View File
@@ -0,0 +1,20 @@
import { z } from 'zod'
import { type TLoginSchema } from '~/layouts/news/form-login'
import { HttpServer } from '~/libs/http-server'
const loginResponseSchema = z.object({
data: z.object({
token: z.string(),
}),
})
export const staffLoginRequest = async (payload: TLoginSchema) => {
try {
const { data } = await HttpServer().post('/api/staff/login', payload)
return loginResponseSchema.parse(data)
} catch (error) {
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
return Promise.reject(error)
}
}