misc_pterodactyl-panel/resources/scripts/api/admin/eggs/createEggVariable.ts

22 lines
849 B
TypeScript
Raw Normal View History

2021-10-03 20:23:06 +00:00
import http from '@/api/http';
import { EggVariable, rawDataToEggVariable } from '@/api/admin/eggs/getEgg';
export default (eggId: number, variable: Omit<EggVariable, 'id' | 'eggId' | 'createdAt' | 'updatedAt'>): Promise<EggVariable> => {
return new Promise((resolve, reject) => {
http.post(
2021-10-03 21:51:35 +00:00
`/api/application/eggs/${eggId}/variables`,
2021-10-03 20:23:06 +00:00
{
name: variable.name,
description: variable.description,
env_variable: variable.envVariable,
default_value: variable.defaultValue,
user_viewable: variable.userViewable,
user_editable: variable.userEditable,
rules: variable.rules,
},
)
.then(({ data }) => resolve(rawDataToEggVariable(data)))
.catch(reject);
});
};