Skip to content

TG199/tinypath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TinyPath

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.

Features

  • 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.

Table of Contents

  1. Getting Started
  2. Installation
  3. Usage
  4. Configuration
  5. Development
  6. License

Getting Started

To get started with TinyPath, you'll need Rust installed on your system along with PostgreSQL for database support.

Prerequisites

  • Rust (latest stable)
  • PostgreSQL

Installation

  1. Clone this repository:

    git clone https://github.com/TG199/tinypath.git
    cd tinypath
  2. Setup your database:

    CREATE DATABASE tinypath;
  3. Run database migrations:

    diesel migration run
  4. Build and run the application:

    cargo run

Usage

Once the server is running, you can interact with the API to shorten or retrieve URLs.

Example API Usage

  1. 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"
      }
  2. Redirecting to Long URL:

    • Endpoint: /abc123
    • Method: GET
    • Redirects to the long URL.

Configuration

TinyPath uses a configuration file to manage runtime settings such as the server's host, port, and database URL.

Command-Line Arguments

  • --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.

Development

Code Structure

  • 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.

Running Tests

Run the test suite using:

cargo test

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

Backend infra for a fast, reliable URL shortening service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages