Redo endpoints to get all data at once

This commit is contained in:
Ethan O'Brien
2026-05-04 12:35:22 -05:00
parent 902fbaec55
commit f7611937cc
8 changed files with 57 additions and 38 deletions

View File

@@ -33,6 +33,23 @@ fn dir_for(region: Region) -> &'static Dir<'static> {
}
}
pub fn get_all(region: Region) -> JsonValue {
let mut rv = object!{};
for file in dir_for(region).files() {
let table_name = file.path()
.file_stem()
.and_then(|s| s.to_str())
.unwrap_or_default();
if !table_name.is_empty() {
rv[table_name] = file.contents_utf8().unwrap_or_default().into();
}
}
rv
}
pub fn csv_bytes(region: Region, name: &str) -> Option<&'static [u8]> {
dir_for(region)
.get_file(format!("{name}.csv"))