Documentation
This commit is contained in:
parent
63266dec56
commit
bb9a6ba9ec
5 changed files with 47 additions and 18 deletions
|
|
@ -1,28 +1,56 @@
|
|||
use std::time::Duration;
|
||||
|
||||
/// The name of the configuration file.
|
||||
/// it's located in the current directory.
|
||||
pub const FILE_CONF: &str = "conf.ron";
|
||||
|
||||
/// The name of the translation file.
|
||||
/// it's located in the current directory.
|
||||
pub const TRANSLATION_FILE: &str = "translation.ron";
|
||||
|
||||
/// Directory where the database is stored.
|
||||
/// It's located in the current directory.
|
||||
pub const DB_DIRECTORY: &str = "data";
|
||||
|
||||
/// Filename of the database.
|
||||
/// It's located in the `DB_DIRECTORY` directory.
|
||||
pub const DB_FILENAME: &str = "recipes.sqlite";
|
||||
|
||||
/// Path to the SQL file which contains the initial database schema.
|
||||
pub const SQL_FILENAME: &str = "sql/version_{VERSION}.sql";
|
||||
|
||||
/// When a new user sign up, he has this duration to validate his account.
|
||||
pub const VALIDATION_TOKEN_DURATION: i64 = 60 * 60; // [s]. (1 jour).
|
||||
|
||||
pub const COOKIE_AUTH_TOKEN_NAME: &str = "auth_token";
|
||||
pub const COOKIE_LANG_NAME: &str = "lang";
|
||||
|
||||
/// When an existing user reset his password, he has this duration to revalidate his account.
|
||||
pub const VALIDATION_PASSWORD_RESET_TOKEN_DURATION: i64 = 60 * 60; // [s]. (1 jour).
|
||||
|
||||
// Number of alphanumeric characters for tokens
|
||||
// (cookie authentication, password reset, validation token).
|
||||
/// The name of the cookie used for user authentication.
|
||||
pub const COOKIE_AUTH_TOKEN_NAME: &str = "auth_token";
|
||||
|
||||
/// The name of the cookie for the current language.
|
||||
/// Se here to know how the current language is defined: [crate::context].
|
||||
pub const COOKIE_LANG_NAME: &str = "lang";
|
||||
|
||||
/// Number of alphanumeric characters for tokens
|
||||
/// (cookie authentication, password reset, validation token).
|
||||
pub const TOKEN_SIZE: usize = 32;
|
||||
|
||||
/// When sending a validation email,
|
||||
/// the server has this duration to wait for a response from the SMTP server.
|
||||
pub const SEND_EMAIL_TIMEOUT: Duration = Duration::from_secs(60);
|
||||
|
||||
/// Some paths (like sign in, sign up, etc.) have a rate limit.
|
||||
/// This is the number of requests allowed in a given time ([DURATION_FOR_RATE_LIMIT]).
|
||||
pub const NUMBER_OF_CONCURRENT_HTTP_REQUEST_FOR_RATE_LIMIT: u64 = 10;
|
||||
|
||||
/// See [NUMBER_OF_CONCURRENT_HTTP_REQUEST_FOR_RATE_LIMIT].
|
||||
pub const DURATION_FOR_RATE_LIMIT: Duration = Duration::from_secs(2);
|
||||
|
||||
// HTTP headers, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers.
|
||||
// Common headers can be found in 'axum::http::header' (which is a re-export of the create 'http').
|
||||
pub const REVERSE_PROXY_IP_HTTP_FIELD: &str = "x-real-ip"; // Set by the reverse proxy (Nginx).
|
||||
/// HTTP headers, see <https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers>.
|
||||
/// Common headers can be found in `axum::http::header` (which is a re-export of the create 'http').
|
||||
/// Set by the reverse proxy (nginx).
|
||||
pub const REVERSE_PROXY_IP_HTTP_FIELD: &str = "x-real-ip";
|
||||
|
||||
pub const MAX_DB_CONNECTION: u32 = 1; // To avoid database lock.
|
||||
// To avoid database lock.
|
||||
pub const MAX_DB_CONNECTION: u32 = 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue