| Crates.io | webshelf |
| lib.rs | webshelf |
| version | 0.1.0 |
| created_at | 2026-01-07 07:22:32.004803+00 |
| updated_at | 2026-01-11 13:43:43.270266+00 |
| description | The best way to develop your web service with one click. |
| homepage | https://www.openpick.org/webshelf |
| repository | https://github.com/aiqubits/webshelf |
| max_upload_size | |
| id | 2027699 |
| size | 214,876 |
The best way to develop your web service with one click.
WebShelf is a production-ready Rust web framework built on Axum, providing a complete backend scaffold with authentication, database integration, distributed locking, and comprehensive middleware support.
git clone https://github.com/aiqubits/webshelf.git
cd webshelf
Create a Docker network:
docker network create webshelf-net
Create a PostgreSQL database:
# creatdb webshelf
docker run --name webshelf-postgres \
--network webshelf-net \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=webshelf \
-p 5432:5432 \
-d postgres:16
Start Redis:
docker run --name webshelf-redis \
--network webshelf-net \
-p 6379:6379 \
-d redis:7-alpine
Copy and edit configuration:
mv config.toml.example config.toml
# Edit config.toml with your database credentials
cargo run
The server will start on http://0.0.0.0:3000 by default.
config.toml)# Database connection
database_url = "postgres://postgres:password@localhost:5432/webshelf"
# Redis for distributed locking
redis_url = "redis://localhost:6379"
# JWT settings
jwt_secret = "your-super-secret-key-change-in-production"
jwt_expiry_seconds = 3600
# Server settings
[server]
host = "0.0.0.0"
port = 3000
# Rate limiting
[rate_limit]
per_second = 2
burst_size = 5
webshelf [OPTIONS]
Options:
-H, --host <HOST> Server bind address [default: 0.0.0.0]
-P, --port <PORT> Server port [default: 3000]
-E, --env <ENV> Environment [default: development]
-C, --config <CONFIG> Configuration file path [default: config.toml]
-L, --log-level <LOG_LEVEL> Log level [default: info]
-h, --help Print help
-V, --version Print version
Example:
cargo run -- --host 127.0.0.1 --port 8080 --log-level debug
POST /api/public/auth/register
Content-Type: application/json
{
"email": "newuser@example.com",
"password": "Password123",
"name": "User Name"
}
Response:
{
"message": "User registered successfully",
"user_id": "550e8400-e29b-41d4-a716-446655440000"
}
POST /api/public/auth/login
Content-Type: application/json
{
"email": "newuser@example.com",
"password": "Password123"
}
Response:
{
"token": "eyJ0eXAiOiJKV1QiLCJhbGc...",
"token_type": "Bearer",
"expires_in": 3600,
"user_id": "550e8400-e29b-41d4-a716-446655440000",
"role": "user"
}
POST /api/users
Content-Type: application/json
{
"email": "newuser@example.com",
"password": "SecurePass123",
"name": "New User"
}
Response:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"email": "newuser@example.com",
"name": "New User",
"role": "user",
"created_at": "2026-01-11T06:00:00Z",
"updated_at": "2026-01-11T06:00:00Z"
}
GET /api/users/{id}
PUT /api/users/{id}
Content-Type: application/json
{
"email": "updated@example.com",
"name": "Updated Name",
"role": "admin"
}
DELETE /api/users/{id}
GET /api/users?page=1&per_page=10
GET /api/health
Response:
{
"status": "ok",
"version": "0.0.1"
}
webshelf/
โโโ k8s/ # Kubernetes manifests
โโโ migrations/ # Database migrations
โโโ src/
โ โโโ handlers/ # Request handlers
โ โ โโโ api.rs # API request handlers
โ โ โโโ auth.rs # Auth request handlers
โ โ โโโ mod.rs
โ โโโ middleware/ # Middleware components
โ โ โโโ auth.rs # JWT authentication
โ โ โโโ panic.rs # Panic capture
โ โ โโโ mod.rs
โ โโโ models/ # Data models
โ โ โโโ user.rs # User entity
โ โ โโโ mod.rs
โ โโโ routes/ # API routes
โ โ โโโ api.rs # User CRUD endpoints
โ โ โโโ auth.rs # Authentication endpoints
โ โ โโโ mod.rs
โ โโโ services/ # Business logic
โ โ โโโ auth.rs # Authentication service
โ โ โโโ user.rs # User service
โ โ โโโ lock.rs # Distributed locking
โ โ โโโ mod.rs
โ โโโ utils/ # Utilities
โ โ โโโ config.rs # Configuration loading
โ โ โโโ error.rs # Error types
โ โ โโโ logger.rs # Logging setup
โ โ โโโ password.rs # Password hashing
โ โ โโโ validator.rs # Input validation
โ โ โโโ mod.rs
โ โโโ bootstrap.rs # Initialization logic
โ โโโ lib.rs # Library exports
โ โโโ main.rs # Application entry
โ โโโ migrations.rs # Database migrations
โโโ tests/
โ โโโ integration_tests.rs # Integration tests
โโโ Cargo.toml # Dependencies
โโโ config.toml.example # Configuration
โโโ README.md # This file
cargo test
Note: Integration tests require PostgreSQL and Redis to be running.
# Start PostgreSQL and Redis first
cargo test --test integration_tests
See Cargo.toml for the complete dependency list.
cargo run -- --env development --log-level debug
cargo build --release
./target/release/webshelf --config prod.config.toml
Middleware execution order (innermost to outermost):
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.