This is an automated email from the ASF dual-hosted git repository.

baoyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d5744a99 feat: support delete all stream routes (#3119)
4d5744a99 is described below

commit 4d5744a99ad8be7eb50812eb939ef18e7d5025a2
Author: YYYoung <isk...@outlook.com>
AuthorDate: Mon Jun 16 09:21:06 2025 +0800

    feat: support delete all stream routes (#3119)
---
 src/apis/stream_routes.ts | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/apis/stream_routes.ts b/src/apis/stream_routes.ts
index 0dbf09d30..c01f58db5 100644
--- a/src/apis/stream_routes.ts
+++ b/src/apis/stream_routes.ts
@@ -18,7 +18,11 @@
 import type { AxiosInstance } from 'axios';
 
 import type { StreamRoutePostType } from 
'@/components/form-slice/FormPartStreamRoute/schema';
-import { API_STREAM_ROUTES } from '@/config/constant';
+import {
+  API_STREAM_ROUTES,
+  PAGE_SIZE_MAX,
+  PAGE_SIZE_MIN,
+} from '@/config/constant';
 import type { APISIXType } from '@/types/schema/apisix';
 
 import type { WithServiceIdFilter } from './routes';
@@ -59,3 +63,21 @@ export const postStreamRouteReq = (
     API_STREAM_ROUTES,
     data
   );
+
+export const deleteAllStreamRoutes = async (req: AxiosInstance) => {
+  const totalRes = await getStreamRouteListReq(req, {
+    page: 1,
+    page_size: PAGE_SIZE_MIN,
+  });
+  const total = totalRes.total;
+  if (total === 0) return;
+  for (let times = Math.ceil(total / PAGE_SIZE_MAX); times > 0; times--) {
+    const res = await getStreamRouteListReq(req, {
+      page: 1,
+      page_size: PAGE_SIZE_MAX,
+    });
+    await Promise.all(
+      res.list.map((d) => req.delete(`${API_STREAM_ROUTES}/${d.value.id}`))
+    );
+  }
+};

Reply via email to