Versions
- Open: VersionChanges from v113 to v114+0-0⦚ 79 unchanged lines ⦚⦚ 79 unchanged lines ⦚
- Open: VersionChanges from v112 to v113+1-1⦚ 48 unchanged lines ⦚// }
return c.json({ queries, data: db.data[resource] });});⦚ 26 unchanged lines ⦚⦚ 48 unchanged lines ⦚// }return c.json({ queries, q, data: db.data[resource] });});⦚ 26 unchanged lines ⦚ - Open: VersionChanges from v111 to v112+14-14⦚ 32 unchanged lines ⦚}
if (queries.q) {let q = queries.q[0];q = q.toLowerCase();let chain = db.data[resource];chain.filter((obj) => {for (const key in obj) {const value = obj[key];if (value.includes(q)) {return true;}}return false;});}return c.json({ queries, data: db.data[resource] });⦚ 28 unchanged lines ⦚⦚ 32 unchanged lines ⦚}// if (queries.q) {// let q = queries.q[0];// q = q.toLowerCase();// let chain = db.data[resource];// chain.filter((obj) => {// for (const key in obj) {// const value = obj[key];// if (value.includes(q)) {// return true;// }// }// return false;// });// }return c.json({ queries, data: db.data[resource] });⦚ 28 unchanged lines ⦚ - Open: VersionChanges from v110 to v111+3-3⦚ 35 unchanged lines ⦚let q = queries.q[0];q = q.toLowerCase();
let chain = db.data[resource]chain.filter((obj) => {for (const key in obj) {const value = obj[key];if (value.includes(q) {return true;}⦚ 34 unchanged lines ⦚⦚ 35 unchanged lines ⦚let q = queries.q[0];q = q.toLowerCase();let chain = db.data[resource];chain.filter((obj) => {for (const key in obj) {const value = obj[key];if (value.includes(q)) {return true;}⦚ 34 unchanged lines ⦚ - Open: VersionChanges from v109 to v110+5-9⦚ 33 unchanged lines ⦚if (queries.q) {
const q = queries.q;// Full-text searchif (Array.isArray(q)) {q = q[0];}q = q.toLowerCase();chain = chain.filter((obj) => {for (const key in obj) {const value = obj[key];if (db._.deepQuery(value, q)) {return true;}⦚ 34 unchanged lines ⦚⦚ 33 unchanged lines ⦚if (queries.q) {let q = queries.q[0];q = q.toLowerCase();let chain = db.data[resource]chain.filter((obj) => {for (const key in obj) {const value = obj[key];if (value.includes(q) {return true;}⦚ 34 unchanged lines ⦚ - Open: VersionChanges from v108 to v109+2-1⦚ 32 unchanged lines ⦚}
if (q) {// Full-text searchif (Array.isArray(q)) {⦚ 45 unchanged lines ⦚⦚ 32 unchanged lines ⦚}if (queries.q) {const q = queries.q;// Full-text searchif (Array.isArray(q)) {⦚ 45 unchanged lines ⦚ - Open: VersionChanges from v107 to v108+19-0⦚ 32 unchanged lines ⦚}
return c.json({ queries, data: db.data[resource] });});⦚ 26 unchanged lines ⦚⦚ 32 unchanged lines ⦚}if (q) {// Full-text searchif (Array.isArray(q)) {q = q[0];}q = q.toLowerCase();chain = chain.filter((obj) => {for (const key in obj) {const value = obj[key];if (db._.deepQuery(value, q)) {return true;}}return false;});}return c.json({ queries, data: db.data[resource] });});⦚ 26 unchanged lines ⦚ - Open: VersionChanges from v106 to v107+1-1⦚ 32 unchanged lines ⦚}
return c.json({ queries, data: db.data[resource][0] });});⦚ 26 unchanged lines ⦚⦚ 32 unchanged lines ⦚}return c.json({ queries, data: db.data[resource] });});⦚ 26 unchanged lines ⦚ - Open: Version+63-0/** @jsxImportSource https://esm.sh/hono@3.9.2/jsx **/import { Homepage } from "https://esm.town/v/nbbaier/dbToAPIFrontend";import { checkResource, getResources, type Options, validate } from "https://esm.town/v/nbbaier/dbToApiHelpers";import { Hono } from "npm:hono";// TODO: implement optionsexport async function createServer(db, options?: Options) {const app = new Hono();// Make sure our db contains "data"if (!validate(db)) {app.get("/", c => c.text("Wrong data shape"));return app;}// Extract information about the resources in the dbconst resources = getResources(db);// Get / => returns homeapp.get("/", c => c.html(<Homepage resources={resources} />));// GET /db => returns all db dataapp.get("/db", c => c.json(db.data));// GET /:resource => if :resource is valid, returns db.data[resource]app.get("/:resource", c => {const { resource } = c.req.param();const queries = c.req.queries();if (!checkResource(resource, resources)) {return c.text(`The requested resource (${resource}) is not available`);}return c.json({ queries, data: db.data[resource][0] });});
Updated: February 4, 2024