Skip to content

Commit f9f1644

Browse files
authored
Merge pull request #1571 from FalkorDB/staging
Update dependencies and enhance connection info features
2 parents a07cf9e + d0de621 commit f9f1644

27 files changed

+2733
-2174
lines changed

.github/workflows/helm-chart.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
fetch-depth: 0
3131

3232
- name: Set up Helm
33-
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
33+
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
3434
with:
3535
version: v3.14.0
3636

@@ -67,7 +67,7 @@ jobs:
6767
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
6868

6969
- name: Set up Helm
70-
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
70+
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
7171
with:
7272
version: v3.14.0
7373

@@ -117,7 +117,7 @@ jobs:
117117
fetch-depth: 0
118118

119119
- name: Set up Helm
120-
uses: azure/setup-helm@1a275c3b69536ee54be43f2070a358922e12c8d4 # v4.3.1
120+
uses: azure/setup-helm@dda3372f752e03dde6b3237bc9431cdc2f7a02a2 # v5.0.0
121121
with:
122122
version: v3.14.0
123123

@@ -235,7 +235,7 @@ jobs:
235235
cat installation-instructions.txt
236236
237237
- name: Upload package as artifact
238-
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v4.4.3
238+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
239239
with:
240240
name: helm-chart
241241
path: .helm-charts/*.tgz

.github/workflows/nextjs.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ jobs:
3535
security-events: write
3636
steps:
3737
- name: Checkout
38-
uses: actions/checkout@v6
38+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
3939
- name: Setup Node
40-
uses: actions/setup-node@v4
40+
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
4141
with:
4242
node-version: "24"
4343
cache: npm
4444

4545
- name: Restore cache
46-
uses: actions/cache@v4
46+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
4747
with:
4848
path: |
4949
.next/cache
@@ -67,7 +67,7 @@ jobs:
6767
security-events: write
6868
steps:
6969
- name: Checkout
70-
uses: actions/checkout@v6
70+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
7171

7272
- name: Set up Docker Buildx
7373
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4
@@ -85,7 +85,7 @@ jobs:
8585

8686
- name: Run Trivy vulnerability scanner
8787
id: trivy-scan
88-
uses: aquasecurity/trivy-action@1bd062560b422f5944df1de50abd05162bea079e
88+
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
8989
continue-on-error: true
9090
with:
9191
image-ref: 'falkordb/falkordb-browser:test'
@@ -111,14 +111,14 @@ jobs:
111111
fi
112112
113113
- name: Upload Trivy results to GitHub Security tab
114-
uses: github/codeql-action/upload-sarif@v4
114+
uses: github/codeql-action/upload-sarif@c10b8064de6f491fea524254123dbe5e09572f13 # v4
115115
if: always()
116116
with:
117117
sarif_file: 'trivy-results.sarif'
118118

119119
- name: Generate Trivy report for PR
120120
if: github.event_name == 'pull_request'
121-
uses: aquasecurity/trivy-action@1bd062560b422f5944df1de50abd05162bea079e
121+
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
122122
continue-on-error: true
123123
with:
124124
image-ref: 'falkordb/falkordb-browser:test'
@@ -132,7 +132,7 @@ jobs:
132132

133133
- name: Comment PR with Trivy results
134134
if: github.event_name == 'pull_request'
135-
uses: actions/github-script@v8
135+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
136136
with:
137137
script: |
138138
const fs = require('fs');
@@ -176,7 +176,7 @@ jobs:
176176
}
177177
178178
- name: Enforce HIGH/CRITICAL vulnerability threshold
179-
uses: aquasecurity/trivy-action@22438a435773de8c97dc0958cc0b823c45b064ac
179+
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
180180
with:
181181
image-ref: 'falkordb/falkordb-browser:test'
182182
format: 'table'

.github/workflows/playwright.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ jobs:
3434
runs-on: ubuntu-latest
3535
timeout-minutes: 15
3636
steps:
37-
- uses: actions/checkout@v6
38-
- uses: actions/setup-node@v4
37+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
38+
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
3939
with:
4040
node-version: 24
4141
cache: 'npm'
4242
- name: Cache node modules
4343
id: cache-npm
44-
uses: actions/cache@v4
44+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
4545
with:
4646
path: |
4747
~/.npm
@@ -86,7 +86,7 @@ jobs:
8686
- name: Build application
8787
run: npm run build
8888
- name: Upload build output
89-
uses: actions/[email protected]
89+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
9090
with:
9191
name: nextjs-build-${{ github.run_id }}
9292
path: .next/
@@ -115,13 +115,13 @@ jobs:
115115
- 6380:6379
116116

117117
steps:
118-
- uses: actions/checkout@v6
119-
- uses: actions/setup-node@v4
118+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
119+
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
120120
with:
121121
node-version: 24
122122
cache: 'npm'
123123
- name: Restore dependencies cache
124-
uses: actions/cache/restore@v4
124+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
125125
with:
126126
path: |
127127
~/.npm
@@ -132,7 +132,7 @@ jobs:
132132
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-
133133
${{ runner.os }}-node-
134134
- name: Download build output
135-
uses: actions/download-artifact@v8
135+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
136136
with:
137137
name: nextjs-build-${{ github.run_id }}
138138
path: .next/
@@ -162,23 +162,23 @@ jobs:
162162
--reporter=dot,list
163163
- name: Upload test results
164164
if: always()
165-
uses: actions/[email protected]
165+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
166166
with:
167167
name: playwright-results-shard-${{ matrix.shard }}-${{ github.run_id }}
168168
path: test-results/
169169
retention-days: 3
170170
if-no-files-found: ignore
171171
- name: Upload HTML report
172172
if: always()
173-
uses: actions/[email protected]
173+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
174174
with:
175175
name: playwright-report-shard-${{ matrix.shard }}-${{ github.run_id }}
176176
path: playwright-report/
177177
retention-days: 30
178178
if-no-files-found: ignore
179179
- name: Upload server logs
180180
if: always()
181-
uses: actions/[email protected]
181+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
182182
with:
183183
name: nextjs-logs-shard-${{ matrix.shard }}-${{ github.run_id }}
184184
path: nextjs.log
@@ -192,13 +192,13 @@ jobs:
192192
runs-on: ubuntu-latest
193193

194194
steps:
195-
- uses: actions/checkout@v6
196-
- uses: actions/setup-node@v4
195+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
196+
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
197197
with:
198198
node-version: 24
199199
cache: 'npm'
200200
- name: Restore dependencies cache
201-
uses: actions/cache/restore@v4
201+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
202202
with:
203203
path: |
204204
~/.npm
@@ -209,7 +209,7 @@ jobs:
209209
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-
210210
${{ runner.os }}-node-
211211
- name: Download build output
212-
uses: actions/download-artifact@v8
212+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
213213
with:
214214
name: nextjs-build-${{ github.run_id }}
215215
path: .next/
@@ -298,23 +298,23 @@ jobs:
298298
run: docker stop falkordb-tls || true
299299
- name: Upload test results
300300
if: always()
301-
uses: actions/[email protected]
301+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
302302
with:
303303
name: playwright-results-tls-${{ github.run_id }}
304304
path: test-results/
305305
retention-days: 3
306306
if-no-files-found: ignore
307307
- name: Upload HTML report
308308
if: always()
309-
uses: actions/[email protected]
309+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
310310
with:
311311
name: playwright-report-tls-${{ github.run_id }}
312312
path: playwright-report/
313313
retention-days: 30
314314
if-no-files-found: ignore
315315
- name: Upload server logs
316316
if: always()
317-
uses: actions/[email protected]
317+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
318318
with:
319319
name: nextjs-logs-tls-${{ github.run_id }}
320320
path: nextjs.log
@@ -328,13 +328,13 @@ jobs:
328328
runs-on: ubuntu-latest
329329

330330
steps:
331-
- uses: actions/checkout@v6
332-
- uses: actions/setup-node@v4
331+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
332+
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
333333
with:
334334
node-version: 24
335335
cache: 'npm'
336336
- name: Restore dependencies cache
337-
uses: actions/cache/restore@v4
337+
uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4
338338
with:
339339
path: |
340340
~/.npm
@@ -345,7 +345,7 @@ jobs:
345345
${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}-
346346
${{ runner.os }}-node-
347347
- name: Download build output
348-
uses: actions/download-artifact@v8
348+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
349349
with:
350350
name: nextjs-build-${{ github.run_id }}
351351
path: .next/
@@ -434,23 +434,23 @@ jobs:
434434
done
435435
- name: Upload test results
436436
if: always()
437-
uses: actions/[email protected]
437+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
438438
with:
439439
name: playwright-results-cluster-${{ github.run_id }}
440440
path: test-results/
441441
retention-days: 3
442442
if-no-files-found: ignore
443443
- name: Upload HTML report
444444
if: always()
445-
uses: actions/[email protected]
445+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
446446
with:
447447
name: playwright-report-cluster-${{ github.run_id }}
448448
path: playwright-report/
449449
retention-days: 30
450450
if-no-files-found: ignore
451451
- name: Upload server logs
452452
if: always()
453-
uses: actions/[email protected]
453+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
454454
with:
455455
name: nextjs-logs-cluster-${{ github.run_id }}
456456
path: nextjs.log

.github/workflows/release-image.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ jobs:
8787
8888
- name: Run Trivy vulnerability scanner
8989
if: matrix.arch == 'amd64'
90-
uses: aquasecurity/trivy-action@1bd062560b422f5944df1de50abd05162bea079e
90+
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1
9191
with:
9292
image-ref: ${{ env.TRIVY_TAG }}
9393
format: 'table'

app/api/connection-info/route.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import { NextResponse } from "next/server";
2+
import { getClient } from "@/app/api/auth/[...nextauth]/options";
3+
import { getCorsHeaders } from "@/app/api/utils";
4+
5+
export async function OPTIONS(request: Request) {
6+
return new NextResponse(null, { status: 204, headers: getCorsHeaders(request) });
7+
}
8+
9+
function parseInfoField(info: string, field: string): string | undefined {
10+
const escaped = field.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
11+
const match = info.match(new RegExp(`${escaped}:(.+?)\\r?\\n`));
12+
return match?.[1]?.trim();
13+
}
14+
15+
// eslint-disable-next-line import/prefer-default-export
16+
export async function GET(request: Request) {
17+
try {
18+
const session = await getClient(request);
19+
20+
if (session instanceof NextResponse) {
21+
return session;
22+
}
23+
24+
const { client } = session;
25+
const connection = await client.connection;
26+
27+
const info = await connection.info();
28+
const clusterEnabled = parseInfoField(info, "redis_mode") === "cluster";
29+
const replicationInfo = await connection.info("replication");
30+
const connectedSlaves = Number(parseInfoField(replicationInfo, "connected_slaves") ?? "0");
31+
const role = parseInfoField(replicationInfo, "role") ?? "master";
32+
33+
const result: Record<string, unknown> = {};
34+
35+
if (clusterEnabled) {
36+
try {
37+
const clusterNodesRaw: string = await connection.sendCommand(["CLUSTER", "NODES"]) as string;
38+
const lines = clusterNodesRaw.split("\n").filter(line => line.trim().length > 0);
39+
result.clusterNodes = lines.map(line => {
40+
const parts = line.split(" ");
41+
const addressPart = parts[1] ?? "";
42+
const [addrWithPort, hostname] = addressPart.split(",");
43+
const address = addrWithPort?.split("@")[0] ?? "";
44+
const [ip, portStr] = address.split(":");
45+
const host = hostname || ip;
46+
const flags = parts[2] ?? "";
47+
const flagList = flags.split(",");
48+
// Skip nodes with non-standard flags (e.g., fail, handshake, noaddr)
49+
const isMaster = flagList.includes("master") || flagList.includes("myself,master");
50+
const isSlave = flagList.includes("slave") || flagList.includes("myself,slave");
51+
if (!isMaster && !isSlave) return null;
52+
const nodeRole = isMaster ? "master" : "slave";
53+
const port = Number(portStr);
54+
if (!Number.isFinite(port) || port <= 0) return null;
55+
const slots = nodeRole === "master" ? parts.slice(8).join(" ") : undefined;
56+
return { host, port, role: nodeRole, slots };
57+
}).filter(Boolean);
58+
} catch (err) {
59+
console.error("Failed to get cluster details:", err);
60+
}
61+
} else if (role === "master" && connectedSlaves > 0) {
62+
result.sentinelRole = "master";
63+
result.sentinelReplicas = connectedSlaves;
64+
} else if (role === "slave") {
65+
result.sentinelRole = "slave";
66+
result.sentinelMasterHost = parseInfoField(replicationInfo, "master_host");
67+
const parsedPort = Number(parseInfoField(replicationInfo, "master_port") ?? "0");
68+
result.sentinelMasterPort = Number.isFinite(parsedPort) ? parsedPort : 0;
69+
}
70+
71+
return NextResponse.json({ result }, { status: 200, headers: getCorsHeaders(request) });
72+
} catch (err) {
73+
console.error(err);
74+
return NextResponse.json(
75+
{ message: (err as Error).message },
76+
{ status: 500, headers: getCorsHeaders(request) }
77+
);
78+
}
79+
}

0 commit comments

Comments
 (0)