1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! # {{app_name}}
//!
//! A JSON API built with Chyabrung. Where things live:
//!
//! | Path | What goes there | Create with |
//! |--------------------|----------------------------------------------------|-------------------------------------|
//! | `src/routes/` | every URL: `web.rs` pages, `api.rs` the JSON API | edit by hand |
//! | `src/controllers/` | handlers: read the request, return a response | `chy make:controller PostController`|
//! | (all of the above) | a whole feature: model to test, routes mounted | `chy make:resource Comment` |
//! | `src/models/` | one struct per database table | `chy make:model Post -m` |
//! | `src/requests/` | incoming data and its validation rules | add a file by hand |
//! | `src/responses/` | how models look in the API output (JSON resources) | `chy make:response Post` |
//! | `src/middleware/` | code that runs before or after handlers | `chy make:middleware EnsureAdmin` |
//! | `migrations/` | SQL that creates and changes tables | `chy make:migration add_bio_to_users`|
//! | `database/seeds/` | sample data for development | `chy make:seeder users` |
//! | `public/` | static files served at `/assets/...` | copy files in |
//! | `tests/` | automated tests (`cargo test`) | add a file by hand |
//!
//! This file wires everything together: shared state, global middleware and routes.
use *;
use has_role;
use Maintenance;
use Storage;
use Duration;
/// The migrations in `migrations/` (each file has `up` and `down`), built into
/// the app. They run when the app starts; `chy migrate`, `chy migrate:status`
/// and `chy migrate:rollback` run them too.
/// Build the application.