Init: Create & Init dayu Project...
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
		
							
								
								
									
										26
									
								
								packages/faas/src/api.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								packages/faas/src/api.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,26 @@
 | 
			
		||||
import * as faas from './interfaces'
 | 
			
		||||
import axios, { AxiosRequestConfig } from 'axios'
 | 
			
		||||
 | 
			
		||||
const instanceConfig: AxiosRequestConfig = {
 | 
			
		||||
    baseURL: 'https://faas.yumc.pw',
 | 
			
		||||
    headers: {
 | 
			
		||||
        'Content-Type': 'application/json',
 | 
			
		||||
        'Authorization': 'Basic YWRtaW46MmQ2MzdiYzQ4MWQxYThhMjg2M2E2ZTIzOTY1ZWRlNDI0ZTRjMTk2OTQyMzU5N2M5MzRlNGQyY2FlZTNkMjk2OA=='
 | 
			
		||||
    },
 | 
			
		||||
    timeout: 5000
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
let api = axios.create(instanceConfig)
 | 
			
		||||
 | 
			
		||||
async function get<T>(path: string) {
 | 
			
		||||
    let result = await api.get(path);
 | 
			
		||||
    return result.data as T;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function getFunctions() {
 | 
			
		||||
    return await get<faas.Function[]>('/system/functions');
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export async function getFunction(name: string) {
 | 
			
		||||
    return await get<faas.Function>(`/system/function/${name}`);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								packages/faas/src/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								packages/faas/src/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
			
		||||
export * from './api'
 | 
			
		||||
							
								
								
									
										13
									
								
								packages/faas/src/interfaces.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								packages/faas/src/interfaces.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
			
		||||
export interface Labels {
 | 
			
		||||
    [key: string]: string
 | 
			
		||||
}
 | 
			
		||||
export interface Function {
 | 
			
		||||
    name: string;
 | 
			
		||||
    image: string;
 | 
			
		||||
    invocationCount: number;
 | 
			
		||||
    replicas: number;
 | 
			
		||||
    envProcess: string;
 | 
			
		||||
    availableReplicas: number;
 | 
			
		||||
    labels: Labels;
 | 
			
		||||
    annotations?: any;
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user