TinyPath is a fast and reliable URL shortening service designed to simplify and manage long URLs. Built with Rust, it provides a scalable and efficient backend for generating and managing short URLs.
Note: This project is still under development. Features and documentation may change as work progresses.
- Shorten URLs: Generate unique short codes for long URLs.
- Database Integration: Uses PostgreSQL for persistent storage of short and long URLs.
- Logging: Structured logging with customizable log levels.
- Configurable: Easily configurable server settings and database connections.
- Error Handling: Properly structured API responses for error scenarios.
- Efficient Routing: Powered by Actix Web for high-performance HTTP handling.
To get started with TinyPath, you'll need Rust installed on your system along with PostgreSQL for database support.
- Rust (latest stable)
- PostgreSQL
-
Clone this repository:
git clone https://github.com/TG199/tinypath.git cd tinypath -
Setup your database:
CREATE DATABASE tinypath;
-
Run database migrations:
diesel migration run
-
Build and run the application:
cargo run
Once the server is running, you can interact with the API to shorten or retrieve URLs.
-
Shortening a URL:
- Endpoint:
/shorten - Method: POST
- Request Body:
{ "url": "https://example.com/some/long/path" } - Response:
{ "key": "abc123", "long_url": "https://example.com/some/long/path", "short_url": "http://localhost:8080/abc123" }
- Endpoint:
-
Redirecting to Long URL:
- Endpoint:
/abc123 - Method: GET
- Redirects to the long URL.
- Endpoint:
TinyPath uses a configuration file to manage runtime settings such as the server's host, port, and database URL.
--config <FILE>: Path to the configuration file.--host <HOST>: Host address for the server.--port <PORT>: Port for the server.--log-level <LEVEL>: Logging level (e.g.,trace,debug,info,warn,error).--database-url <URL>: Database connection URL.
src/cli.rs: Command-line interface for configuring the application.src/main.rs: Entry point of the application.src/types.rs: Defines data structures for API requests and responses.src/utils.rs: Utility functions for generating short codes.src/schema.rs: Database schema generated by Diesel.src/db/: Database models and operations.
Run the test suite using:
cargo testThis project is licensed under the MIT License. See the LICENSE file for details.