```ts if (!exists(proto_res) || !exists(proto_res.properties.periods)) return new Err(`No data from
i do check that
if (!exists(proto_res) || !exists(proto_res.properties.periods)) return new Err(`No data from ${WeatherAPIEndpoint}/hourly`);.ok and also check if the content-type includes application/json. You'd be surprised at how many APIs are wonky sometimes and return a 200 but an HTML error page or something.properties doesn't exist there, you'll get a TypeError. I'd check proto_res.properties exists tooif(!proto_res?.properties?.periods) with optional chaining.properties.periods would throw a TypeError if properties doesn't exist. For example:
performance.now() isnโt available in Workers and Date.now() doesnโt increment unless you do I/O is there any way to actually benchmark CPU bound function execution times in a worker?performance.now() is available but it just calls Date.now()internal server error anyplace to look to see better logging?app.onError to add your own handlerproduction stuff on the dashboard entirely right now
.okcontent-typeapplication/json.propertiesTypeErrorTypeErrorproto_res.propertiesif(!proto_res?.properties?.periods).properties.periodspropertiesperformance.now()performance.now()Date.now()Date.now()internal server errorapp.onErrorconst fetch_headers = {
'User-Agent': `${fitweather_credentials.name}/1.0 (Florida Institute of Technology Weather Discord Bot (Student Run), https://github.com/DaBigBlob/FIT-Weather-Chan)`,
'Accept': "application/geo+json"
};export function exists<T>(data: T|null|undefined): data is T {
if (
(data === null) ||
(data === undefined)
) return false;
return true;
}const obj = {foo: 'bar'}
console.log(obj.foo) // bar
console.log(obj.bar) // undefined
console.log(obj.bar.baz) // TypeErrorimport { Hono } from 'hono'
import { Client } from 'pg'
const app = new Hono()
const connstring = "postgresql://postgres@localhost:5432/hhscdev?schema=public"
app.get('*', async (c) => {
const client = new Client("postgresql://postgres@localhost:5432/hhscdev?schema=public");
await client.connect();
const { rows: [{ now }] } = await client.query('select now();');
return c.text(`Hello Hono! ${now}`)
})
export default app