Coder Social home page Coder Social logo

linx's Introduction

linx

Headless URL Shortener written in Rust

Development

Requirements

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.

Manual

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

linx's People

Contributors

estebanborai avatar palyzambrano avatar michael-liendo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.