Release/test 合并上生产 #2

Merged
admin merged 736 commits from release/test into main 2026-09-17 11:50:56 +08:00
2 changed files with 17 additions and 0 deletions
Showing only changes of commit f2fc40605e - Show all commits
+15
View File
@@ -0,0 +1,15 @@
import { describe, expect, it } from 'vitest'
import { parseApiJsonResponse, parseJsonWithSafeIntegers } from '@chongchong/shared'
describe('safe integer API parsing', () => {
it('preserves backend long IDs as strings', () => {
expect(parseJsonWithSafeIntegers('{"id":2082674456475418625,"page":1}')).toEqual({
id: '2082674456475418625',
page: 1,
})
})
it('leaves non-JSON responses untouched', () => {
expect(parseApiJsonResponse('plain text')).toBe('plain text')
})
})
+2
View File
@@ -1,4 +1,5 @@
import axios, { type InternalAxiosRequestConfig } from 'axios'
import { parseApiJsonResponse } from '@chongchong/shared'
export interface ApiEnvelope<T> {
code: string
@@ -37,6 +38,7 @@ export interface ApiErrorDetails {
export const http = axios.create({
baseURL: import.meta.env.VITE_API_BASE_URL || '/api',
timeout: 15_000,
transformResponse: [(data: unknown) => parseApiJsonResponse(data)],
})
type RetryableRequestConfig = InternalAxiosRequestConfig & { _authRetry?: boolean }