| … | … | @@ -72,24 +72,16 @@ const directory = async (r) => { |
| 72 | 72 | const header = new Headers() |
| 73 | 73 | header.append("Content-Type", "application/json") |
| 74 | 74 | header.append("Access-Control-Allow-Origin", "*") |
| 75 | const q = await apds.query(key) |
| 75 | 76 | if (db[key]) { |
| 76 | 77 | const ar = db[key] |
| 77 | 78 | return new Response(JSON.stringify(ar), {headers: header}) |
| 78 | 79 | } |
| 79 | | if (await apds.getLatest(key)) { |
| 80 | | const latest = await apds.getLatest(key) |
| 81 | | if (!latest.text) { |
| 82 | | const text = await apds.get(latest.opened.substring(13)) |
| 83 | | latest.text = text.value |
| 84 | | } |
| 85 | | return new Response(JSON.stringify(latest), {headers: header}) |
| 86 | | } |
| 87 | 80 | if (key === 'all') { |
| 88 | 81 | const q = await apds.query() |
| 89 | 82 | return new Response(JSON.stringify(q), {headers: header}) |
| 90 | 83 | } |
| 91 | | else if (key != '' && await apds.query(key)) { |
| 92 | | const q = await apds.query(key) |
| 84 | if (q[0]) { |
| 93 | 85 | return new Response(JSON.stringify(q), {headers: header}) |
| 94 | 86 | } else { |
| 95 | 87 | return serveDir(r, { |