8000 GitHub - nachomglz/linx: Headless URL Shortener written in Rust
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

nachomglz/linx

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

linx

Headless URL Shortener written in Rust

Development

Requirements

Optional

For use with PostgreSQL

Setup for Local Development

Makefile

A Makefile is included to help setting up the environment and running the application with ease. Execute make env to create a copy of the .env.example file in the project directory. Then use make install to build Docker images, install SeaORM CLI and run migrations.

Finally use make run to start docker containers using Docker Compose detached mode and then execute the HTTP server by running cargo run against the server crate.

Remember to run make stop when you are done to shut down running containers and apply cleanup routines.

Before running any of the further commands, being database management or executing the server for local development, its important you follow the following setup steps before.

# clone this repository
git clone https://github.com/whizzes/linx.git

# step into repository directory
cd ./linx

# copy the `.env.example` file into a `.env` file
cp .env.example .env

# run docker compose containers
docker compose up -d

# run migrations
cargo run --bin migration -- up

# run server
RUST_LOG='server=debug' cargo run --bin server

Note: As of today migrations runs when bootstrapping the server automatically

Crates

This project uses Rust's Cargo Workspaces structure.

  • Entity: SeaORM Generated Entities
  • Migration: Database Migrations
  • Server: HTTP Server Application

Database Management

The following commands are used to manage the database used by linx. It's important to follow on the Setup for Local Development before.

Command Usage
cargo run --bin migration -- up Run all pending migrations
cargo run --bin migration -- down Rollback last applied migrations
cargo run --bin migration -- status Check migrations status
cargo run --bin migration -- fresh Drops all tables and apply migrations
cargo run --bin migration -- reset Rollback all applied migrations
cargo run --bin migration -- refresh Rollback all migrations and reapply them

Entities

Entities live in the entity crate. These are generated structs from the database state. To generate these structs you must have sea-orm-cli installed.

In future versions this no longer be required due to the availabilty of this feature.

Install sea-orm-cli if not yet installed:

cargo install sea-orm-cli

Finally run the sea-orm-cli providing the -u option with the database url. Make sure you run this command inside the entity/src directory.

sea-orm-cli generate entity -u postgresql://linx:linx@localhost:5432/linx

Contributions

All contributions to this project are welcome. Feel free to open a PR or issue

License

Licensed under the MIT License

About

Headless URL Shortener written in Rust

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 99.8%
  • Shell 0.2%
0