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 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
//! API context: `settings`.
//!
//! This API context is responsible for handling the application settings.
//!
//! # Endpoints
//!
//! - [Get all settings](#get-all-settings)
//! - [Update all settings](#update-all-settings)
//! - [Get site name](#get-site-name)
//! - [Get public settings](#get-public-settings)
//!
//! # Get all settings
//!
//! `GET /v1/settings`
//!
//! Returns all settings.
//!
//! **Example request**
//!
//! ```bash
//! curl \
//! --header "Content-Type: application/json" \
//! --header "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjp7InVzZXJfaWQiOjEsInVzZXJuYW1lIjoiaW5kZXhhZG1pbiIsImFkbWluaXN0cmF0b3IiOnRydWV9LCJleHAiOjE2ODYyMTU3ODh9.4k8ty27DiWwOk4WVcYEhIrAndhpXMRWnLZ3i_HlJnvI" \
//! --request GET \
//! "http://127.0.0.1:3000/v1/settings"
//! ```
//!
//! **Example response** `200`
//!
//! ```json
//! {
//! "data": {
//! "website": {
//! "name": "Torrust"
//! },
//! "tracker": {
//! "url": "udp://localhost:6969",
//! "mode": "Public",
//! "api_url": "http://localhost:1212",
//! "token": "MyAccessToken",
//! "token_valid_seconds": 7257600
//! },
//! "net": {
//! "port": 3000,
//! "base_url": null
//! },
//! "auth": {
//! "email_on_signup": "Optional",
//! "min_password_length": 6,
//! "max_password_length": 64,
//! "secret_key": "MaxVerstappenWC2021"
//! },
//! "database": {
//! "connect_url": "sqlite://./storage/database/data.db?mode=rwc"
//! },
//! "mail": {
//! "email_verification_enabled": false,
//! "from": "example@email.com",
//! "reply_to": "noreply@email.com",
//! "username": "",
//! "password": "",
//! "server": "",
//! "port": 25
//! },
//! "image_cache": {
//! "max_request_timeout_ms": 1000,
//! "capacity": 128000000,
//! "entry_size_limit": 4000000,
//! "user_quota_period_seconds": 3600,
//! "user_quota_bytes": 64000000
//! },
//! "api": {
//! "default_torrent_page_size": 10,
//! "max_torrent_page_size": 30
//! },
//! "tracker_statistics_importer": {
//! "torrent_info_update_interval": 3600
//! }
//! }
//! }
//! ```
//! **Resource**
//!
//! Refer to the [`TorrustBackend`](crate::config::TorrustBackend)
//! struct for more information about the response attributes.
//!
//! # Update all settings
//!
//! **NOTICE**: This endpoint to update the settings does not work when you use
//! environment variables to configure the application. You need to use a
//! configuration file instead. Because settings are persisted in that file.
//! Refer to the issue [#144](https://github.com/torrust/torrust-index-backend/issues/144)
//! for more information.
//!
//! `POST /v1/settings`
//!
//! **Example request**
//!
//! ```bash
//! curl \
//! --header "Content-Type: application/json" \
//! --header "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjp7InVzZXJfaWQiOjEsInVzZXJuYW1lIjoiaW5kZXhhZG1pbiIsImFkbWluaXN0cmF0b3IiOnRydWV9LCJleHAiOjE2ODYyMTU3ODh9.4k8ty27DiWwOk4WVcYEhIrAndhpXMRWnLZ3i_HlJnvI" \
//! --request POST \
//! --data '{"website":{"name":"Torrust"},"tracker":{"url":"udp://localhost:6969","mode":"Public","api_url":"http://localhost:1212","token":"MyAccessToken","token_valid_seconds":7257600},"net":{"port":3000,"base_url":null},"auth":{"email_on_signup":"Optional","min_password_length":6,"max_password_length":64,"secret_key":"MaxVerstappenWC2021"},"database":{"connect_url":"sqlite://./storage/database/data.db?mode=rwc"},"mail":{"email_verification_enabled":false,"from":"example@email.com","reply_to":"noreply@email.com","username":"","password":"","server":"","port":25},"image_cache":{"max_request_timeout_ms":1000,"capacity":128000000,"entry_size_limit":4000000,"user_quota_period_seconds":3600,"user_quota_bytes":64000000},"api":{"default_torrent_page_size":10,"max_torrent_page_size":30},"tracker_statistics_importer":{"torrent_info_update_interval":3600}}' \
//! "http://127.0.0.1:3000/v1/settings"
//! ```
//!
//! The response contains the settings that were updated.
//!
//! **Resource**
//!
//! Refer to the [`TorrustBackend`](crate::config::TorrustBackend)
//! struct for more information about the response attributes.
//!
//! # Get site name
//!
//! `GET /v1/settings/name`
//!
//! It returns the name of the site.
//!
//! **Example request**
//!
//! ```bash
//! curl \
//! --header "Content-Type: application/json" \
//! --request GET \
//! "http://127.0.0.1:3000/v1/settings/name"
//! ```
//!
//! **Example response** `200`
//!
//! ```json
//! {
//! "data":"Torrust"
//! }
//! ```
//!
//! # Get public settings
//!
//! `GET /v1/settings/public`
//!
//! It returns all the public settings.
//!
//! **Example request**
//!
//! ```bash
//! curl \
//! --header "Content-Type: application/json" \
//! --request GET \
//! "http://127.0.0.1:3000/v1/settings/public"
//! ```
//!
//! **Example response** `200`
//!
//! ```json
//! {
//! "data": {
//! "website_name": "Torrust",
//! "tracker_url": "udp://localhost:6969",
//! "tracker_mode": "Public",
//! "email_on_signup": "Optional"
//! }
//! }
//! ```
//!
//! **Resource**
//!
//! Refer to the [`ConfigurationPublic`](crate::config::ConfigurationPublic)
//! struct for more information about the response attributes.
pub mod handlers;
pub mod routes;