MCPcopy
hub / github.com/cita-777/metapi / settingsRoutes

Function settingsRoutes

src/server/routes/api/settings.ts:838–2038  ·  view source on GitHub ↗
(app: FastifyInstance)

Source from the content-addressed store, hash-verified

836}
837
838export async function settingsRoutes(app: FastifyInstance) {
839 await app.get('/api/settings/runtime', async (request) => {
840 const currentAdminIp = extractClientIp(request.ip, request.headers['x-forwarded-for']);
841 return getRuntimeSettingsResponse(currentAdminIp);
842 });
843
844 app.get('/api/settings/brand-list', async () => {
845 return { brands: getAllBrandNames() };
846 });
847
848 app.post<{ Body: unknown }>('/api/settings/system-proxy/test', async (request, reply) => {
849 const parsedBody = parseSystemProxyTestPayload(request.body);
850 if (!parsedBody.success) {
851 return reply.code(400).send({
852 success: false,
853 message: parsedBody.error,
854 });
855 }
856
857 const rawProxyUrl = parsedBody.data.proxyUrl === undefined
858 ? config.systemProxyUrl
859 : String(parsedBody.data.proxyUrl || '').trim();
860 const normalizedProxyUrl = rawProxyUrl
861 ? normalizeSiteProxyUrl(rawProxyUrl)
862 : '';
863
864 if (!rawProxyUrl) {
865 return reply.code(400).send({
866 success: false,
867 message: '请先填写系统代理地址',
868 });
869 }
870
871 if (!normalizedProxyUrl) {
872 return reply.code(400).send({
873 success: false,
874 message: '系统代理地址无效,请填写合法的 http(s)/socks 代理 URL',
875 });
876 }
877
878 try {
879 const result = await testSystemProxyConnectivity(normalizedProxyUrl);
880 return {
881 success: true,
882 proxyUrl: normalizedProxyUrl,
883 ...result,
884 };
885 } catch (error: any) {
886 return reply.code(502).send({
887 success: false,
888 message: error?.message || '系统代理测试失败',
889 });
890 }
891 });
892
893 app.put<{ Body: unknown }>('/api/settings/runtime', async (request, reply) => {
894 const parsedBody = parseRuntimeSettingsPayload(request.body);
895 if (!parsedBody.success) {

Callers

nothing calls this directly

Calls 15

getAllBrandNamesFunction · 0.85
normalizeSiteProxyUrlFunction · 0.85
updateCheckinScheduleFunction · 0.85
upsertSettingFunction · 0.85
updateBalanceRefreshCronFunction · 0.85

Tested by

no test coverage detected