Docs/v0.5.0 second pass (#496)

* update docs

* use auto-gen routes

* dumb deps

* remove whitespace

* github action to build dev docs container

* no cache

Co-authored-by: hay-kot <hay-kot@pm.me>
This commit is contained in:
Hayden
2021-06-11 21:57:59 -08:00
committed by GitHub
parent 06ed377c00
commit e34079673c
42 changed files with 555 additions and 508 deletions

View File

@@ -1,55 +1,38 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import i18n from "@/i18n.js";
const prefix = baseURL + "about";
const aboutURLs = {
version: `${prefix}/version`,
debug: `${prefix}`,
lastRecipe: `${prefix}/last-recipe-json`,
demo: `${prefix}/is-demo`,
log: num => `${prefix}/log/${num}`,
statistics: `${prefix}/statistics`,
events: `${prefix}/events`,
event: id => `${prefix}/events/${id}`,
allNotifications: `${prefix}/events/notifications`,
testNotifications: `${prefix}/events/notifications/test`,
notification: id => `${prefix}/events/notifications/${id}`,
};
import { API_ROUTES } from "./apiRoutes";
export const aboutAPI = {
async getEvents() {
const resposne = await apiReq.get(aboutURLs.events);
const resposne = await apiReq.get(API_ROUTES.aboutEvents);
return resposne.data;
},
async deleteEvent(id) {
const resposne = await apiReq.delete(aboutURLs.event(id));
const resposne = await apiReq.delete(API_ROUTES.aboutEventsId(id));
return resposne.data;
},
async deleteAllEvents() {
const resposne = await apiReq.delete(aboutURLs.events);
const resposne = await apiReq.delete(API_ROUTES.aboutEvents);
return resposne.data;
},
async allEventNotifications() {
const response = await apiReq.get(aboutURLs.allNotifications);
const response = await apiReq.get(API_ROUTES.aboutEventsNotifications);
return response.data;
},
async createNotification(data) {
const response = await apiReq.post(aboutURLs.allNotifications, data);
const response = await apiReq.post(API_ROUTES.aboutEventsNotifications, data);
return response.data;
},
async deleteNotification(id) {
const response = await apiReq.delete(aboutURLs.notification(id));
const response = await apiReq.delete(API_ROUTES.aboutEventsNotificationsId(id));
return response.data;
},
async testNotificationByID(id) {
const response = await apiReq.post(
aboutURLs.testNotifications,
API_ROUTES.aboutEventsNotificationsTest,
{ id: id },
() => i18n.t("events.something-went-wrong"),
() => i18n.t("events.test-message-sent")
@@ -58,7 +41,7 @@ export const aboutAPI = {
},
async testNotificationByURL(url) {
const response = await apiReq.post(
aboutURLs.testNotifications,
API_ROUTES.aboutEventsNotificationsTest,
{ test_url: url },
() => i18n.t("events.something-went-wrong"),
() => i18n.t("events.test-message-sent")

View File

@@ -1,4 +1,4 @@
const baseURL = "/api/";
import { prefix } from "./apiRoutes";
import axios from "axios";
import { store } from "../store";
import { utils } from "@/utils";
@@ -66,11 +66,10 @@ const apiReq = {
const response = await this.get(url);
const token = response.data.fileToken;
const tokenURL = baseURL + "utils/download?token=" + token;
const tokenURL = prefix + "utils/download?token=" + token;
window.open(tokenURL, "_blank");
return response.data;
},
};
export { apiReq };
export { baseURL };

View File

@@ -1,82 +1,87 @@
// This Content is Auto Generated
const prefix = '/api'
export const API_ROUTES = {
aboutEvents: "/api/about/events",
aboutEventsNotifications: "/api/about/events/notifications",
aboutEventsNotificationsTest: "/api/about/events/notifications/test",
authRefresh: "/api/auth/refresh",
authToken: "/api/auth/token",
authTokenLong: "/api/auth/token/long",
backupsAvailable: "/api/backups/available",
backupsExportDatabase: "/api/backups/export/database",
backupsUpload: "/api/backups/upload",
categories: "/api/categories",
categoriesEmpty: "/api/categories/empty",
debug: "/api/debug",
debugLastRecipeJson: "/api/debug/last-recipe-json",
debugLog: "/api/debug/log",
debugStatistics: "/api/debug/statistics",
debugVersion: "/api/debug/version",
groups: "/api/groups",
groupsSelf: "/api/groups/self",
mealPlansAll: "/api/meal-plans/all",
mealPlansCreate: "/api/meal-plans/create",
mealPlansThisWeek: "/api/meal-plans/this-week",
mealPlansToday: "/api/meal-plans/today",
mealPlansTodayImage: "/api/meal-plans/today/image",
migrations: "/api/migrations",
recipesCategory: "/api/recipes/category",
recipesCreate: "/api/recipes/create",
recipesCreateUrl: "/api/recipes/create-url",
recipesSummary: "/api/recipes/summary",
recipesSummaryUncategorized: "/api/recipes/summary/uncategorized",
recipesSummaryUntagged: "/api/recipes/summary/untagged",
recipesTag: "/api/recipes/tag",
shoppingLists: "/api/shopping-lists",
siteSettings: "/api/site-settings",
siteSettingsCustomPages: "/api/site-settings/custom-pages",
siteSettingsWebhooksTest: "/api/site-settings/webhooks/test",
tags: "/api/tags",
tagsEmpty: "/api/tags/empty",
themes: "/api/themes",
themesCreate: "/api/themes/create",
users: "/api/users",
usersApiTokens: "/api/users-tokens",
usersSelf: "/api/users/self",
usersSignUps: "/api/users/sign-ups",
utilsDownload: "/api/utils/download",
export const prefix = "/api";
export const API_ROUTES = {
aboutEvents: `${prefix}/about/events`,
aboutEventsNotifications: `${prefix}/about/events/notifications`,
aboutEventsNotificationsTest: `${prefix}/about/events/notifications/test`,
authRefresh: `${prefix}/auth/refresh`,
authToken: `${prefix}/auth/token`,
authTokenLong: `${prefix}/auth/token/long`,
backupsAvailable: `${prefix}/backups/available`,
backupsExportDatabase: `${prefix}/backups/export/database`,
backupsUpload: `${prefix}/backups/upload`,
categories: `${prefix}/categories`,
categoriesEmpty: `${prefix}/categories/empty`,
debug: `${prefix}/debug`,
debugLastRecipeJson: `${prefix}/debug/last-recipe-json`,
debugLog: `${prefix}/debug/log`,
debugStatistics: `${prefix}/debug/statistics`,
debugVersion: `${prefix}/debug/version`,
groups: `${prefix}/groups`,
groupsSelf: `${prefix}/groups/self`,
mealPlansAll: `${prefix}/meal-plans/all`,
mealPlansCreate: `${prefix}/meal-plans/create`,
mealPlansThisWeek: `${prefix}/meal-plans/this-week`,
mealPlansToday: `${prefix}/meal-plans/today`,
mealPlansTodayImage: `${prefix}/meal-plans/today/image`,
migrations: `${prefix}/migrations`,
recipesCategory: `${prefix}/recipes/category`,
recipesCreate: `${prefix}/recipes/create`,
recipesCreateUrl: `${prefix}/recipes/create-url`,
recipesSummary: `${prefix}/recipes/summary`,
recipesSummaryUncategorized: `${prefix}/recipes/summary/uncategorized`,
recipesSummaryUntagged: `${prefix}/recipes/summary/untagged`,
recipesTag: `${prefix}/recipes/tag`,
recipesTestScrapeUrl: `${prefix}/recipes/test-scrape-url`,
shoppingLists: `${prefix}/shopping-lists`,
siteSettings: `${prefix}/site-settings`,
siteSettingsCustomPages: `${prefix}/site-settings/custom-pages`,
siteSettingsWebhooksTest: `${prefix}/site-settings/webhooks/test`,
tags: `${prefix}/tags`,
tagsEmpty: `${prefix}/tags/empty`,
themes: `${prefix}/themes`,
themesCreate: `${prefix}/themes/create`,
users: `${prefix}/users`,
usersApiTokens: `${prefix}/users-tokens`,
usersSelf: `${prefix}/users/self`,
usersSignUps: `${prefix}/users/sign-ups`,
utilsDownload: `${prefix}/utils/download`,
aboutEventsId: (id) => `${prefix}/about/events/${id}`,
aboutEventsNotificationsId: (id) => `${prefix}/about/events/notifications/${id}`,
backupsFileNameDelete: (file_name) => `${prefix}/backups/${file_name}/delete`,
backupsFileNameDownload: (file_name) => `${prefix}/backups/${file_name}/download`,
backupsFileNameImport: (file_name) => `${prefix}/backups/${file_name}/import`,
categoriesCategory: (category) => `${prefix}/categories/${category}`,
debugLogNum: (num) => `${prefix}/debug/log/${num}`,
groupsId: (id) => `${prefix}/groups/${id}`,
mealPlansId: (id) => `${prefix}/meal-plans/${id}`,
mealPlansIdShoppingList: (id) => `${prefix}/meal-plans/${id}/shopping-list`,
mealPlansPlanId: (plan_id) => `${prefix}/meal-plans/${plan_id}`,
mediaRecipesRecipeSlugAssetsFileName: (recipe_slug, file_name) => `${prefix}/media/recipes/${recipe_slug}/assets/${file_name}`,
mediaRecipesRecipeSlugImagesFileName: (recipe_slug, file_name) => `${prefix}/media/recipes/${recipe_slug}/images/${file_name}`,
migrationsImportTypeFileNameDelete: (import_type, file_name) => `${prefix}/migrations/${import_type}/${file_name}/delete`,
migrationsImportTypeFileNameImport: (import_type, file_name) => `${prefix}/migrations/${import_type}/${file_name}/import`,
migrationsImportTypeUpload: (import_type) => `${prefix}/migrations/${import_type}/upload`,
recipesRecipeSlug: (recipe_slug) => `${prefix}/recipes/${recipe_slug}`,
recipesRecipeSlugAssets: (recipe_slug) => `${prefix}/recipes/${recipe_slug}/assets`,
recipesRecipeSlugImage: (recipe_slug) => `${prefix}/recipes/${recipe_slug}/image`,
recipesSlugComments: (slug) => `${prefix}/recipes/${slug}/comments`,
aboutEventsId: id => `${prefix}/about/events/${id}`,
aboutEventsNotificationsId: id => `${prefix}/about/events/notifications/${id}`,
backupsFileNameDelete: file_name => `${prefix}/backups/${file_name}/delete`,
backupsFileNameDownload: file_name => `${prefix}/backups/${file_name}/download`,
backupsFileNameImport: file_name => `${prefix}/backups/${file_name}/import`,
categoriesCategory: category => `${prefix}/categories/${category}`,
debugLogNum: num => `${prefix}/debug/log/${num}`,
groupsId: id => `${prefix}/groups/${id}`,
mealPlansId: id => `${prefix}/meal-plans/${id}`,
mealPlansIdShoppingList: id => `${prefix}/meal-plans/${id}/shopping-list`,
mealPlansPlanId: plan_id => `${prefix}/meal-plans/${plan_id}`,
mediaRecipesRecipeSlugAssetsFileName: (recipe_slug, file_name) =>
`${prefix}/media/recipes/${recipe_slug}/assets/${file_name}`,
mediaRecipesRecipeSlugImagesFileName: (recipe_slug, file_name) =>
`${prefix}/media/recipes/${recipe_slug}/images/${file_name}`,
migrationsImportTypeFileNameDelete: (import_type, file_name) =>
`${prefix}/migrations/${import_type}/${file_name}/delete`,
migrationsImportTypeFileNameImport: (import_type, file_name) =>
`${prefix}/migrations/${import_type}/${file_name}/import`,
migrationsImportTypeUpload: import_type => `${prefix}/migrations/${import_type}/upload`,
recipesRecipeSlug: recipe_slug => `${prefix}/recipes/${recipe_slug}`,
recipesRecipeSlugAssets: recipe_slug => `${prefix}/recipes/${recipe_slug}/assets`,
recipesRecipeSlugImage: recipe_slug => `${prefix}/recipes/${recipe_slug}/image`,
recipesSlugComments: slug => `${prefix}/recipes/${slug}/comments`,
recipesSlugCommentsId: (slug, id) => `${prefix}/recipes/${slug}/comments/${id}`,
shoppingListsId: (id) => `${prefix}/shopping-lists/${id}`,
siteSettingsCustomPagesId: (id) => `${prefix}/site-settings/custom-pages/${id}`,
tagsTag: (tag) => `${prefix}/tags/${tag}`,
themesId: (id) => `${prefix}/themes/${id}`,
usersApiTokensTokenId: (token_id) => `${prefix}/users-tokens/${token_id}`,
usersId: (id) => `${prefix}/users/${id}`,
usersIdFavorites: (id) => `${prefix}/users/${id}/favorites`,
shoppingListsId: id => `${prefix}/shopping-lists/${id}`,
siteSettingsCustomPagesId: id => `${prefix}/site-settings/custom-pages/${id}`,
tagsTag: tag => `${prefix}/tags/${tag}`,
themesId: id => `${prefix}/themes/${id}`,
usersApiTokensTokenId: token_id => `${prefix}/users-tokens/${token_id}`,
usersId: id => `${prefix}/users/${id}`,
usersIdFavorites: id => `${prefix}/users/${id}/favorites`,
usersIdFavoritesSlug: (id, slug) => `${prefix}/users/${id}/favorites/${slug}`,
usersIdImage: (id) => `${prefix}/users/${id}/image`,
usersIdPassword: (id) => `${prefix}/users/${id}/password`,
usersIdResetPassword: (id) => `${prefix}/users/${id}/reset-password`,
usersSignUpsToken: (token) => `${prefix}/users/sign-ups/${token}`,
}
usersIdImage: id => `${prefix}/users/${id}/image`,
usersIdPassword: id => `${prefix}/users/${id}/password`,
usersIdResetPassword: id => `${prefix}/users/${id}/reset-password`,
usersSignUpsToken: token => `${prefix}/users/sign-ups/${token}`,
};

View File

@@ -1,18 +1,7 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import { store } from "@/store";
import i18n from "@/i18n.js";
const backupBase = baseURL + "backups/";
export const backupURLs = {
// Backup
available: `${backupBase}available`,
createBackup: `${backupBase}export/database`,
importBackup: fileName => `${backupBase}${fileName}/import`,
deleteBackup: fileName => `${backupBase}${fileName}/delete`,
downloadBackup: fileName => `${backupBase}${fileName}/download`,
};
import { API_ROUTES } from "./apiRoutes";
export const backupAPI = {
/**
@@ -20,7 +9,7 @@ export const backupAPI = {
* @returns {Array} List of Available Backups
*/
async requestAvailable() {
let response = await apiReq.get(backupURLs.available);
let response = await apiReq.get(API_ROUTES.backupsAvailable);
return response.data;
},
/**
@@ -30,7 +19,7 @@ export const backupAPI = {
* @returns A report containing status of imported items
*/
async import(fileName, data) {
let response = await apiReq.post(backupURLs.importBackup(fileName), data);
let response = await apiReq.post(API_ROUTES.backupsFileNameImport(fileName), data);
store.dispatch("requestRecentRecipes");
return response;
},
@@ -40,7 +29,7 @@ export const backupAPI = {
*/
async delete(fileName) {
return apiReq.delete(
backupURLs.deleteBackup(fileName),
API_ROUTES.backupsFileNameDelete(fileName),
null,
() => i18n.t("settings.backup.unable-to-delete-backup"),
() => i18n.t("settings.backup.backup-deleted")
@@ -53,7 +42,7 @@ export const backupAPI = {
*/
async create(options) {
return apiReq.post(
backupURLs.createBackup,
API_ROUTES.backupsExportDatabase,
options,
() => i18n.t("settings.backup.error-creating-backup-see-log-file"),
response => {
@@ -67,7 +56,7 @@ export const backupAPI = {
* @returns Download URL
*/
async download(fileName) {
const url = backupURLs.downloadBackup(fileName);
const url = API_ROUTES.backupsFileNameDownload(fileName);
apiReq.download(url);
},
};

View File

@@ -1,30 +1,20 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import { store } from "@/store";
import i18n from "@/i18n.js";
const prefix = baseURL + "categories";
const categoryURLs = {
getAll: `${prefix}`,
getEmpty: `${prefix}/empty`,
getCategory: category => `${prefix}/${category}`,
deleteCategory: category => `${prefix}/${category}`,
updateCategory: category => `${prefix}/${category}`,
};
import { API_ROUTES } from "./apiRoutes";
export const categoryAPI = {
async getAll() {
let response = await apiReq.get(categoryURLs.getAll);
let response = await apiReq.get(API_ROUTES.categories);
return response.data;
},
async getEmpty() {
let response = await apiReq.get(categoryURLs.getEmpty);
let response = await apiReq.get(API_ROUTES.categoriesEmpty);
return response.data;
},
async create(name) {
const response = await apiReq.post(
categoryURLs.getAll,
API_ROUTES.categories,
{ name: name },
() => i18n.t("category.category-creation-failed"),
() => i18n.t("category.category-created")
@@ -35,12 +25,12 @@ export const categoryAPI = {
}
},
async getRecipesInCategory(category) {
let response = await apiReq.get(categoryURLs.getCategory(category));
let response = await apiReq.get(API_ROUTES.categoriesCategory(category));
return response.data;
},
async update(name, newName, overrideRequest = false) {
const response = await apiReq.put(
categoryURLs.updateCategory(name),
API_ROUTES.categoriesCategory(name),
{ name: newName },
() => i18n.t("category.category-update-failed"),
() => i18n.t("category.category-updated")
@@ -52,7 +42,7 @@ export const categoryAPI = {
},
async delete(category, overrideRequest = false) {
const response = await apiReq.delete(
categoryURLs.deleteCategory(category),
API_ROUTES.categoriesCategory(category),
null,
() => i18n.t("category.category-deletion-failed"),
() => i18n.t("category.category-deleted")
@@ -64,28 +54,18 @@ export const categoryAPI = {
},
};
const tagPrefix = baseURL + "tags";
const tagURLs = {
getAll: `${tagPrefix}`,
getEmpty: `${tagPrefix}/empty`,
getTag: tag => `${tagPrefix}/${tag}`,
deleteTag: tag => `${tagPrefix}/${tag}`,
updateTag: tag => `${tagPrefix}/${tag}`,
};
export const tagAPI = {
async getAll() {
let response = await apiReq.get(tagURLs.getAll);
let response = await apiReq.get(API_ROUTES.tags);
return response.data;
},
async getEmpty() {
let response = await apiReq.get(tagURLs.getEmpty);
let response = await apiReq.get(API_ROUTES.tagsEmpty);
return response.data;
},
async create(name) {
const response = await apiReq.post(
tagURLs.getAll,
API_ROUTES.tags,
{ name: name },
() => i18n.t("tag.tag-creation-failed"),
() => i18n.t("tag.tag-created")
@@ -96,12 +76,12 @@ export const tagAPI = {
}
},
async getRecipesInTag(tag) {
let response = await apiReq.get(tagURLs.getTag(tag));
let response = await apiReq.get(API_ROUTES.tagsTag(tag));
return response.data;
},
async update(name, newName, overrideRequest = false) {
const response = await apiReq.put(
tagURLs.updateTag(name),
API_ROUTES.tagsTag(name),
{ name: newName },
() => i18n.t("tag.tag-update-failed"),
() => i18n.t("tag.tag-updated")
@@ -116,7 +96,7 @@ export const tagAPI = {
},
async delete(tag, overrideRequest = false) {
const response = await apiReq.delete(
tagURLs.deleteTag(tag),
API_ROUTES.tagsTag(tag),
null,
() => i18n.t("tag.tag-deletion-failed"),
() => i18n.t("tag.tag-deleted")

View File

@@ -1,15 +1,6 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import i18n from "@/i18n.js";
const groupPrefix = baseURL + "groups";
const groupsURLs = {
groups: `${groupPrefix}`,
create: `${groupPrefix}`,
delete: id => `${groupPrefix}/${id}`,
current: `${groupPrefix}/self`,
update: id => `${groupPrefix}/${id}`,
};
import { API_ROUTES } from "./apiRoutes";
function deleteErrorText(response) {
switch (response.data.detail) {
@@ -29,31 +20,31 @@ function deleteErrorText(response) {
export const groupAPI = {
async allGroups() {
let response = await apiReq.get(groupsURLs.groups);
let response = await apiReq.get(API_ROUTES.groups);
return response.data;
},
create(name) {
return apiReq.post(
groupsURLs.create,
API_ROUTES.groups,
{ name: name },
() => i18n.t("group.user-group-creation-failed"),
() => i18n.t("group.user-group-created")
);
},
delete(id) {
return apiReq.delete(groupsURLs.delete(id), null, deleteErrorText, function() {
return apiReq.delete(API_ROUTES.groupsId(id), null, deleteErrorText, function() {
return i18n.t("group.group-deleted");
});
},
async current() {
const response = await apiReq.get(groupsURLs.current, null, null);
const response = await apiReq.get(API_ROUTES.groupsSelf, null, null);
if (response) {
return response.data;
}
},
update(data) {
return apiReq.put(
groupsURLs.update(data.id),
API_ROUTES.groupsId(data.id),
data,
() => i18n.t("group.error-updating-group"),
() => i18n.t("settings.group-settings-updated")

View File

@@ -1,25 +1,11 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import i18n from "@/i18n.js";
const prefix = baseURL + "meal-plans/";
const mealPlanURLs = {
// Meals
all: `${prefix}all`,
create: `${prefix}create`,
thisWeek: `${prefix}this-week`,
byId: planID => `${prefix}${planID}`,
update: planID => `${prefix}${planID}`,
delete: planID => `${prefix}${planID}`,
today: `${prefix}today`,
shopping: planID => `${prefix}${planID}/shopping-list`,
};
import { API_ROUTES } from "./apiRoutes";
export const mealplanAPI = {
create(postBody) {
return apiReq.post(
mealPlanURLs.create,
API_ROUTES.mealPlansCreate,
postBody,
() => i18n.t("meal-plan.mealplan-creation-failed"),
() => i18n.t("meal-plan.mealplan-created")
@@ -27,28 +13,28 @@ export const mealplanAPI = {
},
async all() {
let response = await apiReq.get(mealPlanURLs.all);
let response = await apiReq.get(API_ROUTES.mealPlansAll);
return response;
},
async thisWeek() {
let response = await apiReq.get(mealPlanURLs.thisWeek);
let response = await apiReq.get(API_ROUTES.mealPlansThisWeek);
return response.data;
},
async today() {
let response = await apiReq.get(mealPlanURLs.today);
let response = await apiReq.get(API_ROUTES.mealPlansToday);
return response;
},
async getById(id) {
let response = await apiReq.get(mealPlanURLs.byId(id));
let response = await apiReq.get(API_ROUTES.mealPlansId(id));
return response.data;
},
delete(id) {
return apiReq.delete(
mealPlanURLs.delete(id),
API_ROUTES.mealPlansId(id),
null,
() => i18n.t("meal-plan.mealplan-deletion-failed"),
() => i18n.t("meal-plan.mealplan-deleted")
@@ -57,7 +43,7 @@ export const mealplanAPI = {
update(id, body) {
return apiReq.put(
mealPlanURLs.update(id),
API_ROUTES.mealPlansId(id),
body,
() => i18n.t("meal-plan.mealplan-update-failed"),
() => i18n.t("meal-plan.mealplan-updated")
@@ -65,7 +51,7 @@ export const mealplanAPI = {
},
async shoppingList(id) {
let response = await apiReq.get(mealPlanURLs.shopping(id));
let response = await apiReq.get(API_ROUTES.mealPlansIdShoppingList(id));
return response.data;
},
};

View File

@@ -1,45 +1,29 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
const prefix = baseURL + "debug";
const debugURLs = {
version: `${prefix}/version`,
debug: `${prefix}`,
lastRecipe: `${prefix}/last-recipe-json`,
demo: `${prefix}/is-demo`,
log: num => `${prefix}/log/${num}`,
statistics: `${prefix}/statistics`,
};
import { API_ROUTES } from "./apiRoutes";
export const metaAPI = {
async getAppInfo() {
const response = await apiReq.get(debugURLs.version);
const response = await apiReq.get(API_ROUTES.debugVersion);
return response.data;
},
async getDebugInfo() {
const response = await apiReq.get(debugURLs.debug);
const response = await apiReq.get(API_ROUTES.debug);
return response.data;
},
async getLogText(num) {
const response = await apiReq.get(debugURLs.log(num));
const response = await apiReq.get(API_ROUTES.debugLog(num));
return response.data;
},
async getLastJson() {
const response = await apiReq.get(debugURLs.lastRecipe);
return response.data;
},
async getIsDemo() {
const response = await apiReq.get(debugURLs.demo);
const response = await apiReq.get(API_ROUTES.debugLastRecipeJson);
return response.data;
},
async getStatistics() {
const response = await apiReq.get(debugURLs.statistics);
const response = await apiReq.get(API_ROUTES.debugStatistics);
return response.data;
},
};

View File

@@ -1,25 +1,16 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import { store } from "../store";
import i18n from "@/i18n.js";
const migrationBase = baseURL + "migrations";
const migrationURLs = {
// New
all: migrationBase,
delete: (folder, file) => `${migrationBase}/${folder}/${file}/delete`,
import: (folder, file) => `${migrationBase}/${folder}/${file}/import`,
};
import { API_ROUTES } from "./apiRoutes";
export const migrationAPI = {
async getMigrations() {
let response = await apiReq.get(migrationURLs.all);
let response = await apiReq.get(API_ROUTES.migrations);
return response.data;
},
async delete(folder, file) {
const response = await apiReq.delete(
migrationURLs.delete(folder, file),
API_ROUTES.migrationsImportTypeFileNameDelete(folder, file),
null,
() => i18n.t("general.file-folder-not-found"),
() => i18n.t("migration.migration-data-removed")
@@ -27,7 +18,7 @@ export const migrationAPI = {
return response;
},
async import(folder, file) {
let response = await apiReq.post(migrationURLs.import(folder, file));
let response = await apiReq.post(API_ROUTES.migrationsImportTypeFileNameImport(folder, file));
store.dispatch("requestRecentRecipes");
return response.data;
},

View File

@@ -1,28 +1,8 @@
import { API_ROUTES } from "./apiRoutes";
import { apiReq } from "./api-utils";
import { baseURL } from "./api-utils";
import { store } from "../store";
import i18n from "@/i18n.js";
const prefix = baseURL + "recipes/";
const recipeURLs = {
allRecipes: baseURL + "recipes",
summary: baseURL + "recipes" + "/summary",
allRecipesByCategory: prefix + "category",
create: prefix + "create",
createByURL: prefix + "create-url",
testParseURL: prefix + "test-scrape-url",
recipe: slug => prefix + slug,
update: slug => prefix + slug,
delete: slug => prefix + slug,
createAsset: slug => `${prefix}${slug}/assets`,
recipeImage: slug => `${prefix}${slug}/image`,
updateImage: slug => `${prefix}${slug}/image`,
untagged: prefix + "summary/untagged",
uncategorized: prefix + "summary/uncategorized ",
};
export const recipeAPI = {
/**
* Create a Recipe by URL
@@ -30,7 +10,7 @@ export const recipeAPI = {
* @returns {string} Recipe Slug
*/
async createByURL(recipeURL) {
const response = await apiReq.post(recipeURLs.createByURL, { url: recipeURL }, false, () =>
const response = await apiReq.post(API_ROUTES.recipesCreateUrl, { url: recipeURL }, false, () =>
i18n.t("recipe.recipe-created")
);
@@ -39,13 +19,13 @@ export const recipeAPI = {
},
async getAllByCategory(categories) {
let response = await apiReq.post(recipeURLs.allRecipesByCategory, categories);
let response = await apiReq.post(API_ROUTES.recipesCategory, categories);
return response.data;
},
async create(recipeData) {
const response = await apiReq.post(
recipeURLs.create,
API_ROUTES.recipesCreate,
recipeData,
() => i18n.t("recipe.recipe-creation-failed"),
() => i18n.t("recipe.recipe-created")
@@ -55,7 +35,7 @@ export const recipeAPI = {
},
async requestDetails(recipeSlug) {
let response = await apiReq.get(recipeURLs.recipe(recipeSlug));
let response = await apiReq.get(API_ROUTES.recipesRecipeSlug(recipeSlug));
return response.data;
},
@@ -72,7 +52,7 @@ export const recipeAPI = {
}
return apiReq.put(
recipeURLs.updateImage(recipeSlug),
API_ROUTES.recipesRecipeSlugImage(recipeSlug),
formData,
() => i18n.t("general.image-upload-failed"),
successMessage
@@ -85,13 +65,13 @@ export const recipeAPI = {
fd.append("extension", fileObject.name.split(".").pop());
fd.append("name", name);
fd.append("icon", icon);
const response = apiReq.post(recipeURLs.createAsset(recipeSlug), fd);
const response = apiReq.post(API_ROUTES.recipesRecipeSlugAssets(recipeSlug), fd);
return response;
},
updateImagebyURL(slug, url) {
return apiReq.post(
recipeURLs.updateImage(slug),
API_ROUTES.recipesRecipeSlugImage(slug),
{ url: url },
() => i18n.t("general.image-upload-failed"),
() => i18n.t("recipe.recipe-image-updated")
@@ -100,7 +80,7 @@ export const recipeAPI = {
async update(data) {
let response = await apiReq.put(
recipeURLs.update(data.slug),
API_ROUTES.recipesRecipeSlug(data.slug),
data,
() => i18n.t("recipe.recipe-update-failed"),
() => i18n.t("recipe.recipe-updated")
@@ -112,14 +92,14 @@ export const recipeAPI = {
},
async patch(data) {
let response = await apiReq.patch(recipeURLs.update(data.slug), data);
let response = await apiReq.patch(API_ROUTES.recipesRecipeSlug(data.slug), data);
store.dispatch("patchRecipe", response.data);
return response.data;
},
async delete(recipeSlug) {
const response = await apiReq.delete(
recipeURLs.delete(recipeSlug),
API_ROUTES.recipesRecipeSlug(recipeSlug),
null,
() => i18n.t("recipe.unable-to-delete-recipe"),
() => i18n.t("recipe.recipe-deleted")
@@ -129,19 +109,19 @@ export const recipeAPI = {
},
async allSummary(start = 0, limit = 9999) {
const response = await apiReq.get(recipeURLs.summary, {
const response = await apiReq.get(API_ROUTES.recipesSummary, {
params: { start: start, limit: limit },
});
return response.data;
},
async allUntagged() {
const response = await apiReq.get(recipeURLs.untagged);
const response = await apiReq.get(API_ROUTES.recipesSummaryUntagged);
return response.data;
},
async allUnategorized() {
const response = await apiReq.get(recipeURLs.uncategorized);
const response = await apiReq.get(API_ROUTES.recipesSummaryUncategorized);
return response.data;
},
@@ -186,7 +166,7 @@ export const recipeAPI = {
},
async testScrapeURL(url) {
const response = await apiReq.post(recipeURLs.testParseURL, { url: url });
const response = await apiReq.post(API_ROUTES.recipesTestScrapeUrl, { url: url });
return response.data;
},
};

View File

@@ -1,27 +1,19 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
const settingsBase = baseURL + "site-settings";
const settingsURLs = {
siteSettings: `${settingsBase}`,
updateSiteSettings: `${settingsBase}`,
testWebhooks: `${settingsBase}/webhooks/test`,
};
import { API_ROUTES } from "./apiRoutes";
export const settingsAPI = {
async requestAll() {
let response = await apiReq.get(settingsURLs.siteSettings);
let response = await apiReq.get(API_ROUTES.siteSettings);
return response.data;
},
async testWebhooks() {
let response = await apiReq.post(settingsURLs.testWebhooks);
let response = await apiReq.post(API_ROUTES.siteSettingsWebhooksTest);
return response.data;
},
async update(body) {
let response = await apiReq.put(settingsURLs.updateSiteSettings, body);
let response = await apiReq.put(API_ROUTES.siteSettings, body);
return response.data;
},
};

View File

@@ -1,24 +1,15 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import i18n from "@/i18n.js";
const signUpPrefix = baseURL + "users/sign-ups";
const signUpURLs = {
all: `${signUpPrefix}`,
createToken: `${signUpPrefix}`,
deleteToken: token => `${signUpPrefix}/${token}`,
createUser: token => `${signUpPrefix}/${token}`,
};
import { API_ROUTES } from "./apiRoutes";
export const signupAPI = {
async getAll() {
let response = await apiReq.get(signUpURLs.all);
let response = await apiReq.get(API_ROUTES.usersSignUps);
return response.data;
},
async createToken(data) {
let response = await apiReq.post(
signUpURLs.createToken,
API_ROUTES.usersSignUps,
data,
() => i18n.t("signup.sign-up-link-creation-failed"),
() => i18n.t("signup.sign-up-link-created")
@@ -27,7 +18,7 @@ export const signupAPI = {
},
async deleteToken(token) {
return await apiReq.delete(
signUpURLs.deleteToken(token),
API_ROUTES.usersSignUpsToken(token),
null,
() => i18n.t("signup.sign-up-token-deletion-failed"),
() => i18n.t("signup.sign-up-token-deleted")
@@ -35,7 +26,7 @@ export const signupAPI = {
},
async createUser(token, data) {
return apiReq.post(
signUpURLs.createUser(token),
API_ROUTES.usersSignUpsToken(token),
data,
() => i18n.t("user.you-are-not-allowed-to-create-a-user"),
() => i18n.t("user.user-created")

View File

@@ -1,27 +1,17 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import { store } from "@/store";
import i18n from "@/i18n.js";
const settingsBase = baseURL + "site-settings";
const settingsURLs = {
siteSettings: `${settingsBase}`,
updateSiteSettings: `${settingsBase}`,
testWebhooks: `${settingsBase}/webhooks/test`,
customPages: `${settingsBase}/custom-pages`,
customPage: id => `${settingsBase}/custom-pages/${id}`,
};
import { API_ROUTES } from "./apiRoutes";
export const siteSettingsAPI = {
async get() {
let response = await apiReq.get(settingsURLs.siteSettings);
let response = await apiReq.get(API_ROUTES.siteSettings);
return response.data;
},
async update(body) {
const response = await apiReq.put(
settingsURLs.updateSiteSettings,
API_ROUTES.siteSettings,
body,
() => i18n.t("settings.settings-update-failed"),
() => i18n.t("settings.settings-updated")
@@ -33,18 +23,18 @@ export const siteSettingsAPI = {
},
async getPages() {
let response = await apiReq.get(settingsURLs.customPages);
let response = await apiReq.get(API_ROUTES.siteSettingsCustomPages);
return response.data;
},
async getPage(id) {
let response = await apiReq.get(settingsURLs.customPage(id));
let response = await apiReq.get(API_ROUTES.siteSettingsCustomPagesId(id));
return response.data;
},
createPage(body) {
return apiReq.post(
settingsURLs.customPages,
API_ROUTES.siteSettingsCustomPages,
body,
() => i18n.t("page.page-creation-failed"),
() => i18n.t("page.new-page-created")
@@ -53,7 +43,7 @@ export const siteSettingsAPI = {
async deletePage(id) {
return await apiReq.delete(
settingsURLs.customPage(id),
API_ROUTES.siteSettingsCustomPagesId(id),
null,
() => i18n.t("page.page-deletion-failed"),
() => i18n.t("page.page-deleted")
@@ -62,7 +52,7 @@ export const siteSettingsAPI = {
updatePage(body) {
return apiReq.put(
settingsURLs.customPage(body.id),
API_ROUTES.siteSettingsCustomPagesId(body.id),
body,
() => i18n.t("page.page-update-failed"),
() => i18n.t("page.page-updated")
@@ -71,7 +61,7 @@ export const siteSettingsAPI = {
async updateAllPages(allPages) {
let response = await apiReq.put(
settingsURLs.customPages,
API_ROUTES.siteSettingsCustomPages,
allPages,
() => i18n.t("page.pages-update-failed"),
() => i18n.t("page.pages-updated")

View File

@@ -1,31 +1,21 @@
import { baseURL } from "./api-utils";
import { apiReq } from "./api-utils";
import i18n from "@/i18n.js";
const prefix = baseURL + "themes";
const settingsURLs = {
allThemes: `${baseURL}themes`,
specificTheme: id => `${prefix}/${id}`,
createTheme: `${prefix}/create`,
updateTheme: id => `${prefix}/${id}`,
deleteTheme: id => `${prefix}/${id}`,
};
import { API_ROUTES } from "./apiRoutes";
export const themeAPI = {
async requestAll() {
let response = await apiReq.get(settingsURLs.allThemes);
let response = await apiReq.get(API_ROUTES.themes);
return response.data;
},
async requestByName(name) {
let response = await apiReq.get(settingsURLs.specificTheme(name));
let response = await apiReq.get(API_ROUTES.themesId(name));
return response.data;
},
async create(postBody) {
return await apiReq.post(
settingsURLs.createTheme,
API_ROUTES.themesCreate,
postBody,
() => i18n.t("settings.theme.error-creating-theme-see-log-file"),
() => i18n.t("settings.theme.theme-saved")
@@ -34,7 +24,7 @@ export const themeAPI = {
update(data) {
return apiReq.put(
settingsURLs.updateTheme(data.id),
API_ROUTES.themesId(data.id),
data,
() => i18n.t("settings.theme.error-updating-theme"),
() => i18n.t("settings.theme.theme-updated")
@@ -43,7 +33,7 @@ export const themeAPI = {
delete(id) {
return apiReq.delete(
settingsURLs.deleteTheme(id),
API_ROUTES.themesId(id),
null,
() => i18n.t("settings.theme.error-deleting-theme"),
() => i18n.t("settings.theme.theme-deleted")

View File

@@ -1,62 +1,44 @@
import { baseURL } from "./api-utils";
import { API_ROUTES } from "./apiRoutes";
import { apiReq } from "./api-utils";
import axios from "axios";
import i18n from "@/i18n.js";
const authPrefix = baseURL + "auth";
const userPrefix = baseURL + "users";
const authURLs = {
token: `${authPrefix}/token`,
refresh: `${authPrefix}/refresh`,
};
const usersURLs = {
users: `${userPrefix}`,
self: `${userPrefix}/self`,
userID: id => `${userPrefix}/${id}`,
password: id => `${userPrefix}/${id}/password`,
resetPassword: id => `${userPrefix}/${id}/reset-password`,
userAPICreate: `${userPrefix}/api-tokens`,
userAPIDelete: id => `${userPrefix}/api-tokens/${id}`,
};
export const userAPI = {
async login(formData) {
let response = await apiReq.post(authURLs.token, formData, null, function() {
let response = await apiReq.post(API_ROUTES.authToken, formData, null, function() {
return i18n.t("user.user-successfully-logged-in");
});
return response;
},
async refresh() {
let response = await axios.get(authURLs.refresh).catch(function(event) {
let response = await axios.get(API_ROUTES.authRefresh).catch(function(event) {
console.log("Fetch failed", event);
});
return response.data ? response.data : false;
},
async allUsers() {
let response = await apiReq.get(usersURLs.users);
let response = await apiReq.get(API_ROUTES.users);
return response.data;
},
create(user) {
return apiReq.post(
usersURLs.users,
API_ROUTES.users,
user,
() => i18n.t("user.user-creation-failed"),
() => i18n.t("user.user-created")
);
},
async self() {
let response = await apiReq.get(usersURLs.self);
let response = await apiReq.get(API_ROUTES.usersSelf);
return response.data;
},
async byID(id) {
let response = await apiReq.get(usersURLs.userID(id));
let response = await apiReq.get(API_ROUTES.usersId(id));
return response.data;
},
update(user) {
return apiReq.put(
usersURLs.userID(user.id),
API_ROUTES.usersId(user.id),
user,
() => i18n.t("user.user-update-failed"),
() => i18n.t("user.user-updated")
@@ -64,7 +46,7 @@ export const userAPI = {
},
changePassword(id, password) {
return apiReq.put(
usersURLs.password(id),
API_ROUTES.usersIdPassword(id),
password,
() => i18n.t("user.existing-password-does-not-match"),
() => i18n.t("user.password-updated")
@@ -72,24 +54,24 @@ export const userAPI = {
},
delete(id) {
return apiReq.delete(usersURLs.userID(id), null, deleteErrorText, () => {
return apiReq.delete(API_ROUTES.usersId(id), null, deleteErrorText, () => {
return i18n.t("user.user-deleted");
});
},
resetPassword(id) {
return apiReq.put(
usersURLs.resetPassword(id),
API_ROUTES.usersIdResetPassword(id),
null,
() => i18n.t("user.password-reset-failed"),
() => i18n.t("user.password-has-been-reset-to-the-default-password")
);
},
async createAPIToken(name) {
const response = await apiReq.post(usersURLs.userAPICreate, { name });
const response = await apiReq.post(API_ROUTES.usersApiTokens, { name });
return response.data;
},
async deleteAPIToken(id) {
const response = await apiReq.delete(usersURLs.userAPIDelete(id));
const response = await apiReq.delete(API_ROUTES.usersApiTokensTokenId(id));
return response.data;
},
/** Adds a Recipe to the users favorites

View File

@@ -44,7 +44,7 @@ import { api } from "@/api";
import BaseDialog from "./BaseDialog";
import ImportOptions from "@/components/FormHelpers/ImportOptions";
import TheDownloadBtn from "@/components/UI/Buttons/TheDownloadBtn.vue";
import { backupURLs } from "@/api/backup";
import { API_ROUTES } from "@/api/apiRoutes";
export default {
components: { ImportOptions, TheDownloadBtn, BaseDialog },
props: {
@@ -73,7 +73,7 @@ export default {
},
computed: {
downloadUrl() {
return backupURLs.downloadBackup(this.name);
return API_ROUTES.backupsFileNameDownload(this.name);
},
},
methods: {

View File

@@ -8,7 +8,7 @@ import { globals } from "@/utils/globals";
import i18n from "./i18n";
import "@mdi/font/css/materialdesignicons.css";
import "typeface-roboto/index.css";
import './registerServiceWorker'
import "./registerServiceWorker";
Vue.config.productionTip = false;
Vue.use(VueRouter);

View File

@@ -23,12 +23,3 @@ const icons = {
export const globals = {
icons,
};
/*
import { globals } from "@/utils/globals"
globals: globals,
{{ globals.icons. }}
*/