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
//! # twilio_rust
//!
//! `twilio_rust` is an extensible Actix-Web backend for generating [Twilio Video](https://www.twilio.com/video) tokens,
//! and optionally initiating [Stripe Checkout](https://stripe.com/docs/payments/checkout) sessions.
//!
//! ## โ
Features
//!
//! - ๐ฅ Generate secure Twilio JWT tokens for video rooms
//! - ๐ฐ Optional Stripe Checkout endpoint
//! - ๐ Rate limiting with `actix-governor`
//! - ๐งช Environment file support (`.env`, `.env.production`, etc.)
//!
//! ## ๐ง Configuration
//!
//! Start the app like this:
//!
//! ```bash
//! cargo run -- .env.production
//! ```
//!
//! ### Required `.env` values (Twilio)
//!
//! - `TWILIO_ACCOUNT_SID`
//! - `TWILIO_API_KEY_SID`
//! - `TWILIO_API_KEY_SECRET`
//! - `TOKEN_EXPIRY=3600` (optional, default: 3600s)
//!
//! ### Stripe Settings (only if `--features stripe` is enabled)
//!
//! - `STRIPE_SECRET_KEY`
//! - `STRIPE_SUCCESS_URL=https://your.site/success?room={room}&identity={identity}`
//! - `STRIPE_CANCEL_URL=https://your.site/cancel`
//! - `STRIPE_CURRENCY=eur`
//! - `STRIPE_UNIT_AMOUNT=1000`
//! - `STRIPE_PRODUCT_NAME=Private Video Call`
//!
//! ### Rate Limiting
//!
//! - `GOVERNOR_BURST=5`
//! - `GOVERNOR_PER_SECOND=2`
//!
//! ## โจ Feature Flags
//!
//! - `stripe`: Enables the `/api/create-checkout-session` endpoint.
//!
//! ## ๐ Modules
//!
//! - [`twilio`](crate::twilio) โ Twilio token generation
//! - [`utils`](crate::utils) โ Environment loader
//!
//! ### Stripe (conditionally included)
//!
//! - [`stripe`](crate::stripe) โ Stripe Checkout handler *(only with `--features stripe`)*
//!
//! ## ๐ License
//!
//! MIT License ยฉ [Holger Trahe](https://github.com/holg)