From 5d6a018c63e6d832271c71eab0400f0ded5ebd6c Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 10 Jan 2025 00:26:52 +0800 Subject: [PATCH] :bug: Switch bundler and bug fixes --- packages/sn/bun.lockb | Bin 58900 -> 54586 bytes packages/sn/package.json | 1 - packages/sn/src/network.ts | 45 ++++++++++++++++++++++++++++++++----- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/packages/sn/bun.lockb b/packages/sn/bun.lockb index ef154a0b65b01d581060bd5a1177d574fcd5449c..05716fe82b71738133f36f3c364583546e56c2c3 100755 GIT binary patch delta 9393 zcmc&)3s_ZE+TMG64sgH&3IYc_DmN8Skc)Cq@t}xYJa|FH111V0%He*~#M?QJTBup- z=Tm~_EhQl{39GSDORIUxY$mIj(x(3IB`K3*_bL6~Z|}1`%=|w8%+vG#&8m03>-*NX zF5mjrUT3qHJ1_KkwxiFs*eGLROYGtFZzpEVci3wRz(nmhH9m>a#=%TarI(h0K|TR;3%o7sj!s_!b_0#kc(H?Y8p`9 zEGqS@!QRj}fOX(nNf122Rko_qn8k~PV#q#_NB2?eiW{1$ODb%QjSb6c1v@&b( zg1MouR*{!1w$-CrXtY%~m98i)X;@ZLU))eCHA{G9S&Fi(6u+Vux7t*lwZ_B|egU=M)eeH7T!$1r{FV84?SFdLrvy1?H7H>(p=3 z!+#!lHG1a(mZ6p#WPy1lLNGeBKV-CZbV3dUw}E-UOVBg7q7!a^14BI-f_Ivs@iAMFM~Frx4QI2il_m@7KKJn((s!Qe7*1UL&E0*-LX zZqE9TF{^Os&w|6i2f;(Y>z!N*=6+hZVC!O*hFov)@ zHle_VjbL8VMPTk=I+zjl%=Tx%+`hvp?*y~mIxyQ+ zf_a>Lxqg7)NOKy*$_l|@45Q1Mq=aBNi0$RrF;ZCwgjWu6V2rW=i^05g+QGa)cg0Ye zHi;bCtS*DwOpO>pHqTUX4YebGgRUTVqbRRbaT2wArAnMeEIC8rk%z(mj2sLvNP4`%rm5vu-!0HV#9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AjnK!-=S8|+;tRZY z{@8+)qzP%6qEUKUQfgYR*v!jH8lNV%_#GbSdh2lUfm$(f>r5pXwz)cruaX#Cq+SRz zIaal4QD=v)I>w8i4FM#)-pW~iKSsaYtm}0%zqFy#+>-j(&&=#8l5-?%)i$r?(x6+% zkm(I~?|Snn@Kr2=ID5h$;i#ir-@r# x+x=Du>)(plr%rWI7RQ%E?!{j~{_GJFrc-Ji(zdE&*`azI0s@PQTiX*l{VzfGkjel6 diff --git a/packages/sn/package.json b/packages/sn/package.json index 8ac21df..5c36d0c 100644 --- a/packages/sn/package.json +++ b/packages/sn/package.json @@ -25,7 +25,6 @@ }, "dependencies": { "axios": "^1.7.9", - "axios-case-converter": "^1.1.1", "universal-cookie": "^7.2.2", "zustand": "^5.0.3" } diff --git a/packages/sn/src/network.ts b/packages/sn/src/network.ts index d08a952..970a537 100644 --- a/packages/sn/src/network.ts +++ b/packages/sn/src/network.ts @@ -1,8 +1,33 @@ import axios, { type AxiosInstance } from 'axios' -import applyCaseMiddleware from 'axios-case-converter' import Cookies from 'universal-cookie' import { setTokenCookies } from './auth' +function toCamelCase(obj: any): any { + if (Array.isArray(obj)) { + return obj.map(toCamelCase) + } else if (obj && typeof obj === 'object') { + return Object.keys(obj).reduce((result: any, key) => { + const camelKey = key.replace(/_([a-z])/g, (_, char) => char.toUpperCase()) + result[camelKey] = toCamelCase(obj[key]) + return result + }, {}) + } + return obj +} + +// function toSnakeCase(obj: any): any { +// if (Array.isArray(obj)) { +// return obj.map(toSnakeCase) +// } else if (obj && typeof obj === 'object') { +// return Object.keys(obj).reduce((result: any, key) => { +// const snakeKey = key.replace(/[A-Z]/g, (char) => `_${char.toLowerCase()}`) +// result[snakeKey] = toSnakeCase(obj[key]) +// return result +// }, {}) +// } +// return obj +// } + const baseURL = 'https://api.sn.solsynth.dev' export const sni: AxiosInstance = (() => { @@ -18,11 +43,21 @@ export const sni: AxiosInstance = (() => { }, (error) => error, ) + inst.interceptors.response.use( + (response) => { + if (response.data) { + response.data = toCamelCase(response.data) + } + return response + }, + (error) => { + if (error.response && error.response.data) { + error.response.data = toCamelCase(error.response.data) + } + return Promise.reject(error) + }, + ) - applyCaseMiddleware(inst, { - ignoreParams: true, - ignoreHeaders: true, - }) return inst })()