Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await fetch(`${baseUrl}/articles/${slug}`, {
method: "delete",
headers: getHeaders(token)
});
return [replace(path("routing", "outlet"), "home")];
});
export const getArticleProcess = createProcess("get-article", [
startLoadingArticleCommand,
[loadArticleCommand, loadCommentsCommand]
]);
export const deleteCommentProcess = createProcess("delete-comment", [deleteCommentCommand]);
export const addCommentProcess = createProcess("add-comment", [addCommentCommand]);
export const newCommentInputProcess = createProcess("new-comment-input", [newCommentInputCommand]);
export const favoriteArticleProcess = createProcess("fav-article", [favoriteArticleCommand]);
export const followUserProcess = createProcess("follow-user", [followUserCommand]);
export const deleteArticleProcess = createProcess("delete-article", [deleteArticleCommand]);
return [
replace(path("session"), json.user),
replace(path("settings"), undefined),
replace(path("routing", "outlet"), "user"),
replace(path("routing", "params"), { username: get(path("settings", "username")) })
];
});
export const getUserSettingsProcess = createProcess("user-settings", [
startUserSettingsCommand,
getUserSettingsCommand
]);
export const updateUserSettingsProcess = createProcess("update-user-settings", [updateUserSettingsCommand]);
export const usernameInputProcess = createProcess("username-input", [usernameInputCommand]);
export const emailInputProcess = createProcess("email-input", [emailInputCommand]);
export const passwordInputProcess = createProcess("password-input", [passwordInputCommand]);
export const bioInputProcess = createProcess("bio-input", [bioInputCommand]);
export const imageUrlInputProcess = createProcess("image-url-input", [imageUrlInputCommand]);
const json = await response.json();
if (!response.ok) {
return [replace(path('editor', 'loading'), false), replace(path('errors'), json.errors)];
}
return [
replace(path('article', 'item'), json.article),
replace(path('article', 'loaded'), true),
replace(path('editor'), undefined)
];
});
export const titleInputProcess = createProcess('title-input', [titleInputCommand]);
export const descInputProcess = createProcess('desc-input', [descriptionInputCommand]);
export const bodyInputProcess = createProcess('body-input', [bodyInputCommand]);
export const tagInputProcess = createProcess('tag-input', [tagInputCommand]);
export const addTagProcess = createProcess('add-tag', [addTagCommand, clearTagInputCommand]);
export const removeTagProcess = createProcess('remove-tag', [removeTagCommand]);
export const getEditorArticleProcess = createProcess('get-editor-article', [getArticleForEditorCommand]);
export const publishArticleProcess = createProcess('publish-article', [startPublishCommand, publishArticleCommand]);
export const clearEditorProcess = createProcess('clear-editor', [clearEditorCommand]);
method: "put",
headers: getHeaders(token),
body: JSON.stringify(requestPayload)
});
const json = await response.json();
return [
replace(path("session"), json.user),
replace(path("settings"), undefined),
replace(path("routing", "outlet"), "user"),
replace(path("routing", "params"), { username: get(path("settings", "username")) })
];
});
export const getUserSettingsProcess = createProcess("user-settings", [
startUserSettingsCommand,
getUserSettingsCommand
]);
export const updateUserSettingsProcess = createProcess("update-user-settings", [updateUserSettingsCommand]);
export const usernameInputProcess = createProcess("username-input", [usernameInputCommand]);
export const emailInputProcess = createProcess("email-input", [emailInputCommand]);
export const passwordInputProcess = createProcess("password-input", [passwordInputCommand]);
export const bioInputProcess = createProcess("bio-input", [bioInputCommand]);
export const imageUrlInputProcess = createProcess("image-url-input", [imageUrlInputCommand]);
replace(path("session"), json.user),
replace(path("settings"), undefined),
replace(path("routing", "outlet"), "user"),
replace(path("routing", "params"), { username: get(path("settings", "username")) })
];
});
export const getUserSettingsProcess = createProcess("user-settings", [
startUserSettingsCommand,
getUserSettingsCommand
]);
export const updateUserSettingsProcess = createProcess("update-user-settings", [updateUserSettingsCommand]);
export const usernameInputProcess = createProcess("username-input", [usernameInputCommand]);
export const emailInputProcess = createProcess("email-input", [emailInputCommand]);
export const passwordInputProcess = createProcess("password-input", [passwordInputCommand]);
export const bioInputProcess = createProcess("bio-input", [bioInputCommand]);
export const imageUrlInputProcess = createProcess("image-url-input", [imageUrlInputCommand]);
return [
replace(path("session"), json.user),
replace(path("settings"), undefined),
replace(path("routing", "outlet"), "user"),
replace(path("routing", "params"), { username: get(path("settings", "username")) })
];
});
export const getUserSettingsProcess = createProcess("user-settings", [
startUserSettingsCommand,
getUserSettingsCommand
]);
export const updateUserSettingsProcess = createProcess("update-user-settings", [updateUserSettingsCommand]);
export const usernameInputProcess = createProcess("username-input", [usernameInputCommand]);
export const emailInputProcess = createProcess("email-input", [emailInputCommand]);
export const passwordInputProcess = createProcess("password-input", [passwordInputCommand]);
export const bioInputProcess = createProcess("bio-input", [bioInputCommand]);
export const imageUrlInputProcess = createProcess("image-url-input", [imageUrlInputCommand]);
return [
replace(path('article', 'item'), json.article),
replace(path('article', 'loaded'), true),
replace(path('editor'), undefined)
];
});
export const titleInputProcess = createProcess('title-input', [titleInputCommand]);
export const descInputProcess = createProcess('desc-input', [descriptionInputCommand]);
export const bodyInputProcess = createProcess('body-input', [bodyInputCommand]);
export const tagInputProcess = createProcess('tag-input', [tagInputCommand]);
export const addTagProcess = createProcess('add-tag', [addTagCommand, clearTagInputCommand]);
export const removeTagProcess = createProcess('remove-tag', [removeTagCommand]);
export const getEditorArticleProcess = createProcess('get-editor-article', [getArticleForEditorCommand]);
export const publishArticleProcess = createProcess('publish-article', [startPublishCommand, publishArticleCommand]);
export const clearEditorProcess = createProcess('clear-editor', [clearEditorCommand]);
const initialStateCommand = commandFactory(({ path }) => {
return [
add(path('completedCount'), 0),
add(path('completed'), false),
add(path('currentSearch'), ''),
add(path('currentTodo'), ''),
add(path('editedTodo'), undefined),
add(path('todoCount'), 0),
add(path('todos'), {})
];
});
export const initialStateProcess = createProcess('initial-state', [ initialStateCommand ]);
export const addTodoProcess = createProcess('add-todo', [ addTodoCommand, updateTodoCountsCommand, updateCompletedFlagCommand ]);
export const removeTodoProcess = createProcess('remove-todo', [ removeTodoCommand, updateTodoCountsCommand, updateCompletedFlagCommand ]);
export const toggleTodoProcess = createProcess('toggle-todo', [ toggleTodoCommand, updateTodoCountsCommand, updateCompletedFlagCommand ]);
export const toggleTodosProcess = createProcess('toggle-todos', [ toggleTodosCommand, updateTodoCountsCommand, updateCompletedFlagCommand ]);
export const editTodoProcess = createProcess('edit-todo', [ editTodoCommand ]);
export const clearCompletedProcess = createProcess('clear-completed', [ clearCompletedCommand, updateTodoCountsCommand, updateCompletedFlagCommand ]);
export const saveTodoProcess = createProcess('save-todo', [ saveTodoCommand ]);
export const searchProcess = createProcess('search', [ searchCommand ]);
export const setCurrentTodoProcess = createProcess('current-todo', [ setCurrentTodoCommand ]);
});
const logoutCommand = commandFactory(({ path }) => {
global.sessionStorage.removeItem('conduit-session');
return [replace(path('user'), {})];
});
export const loginProcess = createProcess('login', [startLoginCommand, loginCommand, clearLoginInputs]);
export const registerProcess = createProcess('register', [startRegisterCommand, registerCommand, clearRegisterInputs]);
export const loginEmailInputProcess = createProcess('login-email-input', [loginEmailInputCommand]);
export const loginPasswordInputProcess = createProcess('login-password-input', [loginPasswordInputCommand]);
export const registerEmailInputProcess = createProcess('register-email-input', [registerEmailInputCommand]);
export const registerPasswordInputProcess = createProcess('register-password-input', [registerPasswordInputCommand]);
export const registerUsernameInputProcess = createProcess('register-username-input', [registerUsernameInputCommand]);
export const setSessionProcess = createProcess('set-session', [setSessionCommand]);
export const logoutProcess = createProcess('logout', [logoutCommand]);
body: JSON.stringify(requestPayload)
});
const json = await response.json();
if (!response.ok) {
return [replace(path('editor', 'loading'), false), replace(path('errors'), json.errors)];
}
return [
replace(path('article', 'item'), json.article),
replace(path('article', 'loaded'), true),
replace(path('editor'), undefined)
];
});
export const titleInputProcess = createProcess('title-input', [titleInputCommand]);
export const descInputProcess = createProcess('desc-input', [descriptionInputCommand]);
export const bodyInputProcess = createProcess('body-input', [bodyInputCommand]);
export const tagInputProcess = createProcess('tag-input', [tagInputCommand]);
export const addTagProcess = createProcess('add-tag', [addTagCommand, clearTagInputCommand]);
export const removeTagProcess = createProcess('remove-tag', [removeTagCommand]);
export const getEditorArticleProcess = createProcess('get-editor-article', [getArticleForEditorCommand]);
export const publishArticleProcess = createProcess('publish-article', [startPublishCommand, publishArticleCommand]);
export const clearEditorProcess = createProcess('clear-editor', [clearEditorCommand]);