|
| 1 | +Core Concept: User writes .sql files, SQLPage executes queries, results mapped to handlebars UI components, |
| 2 | +HTML streamed to client |
| 3 | + |
| 4 | +## Validation |
| 5 | + |
| 6 | +Mandatory formatting (rust): `cargo fmt --all` |
| 7 | + |
| 8 | +Mandatory linting: `cargo clippy --all-targets --all-features -- -D warnings` |
| 9 | + |
| 10 | +Frontend formatting: `npm run format` |
| 11 | + |
| 12 | +More about testing: see [github actions](./.github/workflows/ci.yml). |
| 13 | +Project structure: see [contribution guide](./CONTRIBUTING.md) |
| 14 | + |
| 15 | +Don’t reformat unrelated files. Always run tests/lints/format before stopping when you changed code. |
| 16 | + |
| 17 | +### Testing |
| 18 | + |
| 19 | +``` |
| 20 | +cargo test # tests with inmemory sqlite by default |
| 21 | +``` |
| 22 | + |
| 23 | +For other databases, see [docker testing setup](./docker-compose.yml) |
| 24 | + |
| 25 | +``` |
| 26 | +docker compose up -d mssql # or postgres or mysql |
| 27 | +DATABASE_URL='mssql://root:Password123!@localhost/sqlpage' cargo test # all dbms use the same user:pass and db name |
| 28 | +``` |
| 29 | + |
| 30 | +#### Project Conventions |
| 31 | + |
| 32 | +- Components: defined in `./sqlpage/templates/*.handlebars` |
| 33 | +- Functions: `src/webserver/database/sqlpage_functions/functions.rs` registered with `make_function!`. |
| 34 | +- Components and functions are documented in [official website](./examples/official-site/sqlpage/migrations/); one migration per component and per function. |
| 35 | +- ```sql |
| 36 | + CREATE TABLE component( |
| 37 | + name TEXT PRIMARY KEY, |
| 38 | + description TEXT NOT NULL, |
| 39 | + icon TEXT, -- icon name from tabler icon |
| 40 | + introduced_in_version TEXT |
| 41 | + ); |
| 42 | + |
| 43 | + CREATE TABLE parameter_type(name TEXT PRIMARY KEY); |
| 44 | + INSERT INTO parameter_type(name) VALUES ('BOOLEAN'), ('COLOR'), ('HTML'), ('ICON'), ('INTEGER'), ('JSON'), ('REAL'), ('TEXT'), ('TIMESTAMP'), ('URL'); |
| 45 | + |
| 46 | + CREATE TABLE parameter( |
| 47 | + top_level BOOLEAN DEFAULT FALSE, |
| 48 | + name TEXT, |
| 49 | + component TEXT REFERENCES component(name) ON DELETE CASCADE, |
| 50 | + description TEXT, |
| 51 | + description_md TEXT, |
| 52 | + type TEXT REFERENCES parameter_type(name) ON DELETE CASCADE, |
| 53 | + optional BOOLEAN DEFAULT FALSE, |
| 54 | + ); |
| 55 | + |
| 56 | + CREATE TABLE example( |
| 57 | + component TEXT REFERENCES component(name) ON DELETE CASCADE, |
| 58 | + description TEXT, |
| 59 | + properties JSON, |
| 60 | + ); |
| 61 | + ``` |
| 62 | +- [Configuration](./configuration.md): see [AppConfig](./src/app_config.rs) |
| 63 | +- Routing: file-based in `src/webserver/routing.rs`; not found handled via `src/default_404.sql`. |
| 64 | +- Follow patterns from similar modules before introducing new abstractions. |
| 65 | +- frontend: see [css](./sqlpage/sqlpage.css) and [js](./sqlpage/sqlpage.js) |
0 commit comments