Skip to content

AsthoBin is a simple website to share pieces of code with a URL, written in Rust (available on https://bin.asthowen.fr).

License

Notifications You must be signed in to change notification settings

Asthowen/AsthoBin

Repository files navigation

AsthoBin

Made with Rust Use git
License Stars

AsthoBin is a simple website to share pieces of code with a URL, written in Rust.

Features

  • Lightweight < 5MB
  • Low RAM consumption
  • Responsive UI
  • Code coloring with syntect
  • Automatic deletion after custom time
  • Recovery of files raws

TODO

  • GitHub actions
  • Add code documentation
  • Unit tests
  • Docker image

Installation

Docker

Start by cloning the repo:

git clone https://github.com/Asthowen/AsthoBin.git && cd AsthoBin

After that, create a PostgreSQL database with the name you want, then edit .env config file, for this please refer to configuration.

And finally, run Docker container:

docker run -d \
  --name=asthobin \
  -p 8080:8080 \
  --restart unless-stopped \
  --env-file .env \
  asthowen/asthobin:latest

You can also use docker-compose with the docker/docker-compose.yml file.

Manually

Start by cloning the repo:

git clone https://github.com/Asthowen/AsthoBin.git && cd AsthoBin

For the next step you need to have Rust and Cargo installed on your PC, for that follow the official documentation. You will also need pnpm.

Now compile a release:

cargo build --release

Your executable will be in the target/release/ folder, it is named asthobin.

Configuration

To configure AsthoBin, just use the example configuration: .env.example, you just have to rename it to .env and complete it.

List of variables

Key Default Description
HOST 127.0.0.1 The desired hostname to launch AsthoBin.
PORT 8080 The desired port to launch AsthoBin.
DATABASE_URL Nothing (required, unless DATABASE_URL_FILE is present) The URL of your database.
DATABASE_URL_FILE Nothing (required, unless DATABASE_URL is present) Path to a file containing the URL of your database.
CORS_ORIGIN * CORS parameters.
DELETE_TIME 604800 Time (in seconds) for storing a bin.
LOG_ON_ACCESS false Display a log when a user access to a file.
LOG_ON_SAVE false Display a log when a user creates a file.
RATELIMIT_BETWEEN_SAVE 2 Number of seconds between each file save.
RATELIMIT_ALLOWED_BEFORE 4 Number of requests before blocking.
POOL_MAX_CONNECTIONS Nothing (optionnal) Maximum number of connections managed by the database pool.
POOL_MIN_RESERVED_CONNECTIONS Nothing (optionnal) Minimum idle connection count maintained by the database pool.
POOL_CONNECTION_TIMEOUT Nothing (optionnal) Connection timeout used by the database pool (in seconds).
TZ System value The time zone of the logger, e.g: Europe/Paris.

Development

Before submit a PR

You must make sure that clippy (cargo clippy) does not return any errors/warning. You must also run cargo fmt.

Versioning

This project uses semantic versioning, which has the format: MAJOR.MINOR.PATCH with:

  • MAJOR version when you make incompatible API changes.
  • MINOR version when you add functionality in a backwards compatible manner.
  • PATCH version when you make backwards compatible bug fixes.

Contributors

Asthowen

License

AsthoBin | GNU General Public License v3.0

About

AsthoBin is a simple website to share pieces of code with a URL, written in Rust (available on https://bin.asthowen.fr).

Resources

License

Stars

Watchers

Forks