adds API docs

This commit is contained in:
Christian Beutel
2024-03-23 20:19:20 +01:00
parent 6f01cecc22
commit 77b87e2d96
12 changed files with 113 additions and 9 deletions

View File

@@ -12,6 +12,11 @@
<div>
<h5 class="font-semibold">Resources</h5>
<ul class="mt-4 text-sm">
<li>
<a href="/docs/api/index.html"
>API {$_("documentation")}</a
>
</li>
<li>
<a href="https://github.com/Flomp/wanderer/wiki"
>{$_("documentation")}</a

View File

@@ -104,7 +104,7 @@
searchDropdownItems = result.hits.map((h: Record<string, any>) => ({
text: h.name,
description: `${h.division} | ${
description: `${h.division ? `${h.division} | ` : ""}${
country_codes[h["country code"] as keyof typeof country_codes]
}`,
value: h,

View File

@@ -203,7 +203,7 @@ export async function trails_create(trail: Trail, photos: File[], gpx: File | Bl
const model = await waypoints_create({
...waypoint,
marker: undefined,
});
}, f);
trail.waypoints.push(model.id!);
}
for (const summitLog of trail.expand.summit_logs) {

View File

@@ -5,11 +5,11 @@ import { writable, type Writable } from "svelte/store";
export const waypoint: Writable<Waypoint> = writable(new Waypoint(0, 0));
export async function waypoints_create(waypoint: Waypoint) {
export async function waypoints_create(waypoint: Waypoint, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
waypoint.author = pb.authStore.model!.id
let r = await fetch('/api/v1/waypoint', {
let r = await f('/api/v1/waypoint', {
method: 'PUT',
body: JSON.stringify(waypoint),
})

View File

@@ -47,7 +47,7 @@
const cityItems = response.results[1].hits.map(
(c: Record<string, any>) => ({
text: c.name,
description: `City | ${c.division} | ${
description: `City ${c.division ? `| ${c.division} ` : ""}| ${
country_codes[
c["country code"] as keyof typeof country_codes
]

View File

@@ -142,7 +142,7 @@
const cityItems = response.results[1].hits.map(
(c: Record<string, any>) => ({
text: c.name,
description: `City | ${c.division} | ${
description: `City ${c.division ? `| ${c.division} ` : ""}| ${
country_codes[
c["country code"] as keyof typeof country_codes
]

View File

@@ -51,7 +51,7 @@
const result = await r.json();
searchDropdownItems = result.hits.map((h: Record<string, any>) => ({
text: h.name,
description: `${h.division} | ${
description: `${h.division ? `${h.division} | ` : ""}${
country_codes[h["country code"] as keyof typeof country_codes]
}`,
value: h,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long