-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refactor to move several key tables from TABLE_ROWS (pre-fetche…
…d in code) to live DB fetches, allowing the team to immediately see changes to these tables take effect
- Loading branch information
1 parent
9d3f16d
commit 975d32d
Showing
21 changed files
with
281 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { Router } from 'https://deno.land/x/[email protected]/router.ts' | ||
import { cached, defineRoute } from './_common.ts' | ||
import { PUBLIC_TABLES, Routes } from '../../types/route-types.ts' | ||
import { Status } from 'https://deno.land/[email protected]/http/http_status.ts' | ||
import { withDBConnection } from '../../utils/db.ts' | ||
import { ONE_MINUTE_MS } from '../../utils/constants.ts' | ||
|
||
export default function register(router: Router) { | ||
|
||
for (const table of PUBLIC_TABLES) { | ||
const endpoint = `/tables/${table}` as const | ||
|
||
defineRoute(router, { | ||
endpoint, | ||
method: 'get', | ||
handler: cached(5 * ONE_MINUTE_MS, async () => { | ||
const rows = await withDBConnection(db => db.queryTable(table)) as Routes[typeof endpoint]['response'] | ||
return [rows, Status.OK] | ||
}) | ||
}) | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.