James
05/27/2023, 7:18 PMif(!proto_res?.properties?.periods)
with optional chainingJames
05/27/2023, 7:19 PMkian
05/27/2023, 7:19 PMIdkWhatever69
05/27/2023, 7:19 PMkian
05/27/2023, 7:19 PMkian
05/27/2023, 7:19 PMF0rce
05/27/2023, 7:19 PMIdkWhatever69
05/27/2023, 7:20 PMts
export function exists<T>(data: T|null|undefined): data is T {
if (
(data === null) ||
(data === undefined)
) return false;
return true;
}
James
05/27/2023, 7:22 PM.properties.periods
would throw a TypeError
if properties
doesn't exist. For example:
js
const obj = {foo: 'bar'}
console.log(obj.foo) // bar
console.log(obj.bar) // undefined
console.log(obj.bar.baz) // TypeError
AA
05/27/2023, 7:23 PMIdkWhatever69
05/27/2023, 7:24 PMhttps://cdn.discordapp.com/attachments/779390076219686943/1112098934026932244/Screenshot_2023-05-28_at_12.53.54_AM.pngâ–¾
silence
05/27/2023, 7:25 PM(error) Error: Unexpected Server Error
lol I sure wish this error was betterandrew.rfc
05/27/2023, 7:52 PMperformance.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?kian
05/27/2023, 7:58 PMkian
05/27/2023, 7:58 PMperformance.now()
is available but it just calls Date.now()
andrew.rfc
05/27/2023, 8:06 PMAA
05/27/2023, 8:08 PMinternal server error
anyplace to look to see better logging?AA
05/27/2023, 8:08 PMWalshy | Pages
05/27/2023, 8:09 PMWalshy | Pages
05/27/2023, 8:09 PMAA
05/27/2023, 8:10 PMAA
05/27/2023, 8:10 PMts
import { 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
Walshy | Pages
05/27/2023, 8:11 PMWalshy | Pages
05/27/2023, 8:11 PMWalshy | Pages
05/27/2023, 8:11 PMapp.onError
to add your own handlerAA
05/27/2023, 8:11 PMAA
05/27/2023, 8:12 PMAA
05/27/2023, 8:20 PMAA
05/27/2023, 8:23 PMAA
05/27/2023, 8:23 PM