Simple API gateway for webhooks

debug: add logs

finxol.io dd8c3a33 e4e0f18e

verified
+14 -9
+7 -7
src/main.ts
··· 53 53 `) 54 54 }) 55 55 56 - if (Deno.env.get("DENO_ENV") === "dev") { 57 - const { default: data } = await import("../test.json", { with: { type: "json" } }) 58 - kv.set( 59 - ["sensors", "latest"], 60 - { ...data }, 61 - ) 62 - } 56 + // if (Deno.env.get("DENO_ENV") === "dev") { 57 + // const { default: data } = await import("../test.json", { with: { type: "json" } }) 58 + // kv.set( 59 + // ["sensors", "latest"], 60 + // { ...data }, 61 + // ) 62 + // } 63 63 64 64 Deno.serve(app.fetch)
+7 -2
src/sensors.ts
··· 171 171 return c.text("Geoapify API error", 404) 172 172 } 173 173 174 + console.log( 175 + "Geoapify response structure:", 176 + JSON.stringify(geocode.value, null, 2), 177 + ) 178 + 174 179 const country = ReverseGeocodingSchema.safeParse(geocode.value) 175 180 176 181 if (!country.success) { 177 - console.error(country.error) 182 + console.error("ReverseGeocodingSchema validation failed:", country.error) 178 183 return c.text("Invalid country data", 400) 179 184 } 180 185 ··· 222 227 }), 223 228 async (c) => { 224 229 const body = c.req.valid("json") 225 - console.log(`Receiving sensor data at ${body.timestamp.toISOString()}`) 230 + console.log(`Receiving sensor data at ${body.timestamp.toISOString()}`, body) 226 231 227 232 // save data to kv store 228 233 await kv.set(["sensors", body.timestamp.toISOString()], body)