* Support JSON responses via Accept header * no update in migrations * No UPDATE in official site migrations - Updated the JSON component description to clarify its integration with external services and the ability to serve both HTML and JSON based on the HTTP Accept header. - Added examples demonstrating how to request JSON responses using `curl`. - Removed the obsolete migration file that documented the JSON response format feature, consolidating information into the main documentation. * revert stupid docs example change stupid bot * simplify tests * avoid string then json in tests, parse as json directly * changelog
2.1 KiB
Core Concept: User writes .sql files, SQLPage executes queries, results mapped to handlebars UI components, HTML streamed to client
Validation
When working on rust code
Mandatory formatting (rust): cargo fmt --all
Mandatory linting: cargo clippy --all-targets --all-features -- -D warnings
When working on css or js
Frontend formatting: npm run format
More about testing: see github actions. Project structure: see contribution guide
NEVER reformat/lint/touch files unrelated to your task. Always run tests/lints/format before stopping when you changed code.
Testing
cargo test # tests with inmemory sqlite by default
For other databases, see docker testing setup
docker compose up -d mssql # or postgres or mysql
DATABASE_URL='mssql://root:Password123!@localhost/sqlpage' cargo test # all dbms use the same user:pass and db name
Documentation
Components and functions are documented in official website; one migration per component and per function. You CAN update existing migrations, the official site database is recreated from scratch on each deployment.
official documentation website sql tables:
component(name,description,icon,introduced_in_version)-- icon name from tabler iconparameter(top_level BOOLEAN, name, component REFERENCES component(name), description, description_md, type, optional BOOLEAN)parameter types: BOOLEAN, COLOR, HTML, ICON, INTEGER, JSON, REAL, TEXT, TIMESTAMP, URLexample(component REFERENCES component(name), description, properties JSON)
Project Conventions
- Components: defined in
./sqlpage/templates/*.handlebars - Functions:
src/webserver/database/sqlpage_functions/functions.rsregistered withmake_function!. - Configuration: see AppConfig
- Routing: file-based in
src/webserver/routing.rs; not found handled viasrc/default_404.sql. - Follow patterns from similar modules before introducing new abstractions.
- frontend: see css and js