Skip to main content

Crate pipi

Crate pipi 

Source
Expand description

Welcome to Pipi

🚂 Pipi is Rust on Rails.

source framework crate cli crate Discord channel

English · 中文 · Français · Portuguese (Brazil)日本語 · 한국어 · Русский · Español

§What’s Pipi?

Pipi is strongly inspired by Rails. If you know Rails and Rust, you’ll feel at home. If you only know Rails and new to Rust, you’ll find Pipi refreshing. We do not assume you know Rails.

For a deeper dive into how Pipi works, including detailed guides, examples, and API references, check out our documentation website.

§Features of Pipi:

  • Convention Over Configuration: Similar to Ruby on Rails, Pipi emphasizes simplicity and productivity by reducing the need for boilerplate code. It uses sensible defaults, allowing developers to focus on writing business logic rather than spending time on configuration.

  • Rapid Development: Aim for high developer productivity, Pipi’s design focuses on reducing boilerplate code and providing intuitive APIs, allowing developers to iterate quickly and build prototypes with minimal effort.

  • ORM Integration: Model your business with robust entities, eliminating the need to write SQL. Define relationships, validation, and custom logic directly on your entities for enhanced maintainability and scalability.

  • Controllers: Handle web requests parameters, body, validation, and render a response that is content-aware. We use Axum for the best performance, simplicity, and extensibility. Controllers also allow you to easily build middlewares, which can be used to add logic such as authentication, logging, or error handling before passing requests to the main controller actions.

  • Views: Pipi can integrate with templating engines to generate dynamic HTML content from templates.

  • Background Jobs: Perform compute or I/O intensive jobs in the background with a Redis backed queue, or with threads. Implementing a worker is as simple as implementing a perform function for the Worker trait.

  • Scheduler: Simplifies the traditional, often cumbersome crontab system, making it easier and more elegant to schedule tasks or shell scripts.

  • Mailers: A mailer will deliver emails in the background using the existing pipi background worker infrastructure. It will all be seamless for you.

  • Storage: In Pipi Storage, we facilitate working with files through multiple operations. Storage can be in-memory, on disk, or use cloud services such as AWS S3, GCP, and Azure.

  • Cache: Pipi provides an cache layer to improve application performance by storing frequently accessed data.

So see more Pipi features, check out our documentation website.

§Getting Started

§Installation

Install the Pipi CLI from crates.io:

cargo install pipi-cli
cargo install sea-orm-cli # Only when DB is needed

The crate is named pipi-cli, but it installs the pipi command. Generated apps use the pipi-rs framework crate:

pipi = { package = "pipi-rs", version = "0.1.1" }

When developing the framework and a generated app together, point new projects at a local checkout instead:

PIPI_DEV_MODE_PATH=/absolute/path/to/pipi pipi new

Now you can create your new app (choose “SaaS app”).

❯ pipi new
✔ ❯ App name? · myapp
✔ ❯ What would you like to build? · Saas App with client side rendering
✔ ❯ Select a DB Provider · Sqlite
✔ ❯ Select your background worker type · Async (in-process tokio async tasks)

🚂 Pipi app generated successfully in:
myapp/

- assets: You've selected `clientside` for your asset serving configuration.

Next step, build your frontend:
  $ cd frontend/
  $ npm install && npm run build

Re-exports§

pub use self::errors::Error;
pub use validator;

Modules§

app
This module contains the core components and traits for building a web server application.
auth
bgworker
boot
Application Bootstrapping and Logic
cache
Cache Module
cargo_config
Cargo.toml configuration reader module
cli
command-line interface for running various tasks and commands related to the application. It allows developers to interact with the application via the command line.
config
Configuration Management
controller
Manage web server routing
data
db
Database Operations
doctor
Doctor module for health checks and diagnostics.
environment
Defines the application environment. By given the environment you can also load the application configuration
errors
Application Error Handling
hash
initializers
logger
initialization application logger.
mailer
This module defines the email-related functionality, including the Mailer trait and its implementation, Email structure, and the MailerWorker for asynchronous email processing.
model
Model Error Handling
prelude
scheduler
Scheduler Module
schema
storage
Storage Module
task
Task Management Module
testing
tests_cfg
validation
This module provides utility functions for handling validation errors for structs. It useful if you want to validate model before insert to Database.

Structs§

TestServer
The TestServer runs your Axum application, allowing you to make HTTP requests against it.

Type Aliases§

Result
Application results options list