https://github.com/aeyoll/toothpaste
A pastebin written in Rust
https://github.com/aeyoll/toothpaste
axum bootstrap pastebin pastebin-service rust sqlite webpack
Last synced: 10 months ago
JSON representation
A pastebin written in Rust
- Host: GitHub
- URL: https://github.com/aeyoll/toothpaste
- Owner: aeyoll
- License: mit
- Created: 2021-09-02T06:39:03.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-22T07:11:05.000Z (over 1 year ago)
- Last Synced: 2024-10-22T07:37:48.108Z (over 1 year ago)
- Topics: axum, bootstrap, pastebin, pastebin-service, rust, sqlite, webpack
- Language: Rust
- Homepage:
- Size: 579 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-starred - aeyoll/toothpaste - A pastebin written in Rust (bootstrap)
README
# Toothpaste
[](https://conventionalcommits.org)

A pastebin application written in Rust with a frontend built using Yew. It also includes a CLI tool to create pastes.
## Requirements
- [Rust](https://www.rust-lang.org/)
- [Trunk](https://trunkrs.dev/)
## Project Structure
The project is organized into three main crates:
1. `toothpaste-backend`: The Rust backend server
2. `toothpaste-frontend`: The Yew-based frontend
3. `toothpaste-cli`: The CLI tool to create pastes
## Installation and Setup
1. Set the `DATABASE_URL` environment variable (e.g., `DATABASE_URL=sqlite://sqlite.db`).
2. Initialize the database:
```shell
touch sqlite.db
```
## Build the frontend assets
```shell
cd crates/toothpaste-frontend
# Build the frontend static
# For development
TOOTHPASTE_API_URL=http://127.0.0.1:8080 trunk serve --port 8081
# For production
trunk build --release
```
## Build and run the backend server:
```shell
toothpaste-backend --ip 127.0.0.1 --port 8080 # default values
```
## Build and run the CLI tool:
```shell
toothpaste-cli --name toothpaste.txt --expire-after 86400 < your-content.txt # From stdin redirection
cat your-content.txt | toothpaste-cli --name toothpaste.txt --expire-after 86400 # From stdin indirection
toothpaste-cli --expire-after 86400 -f your-content.txt # From file
```
## Set up a cron job for paste expiration cleanup:
```shell
* * * * * wget -q -O /dev/null "http(s)://your_host/api/paste/cleanup"
```
## Sample nginx configuration
```nginx
server {
server_name paste.foo.bar;
root /path/to/toothpaste/frontend;
location / {
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://127.0.0.1:8081;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
}
}
```
## License
See the LICENSE file for details.