Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
submit: async ({ username, password }) => {
if (username !== '' && password !== '') {
try {
const result = await request('/user/login', {
method: 'POST',
requestType: 'json',
data: {
username,
password,
},
});
localStorage.setItem('token', result.data.token);
return {
status: true,
message: formatMessage({ id: 'component.user.loginMethodPassword.success' }),
data: [],
};
} catch (e) {
// NOTE: API failed, using errorHandler
export const fetchUpstreamItem = (sid: string) => {
return request(`/upstreams/${sid}`).then(({ nodes, timeout, id }) => {
return {
upstreamHostList: transformUpstreamNodes(nodes),
timeout,
upstream_id: id,
};
});
};
export const create = (data: UpstreamModule.RequestBody) =>
request('/upstreams', {
method: 'POST',
data,
});
export const fetchUpstreamList = () => {
return request>>('/upstreams').then(({ data }) => ({
data: data.rows.map(row => convertToFormData(row)),
total: data.total_size,
}));
};
export async function updateEnvironment(
envName: string,
body: API.EnvironmentBody,
): Promise> {
return request(`${BASE_PATH}/${envName}`, {
method: 'put',
data: body,
});
}
export const checkUniqueName = (name = '', exclude = '') =>
request('/notexist/routes', {
params: pickBy(
{
name,
exclude,
},
identity,
),
});
export const fetchPluginList = () => request('/plugins');
export const fetchList = () => {
if (cached.list.length) {
return Promise.resolve(cached.list)
}
return request>('/plugins?all=true').then((data) => {
const typedData = data.data.map(item => ({
...item,
type: PLUGIN_LIST[item.name]?.type || "other",
hidden: PLUGIN_LIST[item.name]?.hidden || false
}));
let finalList: PluginComponent.Meta[] = []
Object.values(PluginType).forEach(type => {
finalList = finalList.concat(typedData.filter(item => item.type === type))
})
if (cached.list.length === 0) {
cached.list = finalList
}
export const fetchPluginList = () => {
return request>('/plugins?all=true').then((data) => {
return data.data;
});
};
export const verifyKeyPaire = (cert = '', key = ''): Promise =>
request('/check_ssl_cert', {
method: 'POST',
data: { cert, key },
});