File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,32 @@ adminApi.post('/machine/restart', async c => {
6262 }
6363} ) ;
6464
65+ // TODO: Remove after frontend rollout to /api/admin/machine/restart
66+ // POST /api/admin/gateway/restart - Backward-compat alias for machine restart
67+ adminApi . post ( '/gateway/restart' , async c => {
68+ const stub = resolveStub ( c ) ;
69+ const body = ( await c . req . json ( ) . catch ( ( ) => ( { } ) ) ) as Record < string , unknown > ;
70+ const rawTag = typeof body . imageTag === 'string' ? body . imageTag : undefined ;
71+
72+ if ( rawTag && ! isValidImageTag ( rawTag ) ) {
73+ return c . json ( { success : false , error : 'Invalid image tag format' } , 400 ) ;
74+ }
75+
76+ const imageTag = rawTag ;
77+ const result = await stub . restartMachine ( imageTag ? { imageTag } : undefined ) ;
78+
79+ if ( result . success ) {
80+ return c . json ( {
81+ success : true ,
82+ message : imageTag
83+ ? `Machine restarting with image tag: ${ imageTag } ...`
84+ : 'Machine restarting with updated configuration...' ,
85+ } ) ;
86+ } else {
87+ return c . json ( { success : false , error : result . error } , 500 ) ;
88+ }
89+ } ) ;
90+
6591// Mount admin API routes under /admin
6692api . route ( '/admin' , adminApi ) ;
6793
You can’t perform that action at this time.
0 commit comments