misc_pterodactyl-panel/resources/scripts/api/admin/nodes/allocations/createAllocation.ts
2021-09-15 15:37:17 -06:00

16 lines
586 B
TypeScript

import http from '@/api/http';
import { Allocation, rawDataToAllocation } from '@/api/admin/nodes/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);
});
};