gridEdit5x5
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Viewing readonly version of main branch: v14View latest version
This app uses Val Town Blob Storage to manage data. Every Val Town account comes with free blob storage for simple key-value data persistence. This folder contains:
queries.ts- functions to read and write grid data to blob storage, which are imported and used in the main Hono server in/backend/index.ts
Instead of using SQLite, this app uses blob storage because:
- Simpler for this use case (no complex relationships)
- No need for database migrations
- Easy JSON serialization/deserialization
- Perfect for storing arrays of grid objects
The app stores a single blob with the key savedGrids containing an array of Grid objects. Each grid has:
id: unique identifiercells: array of 16 booleans representing the 4x4 grid statetimestamp: when the grid was createdsaved: whether the grid has been saved (prevents duplicate saves)
The queries file exports functions to:
getSavedGrids(): Retrieve all saved grids from blob storagesaveGrid(grid): Add a new grid to the saved collection (with duplicate prevention)
The functions handle cases where the blob doesn't exist yet and provide proper error handling for duplicate saves.