rivet library

Rivet Framework

Classes

Auth
Middleware Annotations Annotation to apply authentication middleware with optional role-based authorization
Cache
In-memory cache with TTL and LRU eviction
CacheResponse
Cache Annotation Annotation to cache route responses
Delete
Email
Validator: Field must be a valid email
EmailValidator
Validator implementation for Email
FileWatcher
Watches files for changes and triggers callbacks
Get
GitHubOAuthProvider
GitHub OAuth provider
GoogleOAuthProvider
Google OAuth 2.0 provider
HotReloadManager
Manages hot reload functionality for the Rivet server
JWTPayload
JwtService
Service for JWT token generation and verification
Logger
Max
Validator: Field must be at most this value
MaxLength
Validator: Field must have maximum length
MaxLengthValidator
Validator implementation for MaxLength
MaxValidator
Validator implementation for Max
Middleware
Min
Validator: Field must be at least this value
MinLength
Validator: Field must have minimum length
MinLengthValidator
Validator implementation for MinLength
MinValidator
Validator implementation for Min
OAuthProvider
Abstract OAuth provider interface
OAuthToken
OAuth token response
OAuthUser
OAuth user information
PasswordHasher
Utility class for secure password hashing and verification
Patch
Post
Put
Required
Validator: Field is required
RequiredValidator
Validator implementation for Required
RivetClient
Annotation to generate a Rivet API client
RivetController
Annotation to mark a class as a Rivet controller
RivetRequest
RivetResponse
RivetServer
Route
Annotation to mark a method as a route
RouteGroup
Router
UseMiddleware
Annotation to apply custom middleware
Validate
Validation Annotations Annotation to apply validation to route
Validator
Base validator interface

Enums

LogLevel

Properties

cache → Cache
Global cache instance
final
logger → Logger
final

Functions

cors({dynamic origin = '*', List<String> methods = const ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'], List<String> headers = const ['Origin', 'X-Requested-With', 'Content-Type', 'Accept', 'Authorization'], bool credentials = false}) → MiddlewareHandler
createAuthMiddleware({required JwtService jwtService, List<String>? requiredRoles, bool optional = false}) → MiddlewareHandler
Create an authentication middleware that validates JWT tokens
createStaticHandler(String rootPath) → MiddlewareHandler
generateJWT({required String secret, required Map<String, dynamic> payload, Duration expiration = const Duration(hours: 24)}) → String
jsonLogger() → MiddlewareHandler
jwt({required String secret, String header = 'Authorization', String scheme = 'Bearer', List<String>? requiredRoles}) → MiddlewareHandler
optionalAuth(JwtService jwtService) → MiddlewareHandler
Middleware for optional authentication (validates if present, but doesn't require)
requestLogger({LogLevel level = LogLevel.info, bool includeBody = false}) → MiddlewareHandler
requireAuth(JwtService jwtService) → MiddlewareHandler
Middleware to require authentication (shorthand)
requireRoles(JwtService jwtService, List<String> roles) → MiddlewareHandler
Middleware to require specific roles

Typedefs

MiddlewareHandler = FutureOr Function(RivetRequest req, FutureOr next())

Exceptions / Errors

RivetException