From dbedae1f58f270277fa8f38d8b6642a370e16dcc Mon Sep 17 00:00:00 2001 From: xyroscar Date: Wed, 6 Nov 2024 20:17:03 +0530 Subject: [PATCH] Refactoring code, fixing name and adding readme --- README.md | 79 +++++++++++++++++++++++++++++-- package.json | 2 +- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 4 +- src-tauri/src/{ => client}/api.rs | 0 src-tauri/src/client/mod.rs | 0 src-tauri/src/commands/mod.rs | 14 ++++++ src-tauri/src/main.rs | 18 ++----- src-tauri/src/storage/mod.rs | 2 +- src-tauri/tauri.conf.json | 6 +-- 10 files changed, 102 insertions(+), 25 deletions(-) rename src-tauri/src/{ => client}/api.rs (100%) create mode 100644 src-tauri/src/client/mod.rs diff --git a/README.md b/README.md index 858d179..cf59c39 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,78 @@ -# Tauri + SvelteKit + TypeScript +# Resona - API Client -This template should help get you started developing with Tauri, SvelteKit and TypeScript in Vite. +Resona is a modern, cross-platform API client built with Tauri, SvelteKit, and TypeScript. It provides a powerful interface for testing and managing API requests with features like workspace management, collections, and environment variables. -## Recommended IDE Setup +## Features -[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode) + [Tauri](https://marketplace.visualstudio.com/items?itemName=tauri-apps.tauri-vscode) + [rust-analyzer](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer). +- 🚀 Cross-platform desktop application (Windows, macOS, Linux) +- 📁 Workspace-based organization +- 📑 Request collections +- 🔄 Environment variables support +- 🎨 Beautiful UI with DaisyUI components +- 🌓 Light/Dark theme support +- 💾 Local storage persistence +- ⚡ Fast and lightweight + +## Tech Stack + +- **Frontend**: SvelteKit + TypeScript +- **Backend**: Tauri (Rust) +- **Styling**: TailwindCSS + DaisyUI +- **Database**: SQLite (via rusqlite) +- **Build Tool**: Vite + +## Prerequisites + +- Node.js (v16 or later) +- Bun +- Rust (latest stable) +- Cargo +- System dependencies for Tauri (see [Tauri prerequisites](https://tauri.app/v1/guides/getting-started/prerequisites)) + +## Installation + +1. Clone the repository and install dependencies: +```bash +git clone https://github.com/Xyroscar/resona.git +cd resona +bun install +``` + +2. For development server: +```bash +bun run tauri dev +``` + +This will launch both the SvelteKit development server and the Tauri application. + +## Building + +To create a production build: +```bash +bun run tauri build +``` + +The built application will be available in the `src-tauri/target/release` directory. + + +## Configuration + +### Development Server + +The development server runs on port 1420 by default. You can modify this in the `vite.config.ts` file. + +### Tauri + +Tauri configuration can be found in `src-tauri/tauri.conf.json`. This includes window settings, build configurations, and security policies. + +### Styling + +The application uses TailwindCSS with DaisyUI for styling. Configuration can be found in: +- `tailwind.config.js` - TailwindCSS configuration +- `src/app.css` - Global styles + +## Acknowledgments + +- [Tauri](https://tauri.app/) - For the desktop application framework +- [SvelteKit](https://kit.svelte.dev/) - For the frontend framework +- [DaisyUI](https://daisyui.com/) - For the UI components \ No newline at end of file diff --git a/package.json b/package.json index f839c0e..813579f 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "api-client", + "name": "resona", "version": "0.1.0", "description": "", "type": "module", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 56a46c2..af55d8e 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -75,7 +75,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13" [[package]] -name = "api-tester" +name = "Resona" version = "0.1.0" dependencies = [ "reqwest", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 6ae2122..31d3351 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,11 +1,11 @@ [package] -name = "api-tester" +name = "Resona" version = "0.1.0" description = "A Tauri App" authors = ["you"] license = "" repository = "" -default-run = "api-tester" +default-run = "resona" edition = "2021" rust-version = "1.60" diff --git a/src-tauri/src/api.rs b/src-tauri/src/client/api.rs similarity index 100% rename from src-tauri/src/api.rs rename to src-tauri/src/client/api.rs diff --git a/src-tauri/src/client/mod.rs b/src-tauri/src/client/mod.rs new file mode 100644 index 0000000..e69de29 diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs index cbfe3be..f7a9013 100644 --- a/src-tauri/src/commands/mod.rs +++ b/src-tauri/src/commands/mod.rs @@ -3,3 +3,17 @@ mod collection; pub use workspace::*; pub use collection::*; + +pub fn handlers() -> impl Fn(tauri::ipc::Invoke) -> bool { + tauri::generate_handler![ + create_workspace, + get_workspaces, + get_workspace, + update_workspace, + delete_workspace, + create_collection, + get_workspace_collections, + update_collection, + delete_collection + ] +} \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index e74cdd6..cd82c23 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -1,13 +1,15 @@ -mod api; mod models; mod storage; mod commands; +mod client; +use commands::handlers as h; use storage::Storage; use tauri::Manager; use std::sync::Mutex; fn main() { + let handlers = h(); tauri::Builder::default() .setup(|app| { let app_dir = app.path().app_data_dir() @@ -19,17 +21,7 @@ fn main() { app.manage(Mutex::new(storage)); Ok(()) }) - .invoke_handler(tauri::generate_handler![ - commands::create_workspace, - commands::get_workspaces, - commands::get_workspace, - commands::update_workspace, - commands::delete_workspace, - commands::create_collection, - commands::get_workspace_collections, - commands::update_collection, - commands::delete_collection, - ]) + .invoke_handler(handlers) .run(tauri::generate_context!()) .expect("error while running tauri application"); -} +} \ No newline at end of file diff --git a/src-tauri/src/storage/mod.rs b/src-tauri/src/storage/mod.rs index 5e4756a..6991b57 100644 --- a/src-tauri/src/storage/mod.rs +++ b/src-tauri/src/storage/mod.rs @@ -59,7 +59,7 @@ pub struct Storage { impl Storage { pub fn new(app_dir: PathBuf) -> rusqlite::Result { - let db_path = app_dir.join("api-client.db"); + let db_path = app_dir.join("resona.db"); let data_dir = app_dir.join("data"); fs::create_dir_all(&data_dir).map_err(|e| rusqlite::Error::InvalidPath(data_dir.clone()))?; diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 7de28d6..c799256 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,8 +1,8 @@ { "$schema": "https://schema.tauri.app/config/2", - "productName": "api-client", + "productName": "resona", "version": "0.1.0", - "identifier": "com.api-client.app", + "identifier": "com.resona.app", "build": { "beforeDevCommand": "bun run dev", "devUrl": "http://localhost:1420", @@ -12,7 +12,7 @@ "app": { "windows": [ { - "title": "api-client", + "title": "resona", "width": 800, "height": 600 }