-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from ninoseki/introduce-zod
refactor: introduce Zod
- Loading branch information
Showing
46 changed files
with
316 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
import axios from 'axios' | ||
|
||
import type { Response, Status } from '@/types' | ||
import { ResponseSchema, type ResponseType, StatusSchema, type StatusType } from '@/schemas' | ||
|
||
const client = axios.create() | ||
|
||
export const API = { | ||
async analyze(file: File): Promise<Response> { | ||
async analyze(file: File): Promise<ResponseType> { | ||
const formData = new FormData() | ||
formData.append('file', file) | ||
const res = await client.post<Response>('/api/analyze/file', formData, { | ||
const res = await client.post('/api/analyze/file', formData, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data' | ||
} | ||
}) | ||
return res.data | ||
return ResponseSchema.parse(res.data) | ||
}, | ||
async lookup(id: string): Promise<Response> { | ||
const res = await client.get<Response>(`/api/lookup/${id}`) | ||
return res.data | ||
async lookup(id: string): Promise<ResponseType> { | ||
const res = await client.get(`/api/lookup/${id}`) | ||
return ResponseSchema.parse(res.data) | ||
}, | ||
async getCacheKeys(): Promise<string[]> { | ||
const res = await client.get<string[]>(`/api/cache/`) | ||
return res.data | ||
}, | ||
async getStatus(): Promise<Status> { | ||
const res = await client.get<Status>(`/api/status/`) | ||
return res.data | ||
async getStatus(): Promise<StatusType> { | ||
const res = await client.get(`/api/status/`) | ||
return StatusSchema.parse(res.data) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.