magic: added a way for running async functions in the top level jsx code

This commit is contained in:
2023-01-11 21:38:37 +01:00
parent 71280fba5c
commit fab8398a7a
8 changed files with 91 additions and 44 deletions
+11
View File
@@ -0,0 +1,11 @@
import { Problem, Solution, User } from './model'
export type DatabaseConnection = {
getProblem(id: string): Promise<Problem | null>
}
export type Database = {
users: Record<string, User>
problems: Record<string, Problem>
solutions: Record<string, Solution>
}
+6 -1
View File
@@ -1,6 +1,11 @@
import { DatabaseConnection } from './database'
export type ServerAsyncCallback = () => Promise<void>
export type RenderedPage = {
html: string
metadata: any
asyncCallbacks: ServerAsyncCallback[]
}
export type RenderFunction = (url: string) => RenderedPage
export type RenderFunction = (url: string, db: DatabaseConnection) => RenderedPage