Skip to main content

max / makenotwork

1.7 KB · 44 lines History Blame Raw
1 //! Shared utility functions used across routes and modules.
2 //!
3 //! Organized into focused submodules and re-exported flat, so existing
4 //! `crate::helpers::*` imports keep working unchanged:
5 //!
6 //! - [`http`], shared outbound client, client-IP, HTMX/ETag, toast headers
7 //! - [`db`], unique-violation (23505) mapping + unique-slug insert loop
8 //! - [`render`], Askama fragment rendering + HTML escaping
9 //! - [`billing`], Stripe fee estimation + timestamp conversion
10 //! - [`datetime`], schedule-datetime parsing
11 //! - [`integration`], CSRF-token convenience + MT discussion stats
12 //!
13 //! Formatting, crypto, and rate limiting live in their own top-level modules and
14 //! are re-exported here too, for the same backward-compatibility reason.
15
16 mod billing;
17 mod datetime;
18 mod db;
19 mod http;
20 mod integration;
21 mod render;
22
23 pub use billing::{estimate_stripe_fee, stripe_timestamp};
24 pub use datetime::parse_schedule_datetime;
25 pub use db::{SLUG_SUFFIX_CAP, insert_with_unique_slug, is_unique_violation, map_unique_violation};
26 pub use http::{
27 HTTP_CLIENT, check_etag, extract_client_ip, htmx_toast_response, hx_toast,
28 ip_advisory_lock_key, is_htmx_request, with_etag,
29 };
30 pub use integration::{fetch_discussion_info, get_csrf_token};
31 pub use render::{escape_html, render_fragment};
32
33 pub use crate::crypto::{
34 constant_time_compare, generate_feed_url, generate_key_code, verify_feed_signature,
35 };
36 pub use crate::formatting::{
37 format_bytes, format_file_size, format_price, format_revenue, get_initials, sanitize_csv_cell,
38 slugify,
39 };
40 pub use crate::rate_limit::{
41 CloudflareIpKeyExtractor, SyncAppKeyExtractor, rate_limiter_ms, rate_limiter_per_sec,
42 synckit_app_rate_limiter_ms,
43 };
44