mirror of
https://github.com/minoplhy/chhoto-url.git
synced 2025-04-20 08:26:58 +00:00
1.2.0: update dependencies / add api_url / frontend reverse ordering
This commit is contained in:
parent
6deecbf3de
commit
7b5ceb1ce7
805
actix/Cargo.lock
generated
805
actix/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
[package]
|
[package]
|
||||||
name = "chhoto-url"
|
name = "chhoto-url"
|
||||||
version = "1.1.0"
|
version = "1.2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["Sayantan Santra <sayantan[dot]santra689[at]gmail[dot]com"]
|
authors = ["Sayantan Santra <sayantan[dot]santra689[at]gmail[dot]com"]
|
||||||
license = "mit"
|
license = "mit"
|
||||||
@ -27,14 +27,14 @@ categories = ["web-programming"]
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "4.5.1"
|
actix-web = "4.10.2"
|
||||||
actix-files = "0.6.5"
|
actix-files = "0.6.6"
|
||||||
rusqlite = { version = "0.32.0", features = ["bundled"] }
|
rusqlite = { version = "0.34.0", features = ["bundled"] }
|
||||||
regex = "1.10.3"
|
regex = "1.11.1"
|
||||||
rand = "0.8.5"
|
rand = "0.9.0"
|
||||||
actix-session = { version = "0.10.0", features = ["cookie-session"] }
|
actix-session = { version = "0.10.1", features = ["cookie-session"] }
|
||||||
env_logger = "0.11.1"
|
env_logger = "0.11.8"
|
||||||
nanoid = "0.4.0"
|
nanoid = "0.4.0"
|
||||||
serde_json = "1.0.115"
|
serde_json = "1.0.140"
|
||||||
serde = { version = "1.0.197", features = [ "derive" ] }
|
serde = { version = "1.0.219", features = [ "derive" ] }
|
||||||
once_cell = "1.20.2"
|
once_cell = "1.21.3"
|
||||||
|
@ -38,6 +38,16 @@ async fn main() -> Result<()> {
|
|||||||
.ok()
|
.ok()
|
||||||
.filter(|s| !s.trim().is_empty());
|
.filter(|s| !s.trim().is_empty());
|
||||||
|
|
||||||
|
let api_url = {
|
||||||
|
let mut get_api_url = env::var("api_url".replace("//", "/"))
|
||||||
|
.ok()
|
||||||
|
.unwrap_or_default();
|
||||||
|
if get_api_url.ends_with("/") {
|
||||||
|
get_api_url.pop();
|
||||||
|
}
|
||||||
|
get_api_url
|
||||||
|
};
|
||||||
|
|
||||||
// Actually start the server
|
// Actually start the server
|
||||||
HttpServer::new(move || {
|
HttpServer::new(move || {
|
||||||
App::new()
|
App::new()
|
||||||
@ -59,6 +69,7 @@ async fn main() -> Result<()> {
|
|||||||
middleware::DefaultHeaders::new()
|
middleware::DefaultHeaders::new()
|
||||||
})
|
})
|
||||||
.service(services::link_handler)
|
.service(services::link_handler)
|
||||||
|
.service(web::scope(&api_url)
|
||||||
.service(services::getall)
|
.service(services::getall)
|
||||||
.service(services::siteurl)
|
.service(services::siteurl)
|
||||||
.service(services::version)
|
.service(services::version)
|
||||||
@ -69,6 +80,7 @@ async fn main() -> Result<()> {
|
|||||||
.service(services::gen_api_key)
|
.service(services::gen_api_key)
|
||||||
.service(services::logout)
|
.service(services::logout)
|
||||||
.service(Files::new("/", "./resources/").index_file("index.html"))
|
.service(Files::new("/", "./resources/").index_file("index.html"))
|
||||||
|
)
|
||||||
.default_service(actix_web::web::get().to(services::error404))
|
.default_service(actix_web::web::get().to(services::error404))
|
||||||
})
|
})
|
||||||
.bind(("0.0.0.0", port))?
|
.bind(("0.0.0.0", port))?
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
use nanoid::nanoid;
|
use nanoid::nanoid;
|
||||||
use rand::seq::SliceRandom;
|
use rand::seq::IndexedRandom;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@ -156,8 +156,8 @@ pub fn gen_api_key(db: &Connection) -> (bool, String) {
|
|||||||
// From: https://stackoverflow.com/a/74953997
|
// From: https://stackoverflow.com/a/74953997
|
||||||
fn generate_string(len: usize) -> String {
|
fn generate_string(len: usize) -> String {
|
||||||
const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::rng();
|
||||||
let one_char = || CHARSET[rng.gen_range(0..CHARSET.len())] as char;
|
let one_char = || CHARSET[rng.random_range(0..CHARSET.len())] as char;
|
||||||
iter::repeat_with(one_char).take(len).collect()
|
iter::repeat_with(one_char).take(len).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,10 +204,10 @@ fn gen_link(style: String, len: usize) -> String {
|
|||||||
format!(
|
format!(
|
||||||
"{0}-{1}",
|
"{0}-{1}",
|
||||||
ADJECTIVES
|
ADJECTIVES
|
||||||
.choose(&mut rand::thread_rng())
|
.choose(&mut rand::rng())
|
||||||
.expect("Error choosing random adjective."),
|
.expect("Error choosing random adjective."),
|
||||||
NAMES
|
NAMES
|
||||||
.choose(&mut rand::thread_rng())
|
.choose(&mut rand::rng())
|
||||||
.expect("Error choosing random name.")
|
.expect("Error choosing random name.")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
10
compose.yaml
10
compose.yaml
@ -25,6 +25,16 @@ services:
|
|||||||
|
|
||||||
- password=TopSecretPass
|
- password=TopSecretPass
|
||||||
|
|
||||||
|
# Change it in case you want to change the path of api and frontend
|
||||||
|
# THIS WILL NOT CHANGE THE PATH OF SHORTURL!
|
||||||
|
# Example:
|
||||||
|
# api_url=/ui/
|
||||||
|
# UI -> https://example.com/ui/
|
||||||
|
# API -> https://example.com/ui/api
|
||||||
|
# SHORTLINK -> https://example.com/shortlink
|
||||||
|
#
|
||||||
|
# - api_url=
|
||||||
|
|
||||||
# Pass the redirect method, if needed. TEMPORARY and PERMANENT
|
# Pass the redirect method, if needed. TEMPORARY and PERMANENT
|
||||||
# are accepted values, defaults to PERMANENT.
|
# are accepted values, defaults to PERMANENT.
|
||||||
# - redirect_method=TEMPORARY
|
# - redirect_method=TEMPORARY
|
||||||
|
@ -57,7 +57,7 @@ const refreshData = async () => {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let data = await res.json();
|
let data = await res.json();
|
||||||
displayData(data);
|
displayData(data.reverse());
|
||||||
document.getElementById("api-key-button").hidden = false; // Show API Key button when logged in
|
document.getElementById("api-key-button").hidden = false; // Show API Key button when logged in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: Montserrat;
|
font-family: Montserrat;
|
||||||
src: url('/assets/Montserrat-VF.woff2');
|
src: url('../assets/Montserrat-VF.woff2');
|
||||||
}
|
}
|
||||||
|
|
||||||
* {
|
* {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user