You can access search results via JSON API by adding format=json
to your query:
https://codesearch.val.run/$2?q=api&page=49&format=json
For typeahead suggestions, use the /typeahead
endpoint:
https://codesearch.val.run/typeahead?q=api
Returns an array of strings in format "username" or "username/projectName"
Found 18047 results for "api"(497ms)
14- Admin panel for database management and inspection of both plants and settings tables
1516## API Endpoints
1718The application provides the following RESTful API endpoints:
1920### Garden Settings
2122#### GET /api/settings
23Returns the current garden configuration settings.
2425#### PUT /api/settings
26Updates garden configuration settings. Required fields:
27- `garden_width`: Width of the garden map in pixels (300-2000)
30### Plants
3132#### GET /api/plants
33Returns a list of all plants in the garden.
3435### GET /api/plants/:id
36Returns details for a specific plant by ID.
3738### POST /api/plants
39Creates a new plant. Required fields:
40- `x_coordinate`: X position on the map
46- `notes`: Additional information about the plant
4748### PUT /api/plants/:id
49Updates an existing plant. All fields are optional.
5051### DELETE /api/plants/:id
52Removes a plant from the garden.
53106## Technologies Used
107108- Hono.js for the API backend
109- SQLite for data storage
110- Vanilla JavaScript for the frontend
49initDatabase();
5051// API Routes
52// Get garden settings
53app.get("/api/settings", async (c) => {
54const settingsResult = await sqlite.execute(`SELECT * FROM ${SETTINGS_TABLE_NAME} WHERE id = 1`);
55return c.json(settingsResult.rows[0] || { garden_width: 800, garden_height: 500 });
5758// Update garden settings
59app.put("/api/settings", async (c) => {
60const body = await c.req.json();
61
8283// Get all plants
84app.get("/api/plants", async (c) => {
85const plantResults = await sqlite.execute(`SELECT * FROM ${TABLE_NAME} ORDER BY id DESC`);
86return c.json(plantResults.rows);
8889// Get database info (for admin purposes)
90app.get("/api/admin/db", async (c) => {
91// Get table schema for plants
92const plantsSchema = await sqlite.execute(`PRAGMA table_info(${TABLE_NAME})`);
121122// Get a specific plant
123app.get("/api/plants/:id", async (c) => {
124const id = c.req.param("id");
125const plants = await sqlite.execute(`SELECT * FROM ${TABLE_NAME} WHERE id = ?`, [id]);
133134// Create a new plant
135app.post("/api/plants", async (c) => {
136const body = await c.req.json();
137158159// Update a plant
160app.put("/api/plants/:id", async (c) => {
161const id = c.req.param("id");
162const body = await c.req.json();
190191// Delete a plant
192app.delete("/api/plants/:id", async (c) => {
193const id = c.req.param("id");
194