mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-06-11 08:16:00 +08:00
refactor(backend): move every route to its own module
This commit is contained in:
@@ -66,7 +66,6 @@ export default function App() {
|
||||
// <Routes>
|
||||
// <Route path="/" element={<AppContent />} />
|
||||
// <Route path="/session/:sessionId" element={<AppContent />} />
|
||||
// <Route path='/' element={<SampleElement />} />
|
||||
// </Routes>
|
||||
// </Router>
|
||||
// </ProtectedRoute>
|
||||
|
||||
@@ -28,7 +28,7 @@ const parseJson = async <T>(response: Response): Promise<T> => {
|
||||
};
|
||||
|
||||
export const fetchGithubTokenCredentials = async () => {
|
||||
const response = await api.get('/settings/credentials?type=github_token');
|
||||
const response = await api.get('/credentials?type=github_token');
|
||||
const data = await parseJson<CredentialsResponse>(response);
|
||||
|
||||
if (!response.ok) {
|
||||
|
||||
@@ -43,8 +43,8 @@ export function useCredentialsSettings({
|
||||
setLoading(true);
|
||||
|
||||
const [apiKeysResponse, credentialsResponse] = await Promise.all([
|
||||
authenticatedFetch('/api/settings/api-keys'),
|
||||
authenticatedFetch('/api/settings/credentials?type=github_token'),
|
||||
authenticatedFetch('/api/api-keys'),
|
||||
authenticatedFetch('/api/credentials?type=github_token'),
|
||||
]);
|
||||
|
||||
const [apiKeysPayload, credentialsPayload] = await Promise.all([
|
||||
@@ -67,7 +67,7 @@ export function useCredentialsSettings({
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await authenticatedFetch('/api/settings/api-keys', {
|
||||
const response = await authenticatedFetch('/api/api-keys', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ keyName: newKeyName.trim() }),
|
||||
});
|
||||
@@ -95,7 +95,7 @@ export function useCredentialsSettings({
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await authenticatedFetch(`/api/settings/api-keys/${keyId}`, {
|
||||
const response = await authenticatedFetch(`/api/api-keys/${keyId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
||||
@@ -113,7 +113,7 @@ export function useCredentialsSettings({
|
||||
|
||||
const toggleApiKey = useCallback(async (keyId: string, isActive: boolean) => {
|
||||
try {
|
||||
const response = await authenticatedFetch(`/api/settings/api-keys/${keyId}/toggle`, {
|
||||
const response = await authenticatedFetch(`/api/api-keys/${keyId}/toggle`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ isActive: !isActive }),
|
||||
});
|
||||
@@ -136,7 +136,7 @@ export function useCredentialsSettings({
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await authenticatedFetch('/api/settings/credentials', {
|
||||
const response = await authenticatedFetch('/api/credentials', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
credentialName: newGithubName.trim(),
|
||||
@@ -169,7 +169,7 @@ export function useCredentialsSettings({
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await authenticatedFetch(`/api/settings/credentials/${credentialId}`, {
|
||||
const response = await authenticatedFetch(`/api/credentials/${credentialId}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
||||
@@ -187,7 +187,7 @@ export function useCredentialsSettings({
|
||||
|
||||
const toggleGithubCredential = useCallback(async (credentialId: string, isActive: boolean) => {
|
||||
try {
|
||||
const response = await authenticatedFetch(`/api/settings/credentials/${credentialId}/toggle`, {
|
||||
const response = await authenticatedFetch(`/api/credentials/${credentialId}/toggle`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify({ isActive: !isActive }),
|
||||
});
|
||||
|
||||
@@ -692,7 +692,7 @@ export function useSettingsController({ isOpen, initialTab, projects, onClose }:
|
||||
setGeminiPermissionMode(savedGeminiSettings.permissionMode || 'default');
|
||||
|
||||
try {
|
||||
const notificationResponse = await authenticatedFetch('/api/settings/notification-preferences');
|
||||
const notificationResponse = await authenticatedFetch('/api/notification-preferences');
|
||||
if (notificationResponse.ok) {
|
||||
const notificationData = await toResponseJson<NotificationPreferencesResponse>(notificationResponse);
|
||||
if (notificationData.success && notificationData.preferences) {
|
||||
@@ -767,7 +767,7 @@ export function useSettingsController({ isOpen, initialTab, projects, onClose }:
|
||||
lastUpdated: now,
|
||||
}));
|
||||
|
||||
const notificationResponse = await authenticatedFetch('/api/settings/notification-preferences', {
|
||||
const notificationResponse = await authenticatedFetch('/api/notification-preferences', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(notificationPreferences),
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ export function useWebPush(): WebPushState {
|
||||
setPermission(perm);
|
||||
if (perm !== 'granted') return;
|
||||
|
||||
const keyRes = await authenticatedFetch('/api/settings/push/vapid-public-key');
|
||||
const keyRes = await authenticatedFetch('/api/push-sub/vapid-public-key');
|
||||
const { publicKey } = await keyRes.json();
|
||||
|
||||
const registration = await navigator.serviceWorker.ready;
|
||||
@@ -62,7 +62,7 @@ export function useWebPush(): WebPushState {
|
||||
});
|
||||
|
||||
const subJson = subscription.toJSON();
|
||||
await authenticatedFetch('/api/settings/push/subscribe', {
|
||||
await authenticatedFetch('/api/push-sub/subscribe', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
endpoint: subJson.endpoint,
|
||||
@@ -86,7 +86,7 @@ export function useWebPush(): WebPushState {
|
||||
if (subscription) {
|
||||
const endpoint = subscription.endpoint;
|
||||
await subscription.unsubscribe();
|
||||
await authenticatedFetch('/api/settings/push/unsubscribe', {
|
||||
await authenticatedFetch('/api/push-sub/unsubscribe', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ endpoint }),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user