misc_pterodactyl-panel/resources/scripts/api/admin/nodes/allocations/createAllocation.ts

16 lines
598 B
TypeScript

import http from '@/api/http';
import { Allocation, rawDataToAllocation } from '@/api/admin/nodes/allocations/getAllocations';
export interface Values {
ip: string;
ports: number[];
alias?: string;
}
export default (id: string | number, values: Values, include: string[] = []): Promise<Allocation[]> => {
return new Promise((resolve, reject) => {
http.post(`/api/application/nodes/${id}/allocations`, values, { params: { include: include.join(',') } })
.then(({ data }) => resolve((data || []).map(rawDataToAllocation)))
.catch(reject);
});
};