mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-11-04 15:36:52 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			19 lines
		
	
	
		
			733 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			19 lines
		
	
	
		
			733 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
import useSWR from 'swr';
 | 
						|
import http, { FractalResponseList } from '@/api/http';
 | 
						|
import { rawDataToServerEggVariable } from '@/api/transformers';
 | 
						|
import { ServerEggVariable } from '@/api/server/types';
 | 
						|
 | 
						|
interface Response {
 | 
						|
    invocation: string;
 | 
						|
    variables: ServerEggVariable[];
 | 
						|
}
 | 
						|
 | 
						|
export default (uuid: string, initialData?: Response) => useSWR([ uuid, '/startup' ], async (): Promise<Response> => {
 | 
						|
    console.log('firing getServerStartup');
 | 
						|
    const { data } = await http.get(`/api/client/servers/${uuid}/startup`);
 | 
						|
 | 
						|
    const variables = ((data as FractalResponseList).data || []).map(rawDataToServerEggVariable);
 | 
						|
 | 
						|
    return { invocation: data.meta.startup_command, variables };
 | 
						|
}, { initialData, errorRetryCount: 3 });
 |