Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DATABASE_FILENAME=shortcut.db
BASE_STORE_PATH=
DATABASE_FILENAME=${BASE_STORE_PATH}shortcut.db
DATABASE_URL=sqlite://${DATABASE_FILENAME}?mode=rwc
PORT=8035
UI_URL=http://localhost:${PORT}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ SQLite-trunk*
*.db-shm
*.db-wal
ui/assets/main.css
build/*_installer.iss
build/windows/*_installer.iss
logs/
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ serde = { version = "1.0.219", features = ["derive"] }
sqlx = { version= "0.8.5", features=["sqlite", "runtime-tokio-native-tls", "macros"] }
state = "0.6.0"
tera = { version = "1.20", default-features = false}
tera-hot-reload = "0.2.4"
tera-hot-reload = "0.2.5"
tokio = { version = "1.45.0", features = ["full"] }
tower-http = { version = "0.6.4", features = ["full"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-appender = "0.2"
tracing = "0.1.40"
thiserror = "2.0.12"
url = "2.5.4"
Expand All @@ -26,7 +27,7 @@ mockall = "0.13.1"
auto-launch = "0.5.0"

[build-dependencies]
cc = "1.0"
cc = "1.2.27"

[features]
default = []
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tailwind-watch:
npx @tailwindcss/cli -i ./ui/styles/tailwind.css -o ./ui/assets/main.css --watch

server-watch:
RUST_LOG=info cargo watch -x run
RUST_LOG=info cargo watch -x run --ignore logs/ --ignore build/ --ignore docs/

build-windows:
echo "🦀 Building Rust project..."
Expand All @@ -22,13 +22,13 @@ build-windows:

# Linux commands (without inno):
VERSION=$(grep '^version' Cargo.toml | head -n1 | cut -d '"' -f2)
sed "s/{#AppVersion}/$VERSION/" build/windows_template.iss > build/windows_installer.iss
sed "s/{#AppVersion}/${VERSION}/" build/windows/windows_template.iss > build/windows/windows_installer.iss

# Window commands:
# $versionLine = Get-Content Cargo.toml | Where-Object { $_ -match '^version\s*=' } | Select-Object -First 1
# $version = $versionLine -replace '^version\s*=\s*"(.*)"', '$1'
# (Get-Content build\windows_template.iss) -replace '\{#AppVersion\}', $version | Set-Content build\windows_installer.iss
# & "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" ".\build\windows_installer.iss"
$versionLine = Get-Content Cargo.toml | Where-Object { $_ -match '^version\s*=' } | Select-Object -First 1
$version = $versionLine -replace '^version\s*=\s*"(.*)"', '$1'
(Get-Content build\windows\windows_template.iss) -replace '\{#AppVersion\}', $version | Set-Content build\windows\windows_installer.iss
& "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" ".\build\windows\windows_installer.iss"

echo "✅ Done!"

Expand Down
Binary file removed build/ShortcutInstaller.exe
Binary file not shown.
5 changes: 5 additions & 0 deletions build/windows/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
BASE_STORE_PATH=${homepath}/AppData/Roaming/Shortcut
DATABASE_FILENAME=${BASE_STORE_PATH}shortcut.db
DATABASE_URL=sqlite://${DATABASE_FILENAME}?mode=rwc
PORT=8035
UI_URL=http://localhost:${PORT}
Binary file added build/windows/ShortcutInstaller.exe
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ OutputDir=.
OutputBaseFilename=ShortcutInstaller
Compression=lzma
SolidCompression=yes
SetupIconFile=docs\icon.ico
SetupIconFile=docs\images\icon.ico

[Files]
Source: "target/x86_64-pc-windows-gnu/release/shortcut.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "../target/x86_64-pc-windows-gnu/release/ui/*"; DestDir: "{app}/ui/"; Flags: ignoreversion recursesubdirs
Source: "../.env"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs
Source: "build/windows.env"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs

[Icons]
Name: "{group}\Shortcut"; Filename: "{app}\shortcut.exe"
40 changes: 31 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ use repository::shortcut::{ShortcutRepository, ShortcutRepositoryTrait};
use routes::create_api_routes;
use sqlx::{Pool, Sqlite};
use templates::create_ui_routes;
use std::{sync::{LazyLock, RwLock}, time::Duration};
use std::{env, io, sync::{LazyLock, RwLock}, time::Duration};
use tera::Tera;
use tera_hot_reload::{watch, LiveReloadLayer};
use tokio::net::TcpListener;
use tower_http::{compression::CompressionLayer, cors::{Any, CorsLayer}, services::ServeDir, trace::TraceLayer};
use tracing::info;
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
use tracing_appender::rolling;
use tracing_subscriber::{filter, fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer};
use schema::connect_db;
use service::shortcut::ShortcutService;
use state::AppState;
Expand All @@ -49,7 +50,7 @@ pub async fn app() -> Result<Router, ()> {
.allow_methods([Method::GET, Method::POST, Method::DELETE, Method::PUT])
.allow_origin(Any)
.allow_headers([CONTENT_TYPE]);

let app: Router = Router::new()
.merge(create_ui_routes())
.nest_service("/assets", ServeDir::new("ui/assets"))
Expand All @@ -76,16 +77,37 @@ pub async fn app() -> Result<Router, ()> {

pub async fn run() {
dotenv().ok();
let base_store_path = std::env::var("BASE_STORE_PATH").unwrap_or(String::from(""));
eprintln!("{}", base_store_path);
let file_appender = rolling::never(base_store_path.clone() + "/logs", "full.log");
let (file_writer, guard) = tracing_appender::non_blocking(file_appender);
Box::leak(Box::new(guard));

let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| {
format!(
"{}=debug,tower_http=debug,axum::rejection=trace",
env!("CARGO_CRATE_NAME")
)
.into()
});

let file_layer = tracing_subscriber::fmt::layer()
.pretty()
.with_writer(file_writer);

tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| format!(
"{}=debug,tower_http=debug,axum::rejection=trace",
env!("CARGO_CRATE_NAME")
).into()),
// stdout layer, to view everything in the console
fmt::layer()
.compact()
.with_writer(io::stderr)
.with_filter(env_filter)
)
.with(
file_layer
.with_ansi(false)
.with_filter(filter::LevelFilter::DEBUG),
)
.with(tracing_subscriber::fmt::layer())
.init();

let port = std::env::var("PORT").unwrap_or(String::from("3000"));
Expand Down
Loading