File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ export const OPERATOR_DASHBOARD_PORT = 3000 ;
2+
3+ export function resolveDashboardPort (
4+ preferred = process . env . PROMPT_REFINER_DASHBOARD_PORT ,
5+ legacy = process . env . PORT ,
6+ ) : number {
7+ const configured = preferred || legacy ;
8+ if ( ! configured ) {
9+ return OPERATOR_DASHBOARD_PORT ;
10+ }
11+
12+ const port = Number . parseInt ( configured , 10 ) ;
13+ if ( ! Number . isInteger ( port ) || port < 1 || port > 65_535 ) {
14+ return OPERATOR_DASHBOARD_PORT ;
15+ }
16+ return port ;
17+ }
Original file line number Diff line number Diff line change 1+ import { describe , expect , it } from "vitest" ;
2+ import { OPERATOR_DASHBOARD_PORT , resolveDashboardPort } from "../src/core/ports.js" ;
3+
4+ describe ( "dashboard port policy" , ( ) => {
5+ it ( "uses the fixed operator dashboard port by default" , ( ) => {
6+ expect ( OPERATOR_DASHBOARD_PORT ) . toBe ( 3000 ) ;
7+ expect ( resolveDashboardPort ( undefined , undefined ) ) . toBe ( 3000 ) ;
8+ } ) ;
9+
10+ it ( "prefers the named dashboard port over legacy PORT" , ( ) => {
11+ expect ( resolveDashboardPort ( "3000" , "4321" ) ) . toBe ( 3000 ) ;
12+ } ) ;
13+
14+ it ( "keeps legacy PORT as a compatibility fallback and rejects invalid values" , ( ) => {
15+ expect ( resolveDashboardPort ( undefined , "3999" ) ) . toBe ( 3999 ) ;
16+ expect ( resolveDashboardPort ( "not-a-port" , "3999" ) ) . toBe ( 3000 ) ;
17+ expect ( resolveDashboardPort ( "70000" , undefined ) ) . toBe ( 3000 ) ;
18+ } ) ;
19+ } ) ;
You can’t perform that action at this time.
0 commit comments