Version Khoj API, Update frontends, tests and docs to reflect it

- Split router.py into v1.0, beta and frontend (no-prefix) api modules
  under new router package. Version tag in main.py via prefix
- Update frontends to use the versioned api endpoints
- Update tests to work with versioned api endpoints
- Update docs to mentioned, reference only versioned api endpoints
This commit is contained in:
Debanjum Singh Solanky
2022-09-14 21:22:20 +03:00
parent ee65a4f2c7
commit e42a38e825
11 changed files with 154 additions and 124 deletions

View File

@@ -77,8 +77,8 @@
// Generate Backend API URL to execute Search
url = type === "image"
? `/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}`
: `/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}&r=${rerank}`;
? `/api/v1.0/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}`
: `/api/v1.0/search?q=${encodeURIComponent(query)}&t=${type}&n=${results_count}&r=${rerank}`;
// Execute Search and Render Results
fetch(url)
@@ -94,7 +94,7 @@
function updateIndex() {
type = document.getElementById("type").value;
fetch(`/reload?t=${type}`)
fetch(`/api/v1.0/update?t=${type}`)
.then(response => response.json())
.then(data => {
console.log(data);
@@ -118,7 +118,7 @@
function populate_type_dropdown() {
// Populate type dropdown field with enabled search types only
var possible_search_types = ["org", "markdown", "ledger", "music", "image"];
fetch("/config/data")
fetch("/api/v1.0/config/data")
.then(response => response.json())
.then(data => {
document.getElementById("type").innerHTML =