mirror of
https://github.com/flibusta-apps/telegram_files_cache_server.git
synced 2025-12-06 06:35:38 +01:00
Fix for reuse connections
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::{config::CONFIG, prisma::PrismaClient};
|
||||
|
||||
pub async fn get_prisma_client() -> PrismaClient {
|
||||
let database_url: String = format!(
|
||||
"postgresql://{}:{}@{}:{}/{}?connection_limit=1",
|
||||
"postgresql://{}:{}@{}:{}/{}?connection_limit=10",
|
||||
CONFIG.postgres_user,
|
||||
CONFIG.postgres_password,
|
||||
CONFIG.postgres_host,
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
pub mod types;
|
||||
|
||||
use once_cell::sync::Lazy;
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
use crate::config::CONFIG;
|
||||
|
||||
use self::types::{BaseBook, Page};
|
||||
|
||||
pub static CLIENT: Lazy<reqwest::Client> = Lazy::new(reqwest::Client::new);
|
||||
|
||||
async fn _make_request<T>(
|
||||
url: &str,
|
||||
params: Vec<(&str, String)>,
|
||||
@@ -13,11 +16,9 @@ async fn _make_request<T>(
|
||||
where
|
||||
T: DeserializeOwned,
|
||||
{
|
||||
let client = reqwest::Client::new();
|
||||
|
||||
let formated_url = format!("{}{}", CONFIG.library_url, url);
|
||||
|
||||
let response = client
|
||||
let response = CLIENT
|
||||
.get(formated_url)
|
||||
.query(¶ms)
|
||||
.header("Authorization", CONFIG.library_api_key.clone())
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use reqwest::{Response, StatusCode};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::config::CONFIG;
|
||||
|
||||
pub static CLIENT: Lazy<reqwest::Client> = Lazy::new(reqwest::Client::new);
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct FilenameData {
|
||||
pub filename: String,
|
||||
@@ -19,7 +22,7 @@ pub async fn download_from_downloader(
|
||||
CONFIG.downloader_url
|
||||
);
|
||||
|
||||
let response = reqwest::Client::new()
|
||||
let response = CLIENT
|
||||
.get(url)
|
||||
.header("Authorization", &CONFIG.downloader_api_key)
|
||||
.send()
|
||||
@@ -42,7 +45,7 @@ pub async fn get_filename(
|
||||
CONFIG.downloader_url
|
||||
);
|
||||
|
||||
let response = reqwest::Client::new()
|
||||
let response = CLIENT
|
||||
.get(url)
|
||||
.header("Authorization", &CONFIG.downloader_api_key)
|
||||
.send()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use base64::{engine::general_purpose, Engine};
|
||||
use once_cell::sync::Lazy;
|
||||
use reqwest::{
|
||||
header,
|
||||
multipart::{Form, Part},
|
||||
@@ -8,6 +9,8 @@ use serde::Deserialize;
|
||||
|
||||
use crate::config::CONFIG;
|
||||
|
||||
pub static CLIENT: Lazy<reqwest::Client> = Lazy::new(reqwest::Client::new);
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct UploadData {
|
||||
pub chat_id: i64,
|
||||
@@ -29,7 +32,7 @@ pub async fn download_from_telegram_files(
|
||||
CONFIG.files_url
|
||||
);
|
||||
|
||||
let response = reqwest::Client::new()
|
||||
let response = CLIENT
|
||||
.get(url)
|
||||
.header("Authorization", CONFIG.files_api_key.clone())
|
||||
.send()
|
||||
@@ -72,7 +75,7 @@ pub async fn upload_to_telegram_files(
|
||||
.text("filename", filename)
|
||||
.part("file", part);
|
||||
|
||||
let response = reqwest::Client::new()
|
||||
let response = CLIENT
|
||||
.post(url)
|
||||
.header("Authorization", CONFIG.files_api_key.clone())
|
||||
.multipart(form)
|
||||
|
||||
Reference in New Issue
Block a user