serinus library

Classes

Adapter<TServer>
The Adapter class is used to create a new adapter.
AdapterContainer
The AdapterContainer class is used to manage adapters in the application. It allows adding, retrieving, and checking the existence of adapters by their name.
AfterHook
A simple hook that executes a function after the request is handled
Application
The Application class is used to create an application.
ApplicationConfig
The configuration for the application This is used to configure the application
ArgumentsHost
The base class for all argument hosts.
AugmentedMessage
The AugmentedMessage class is used to augment messages with optional parameters.
BaseContext
The BaseContext class must be used as the base class for all contexts.
BeforeHook
A simple hook that executes a function after the response is sent
BodySchemaValidationPipe
Represents a body schema validation pipe.
BodySizeLimitHook
The BodySizeLimitHook class is used to define a body size limit hook.
ClassMetadataNode
A ClassMetadataNode is a class that represents the metadata of a class in the inspector.
ClassNode
A ClassNode is a class that represents a provider in the inspector.
ClassProvider<T extends Provider>
A provider that substitutes one class for another.
ClassToClassEdgeMetadata
A ClassToClassEdgeMetadata is a class that represents the metadata of an edge between two classes in the inspector.
ClientRateLimiter
The ClientRateLimiter class is used to store the rate limit information.
ClientsModule
Module to register and manage microservice clients.
ComposedModule<T extends Module>
The ComposedModule class is used to define a composed module.
ComposedProvider<T extends Provider>
The ComposedProvider class is used to define a provider that is initialized asynchronously. The init function is called when the provider is initialized. The inject property contains the types of other Providers that will be injected in the provider.
CompositionContext
The CompositionContext class is used to provide dependencies to composed modules and composed providers.
ConsoleLogger
The ConsoleLogger class is used to log messages to the console.
ContextualizedMetadata<T>
ContextualizedMetadata is a metadata that is resolved at runtime.
Controller
The Controller class is used to define a controller.
CookieOptions
A class to encapsulate the options for a cookie
CorsHook
The CorsHook class is a hook that adds CORS headers to the response.
CustomProvider<T extends Provider>
A marker interface for custom provider definitions.
DefaultMessagesResolver
The DefaultMessagesResolver class is the default implementation of the MessagesResolver class.
DefaultValuePipe<T>
Represents a default value pipe.
DynamicModule
The DynamicModule class is used to define a dynamic module.
Edge
The Edge class is an abstract class that represents an edge in the inspector.
EdgeMetadata
A EdgeMetadata is a class that represents the metadata of an edge in the inspector.
EventData
The EventData class is used to store the data of an event.
EventPacket
Fire-and-forget event.
ExceptionFilter
An interface for handling exceptions in the application.
ExecutionContext<T extends ArgumentsHost>
The execution context for a request, WebSocket message, SSE message, or RPC message.
Export
Defines an export for a module.
FormData
The class FormData is used to parse multipart/form-data and application/x-www-form-urlencoded
GatewayScope
The GatewayScope class is used to define the scope of a WebSocket gateway. It contains the WebSocketGateway, the providers, and the hooks.
GlobalPrefix
Global prefix for all routes in the controller.
GraphInspector
The GraphInspector class is used to inspect the modules and their dependencies in the application. It creates a graph representation of the modules and their dependencies.
Hook
The Hook class is used to create hooks that can be used to execute code before and after the request is handled
Hookable
The Hookable class is used to create a hookable object.
HooksContainer
The HooksContainer class is used to manage hooks in the application.
HttpAdapter<TServer, TRequest, TResponse>
The HttpAdapter class is used to create an HTTP server adapter.
HttpArgumentsHost
The base class for response-based argument hosts.
IgnoreVersion
Metadata to ignore versioning for a controller or a route
IncomingMessage
The IncomingMessage interface defines the methods and properties that a request must implement. It is used to parse the request and provide access to its properties.
InstanceWrapper
Wraps an instance with metadata about its origin and dependencies
InternalRequest
The class Request is used to handle the request it also contains the httpRequest property that contains the HttpRequest object from dart:io
InternalResponse
The InternalResponse class is a wrapper around the HttpResponse class from dart:io.
Logger
The Logger class is a wrapper around the logging.Logger class.
LoggerService
The LoggerService class is used as a blueprint for the loggers.
MessageContext
Context for a message route, including its handler, providers, hooks, and exception filters.
MessageDeserializer<TOutput>
The MessageDeserializer class is used to define a message deserializer.
MessagePacket
Base message packet abstraction shared by request/event/response.
MessageSerializer<TInput>
The WebSocketContext class is used to define the context of the WebSocket.
MessagesResolver
The MessagesResolver class is used to resolve the message routes of the application.
Metadata<T>
The Metadata class is used to define metadata.
MicroserviceApplication
The MicroserviceApplication class is used to create a new instance of the Application class.
MicroservicesModule
The MicroservicesModule class is used to register the microservices module.
MicroservicesRegistry
The MicroservicesRegistry class is used to register the microservices in the application.
Middleware
The Middleware class is used to define a middleware.
MiddlewareConfiguration
Configuration for middleware in the application.
MiddlewareConsumer
A consumer for middleware configurations.
ModelProvider
A class that provides methods to convert a model to a Map<String, dynamic> and vice versa
Module
The Module class is used to define a module.
ModuleMetadataNode
A ModuleMetadataNode is a class that represents the metadata of a module in the inspector.
ModuleNode
A ModuleNode is a class that represents a module in the inspector.
ModulesContainer
A container for all the modules of the application.
ModuleScope
Defines the scope of a module including its providers, controllers, and relationships.
ModuleToModuleEdgeMetadata
A ModuleToModuleEdgeMetadata is a class that represents the metadata of a module to module edge in the inspector.
Node
A Node is a class that represents a node in the tree structure of the inspector.
NoopAdapter
The NoopAdapter class is a no-operation implementation of the HttpAdapter class.
OptionalParameters
The OptionalParameters class is used to define the optional parameters of the logger.
OutgoingMessage<T, THeaders>
The OutgoingMessage class is an abstract class that defines the methods and properties that an Outgoing message must implement in the Serinus framework.
ParseBoolPipe
Represents a boolean parsing pipe.
ParseDatePipe
Represents a date parsing pipe.
ParseDoublePipe
Represents a double parsing pipe.
ParseIntPipe
Represents an integer parsing pipe.
Pipe
Represents a pipe in the request processing pipeline.
Processable
The Processable class is used to create a processable object.
Provider
The Provider class is used to define a provider.
RateLimiterHook
The RateLimiterHook class is a hook that limits the number of requests a client can make.
RateStorage
The RateStorage class is used by the RateLimiterHook to store the rate limiters.
Redirect
The Redirect class is used to create the redirect response.
ReqResHandler<T, B>
Shortcut for a request-response handler. It takes a RequestContext and returns a Response.
Request
The class Request is used to create a request object.
RequestContext<TBody>
A context that exposes the current request information with a strongly typed body.
RequestHook
A simple hook that executes a function when the request is received
RequestPacket
Request expecting a response.
ResponseContext
The ResponseContext class is an utility class that provides a context for the response. It contains properties and methods to manage the response, such as status code, headers, content type, cookies, and more.
ResponseHook
A simple hook that executes a function when the response is sent
ResponsePacket
Response to a RequestPacket.
ResponseProperties
The ResponseProperties class is used to create the response properties.
RestRouteHandlerSpec<T, B>
The RestRouteHandlerSpec class is used to define a REST route handler specification.
Route
The Route class is used to define the routes of the application.
RouteHandlerSpec<T>
The RouteHandlerSpec class is used to define a route handler specification.
RouteInfo
Information about a specific route in the application.
RpcArgumentsHost
The base class for RPC-based argument hosts.
RpcContext
Context for an RPC message, either a request or an event.
RpcRoute
Route for RPC style communication over a transporter.
SecureSession
A class to manage secure sessions
SecureSessionHook
The SecureSessionHook class is used to create a hook that can be used to secure the session of the request.
SerializedGraph
The SerializedGraph class is used as a base class for the graph inspector. It contains the nodes and edges of the graph.
SerinusApplication
The SerinusApplication class is used to create a new instance of the Application class.
SerinusFactory
The SerinusFactory class is used to create a new instance of the SerinusApplication class.
SerinusHeaders
The SerinusHeaders are a helper class to expose the headers in the Serinus Framework.
SerinusHttpAdapter
The SerinusHttpAdapter class is used to create an HTTP server adapter. It extends the HttpAdapter class.
ServerEvent<T>
The ServerEvent class represents an event that is sent to the server. It contains the type of the event and the data associated with it.
Session
The class Session exposes the methods to interact with the session of the request.
SessionOptions
A class to encapsulate the options for a session
SessionValue
A class to encapsulate a session value
SkipRateLimit
The SkipRateLimit class is used to skip the rate limit for a request.
SseAdapter
The SseAdapter class is used to create a new Server-Sent Events (SSE) adapter.
SseArgumentsHost
The base class for Server-Sent Events-based argument hosts.
SseConnection
Code entirely copied from https://raw.githubusercontent.com/dart-lang/sse/master/lib/src/server/sse_handler.dart I wanted to use the SseConnection with my implementation of the Sse Handler but it was not possible because the method _addIncomingMessage is private. So I copied the whole code to be able to use it. A bi-directional SSE connection between server and browser.
SseContext
The SseContext class is used to store the context of a Server-Sent Event (SSE).
SseEmitter
The SseEmitter is responsible for dispatching SSE events to connected clients from other parts of the application.
SseEmitters
The SSE dispatchers are responsible for dispatching SSE events to connected clients.
SseEventData
Represents the data for a Server-Sent Event (SSE).
SseModule
The SSE module is responsible for managing Server-Sent Events (SSE) connections.
SseRegistry
The SseRegistry class is responsible for managing the Server-Sent Events (SSE) in the application.
SseRouteHandlerSpec
The SseRouteHandlerSpec class is used to define a Server-Sent Event (SSE) route handler specification.
SseScope
The SseScope class is used to define the scope of a Server-Sent Events (SSE) gateway. It contains the SseRouteSpec, the providers, and the hooks.
StreamableResponse
The StreamableResponse class is used to create a streamable response.
StreamedResponse
The StreamedResponse class is used to notify the server that the response is streamed.
TraceEvent
Represents a trace event.
Tracer
Base class for all tracers.
TransformPipe<R>
Represents a transformation pipe.
TransportAdapter<TDriver, TOptions extends TransportOptions>
Base class for a transport adapter (e.g. in-memory, Redis, NATS, etc.). It provides unified APIs for request/response (RPC) and event (pub/sub) semantics.
TransportClient<T extends TransportClientOptions>
Base class for a transport client (e.g. in-memory, Redis, NATS, etc.).
TransportClientOptions
Base class for transport client options.
TransportEvent
An abstract class representing a transport event.
TransportInstance
Wrapper class for a transport adapter instance.
TransportOptions
Base class for transport options.
UpgradedEventData
The UpgradedEventData class contains the data for an upgraded event.
UploadedFile
The class UploadedFile is used to represent a file uploaded by the user It is used to parse the file and store it in a string The string can be accessed by calling the toString method The readAsString method is used to parse the file and store it in the string The stream property is used to get the stream of the file The contentType property is used to get the content type of the file The name property is used to get the name of the file
ValueProvider<T>
A provider that registers a value directly under a type token.
ValueToken
A token that uniquely identifies a value provider.
VersioningOptions
Options for versioning the API
View
The View class contains all the information needed to render a view by a view engine.
ViewEngine
The abstract class ViewEngine is used to define the methods that a view engine must implement.
WebSocketAdapter
The WebSocketAdapter class is used to create a new WebSocket adapter.
WebSocketContext
The WebSocketContext class is used to create a new web socket context.
WebSocketGateway
The WebSocketGateway class is used to define a WebSocketGateway.
WrappedResponse
The WrappedResponse class is used to wrap the response data.
WsAdapter
The WsAdapter class is used to create a new web socket adapter
WsArgumentsHost
The base class for WebSocket-based argument hosts.
WsModule
The WsModule class is used to create a new instance of the Module class.

Enums

HostType
The type of host for the request.
HttpMethod
HTTP methods
InjectableType
An enum that represents the type of a class in the inspector.
LogLevel
The log level of the logger.
PipeBindingType
Enum representing the type of binding for a pipe.
RequestEvent
The ResponseEvent enum is used to define the different events that can be listened to on a response.
ServerEventType
The ServerEventType enum contains the types of server events.
TraceEvents
Represents a trace event.
VersioningType
Enum for versioning type

Mixins

JsonObject
Mixin for objects that can be converted to JSON.
OnAfterHandle
The OnAfterHandle mixin is used to execute code after the request is handled
OnApplicationBootstrap
The mixin OnApplicationBootstrap is used to define the method onApplicationBootstrap.
OnApplicationInit
The mixin OnApplicationInit is used to define the method onApplicationInit.
OnApplicationReady
The mixin OnApplicationReady is used to define the method onApplicationReady.
OnApplicationShutdown
The mixin OnApplicationShutdown is used to define the method onApplicationShutdown.
OnBeforeHandle
The OnBeforeHandle mixin is used to execute code before the request is handled
OnBeforeMessage
The OnBeforeMessage hook is called before a message is processed by the WebSocket gateway.
OnClientConnect
The OnClientConnect mixin is used to handle the client connections.
OnClientDisconnect
The OnClientDisconnect mixin is used to handle the client disconnections.
OnClientError
The OnClientError mixin is used to handle the client errors.
OnClose
The OnClose hook is called when a WebSocket connection is closed.
OnRequest
The OnRequest mixin is used to execute code before and after the request is handled
OnResponse
The OnResponse mixin is used to execute code before the response is sent
OnUpgrade
The OnUpgrade hook is called when a WebSocket connection is upgraded.
RpcController
Declarative registration for message/event handlers (MVP skeleton).
SseController
A mixin that adds support for Server-Sent Events (SSE) to a controller.

Extension Types

InjectionToken
A simple class to represent an injection token.

Extensions

AddIfAbsent on Iterable<T>
This extension is used to add an element to the list if it is not already present
BytesFormatter on int
Extensions for int class.
ContentTypeExtensions on ContentType
The extension ContentTypeExtensions is used to add functionalities to the ContentType class.
Flatten on Iterable<Iterable<T>>
This file contains the extensions for the Iterable class
HeadersToMap on HttpHeaders
This extension is used to convert a list of headers to a map
IsSse on IncomingMessage
Extension for IncomingMessage to check if it is an SSE request.
SplitTypes on Iterable<T>
This extension is used to split a list into two lists based on the type of the elements
StringMethod on String
Extension method to convert a string to a Method

Constants

kDebugMode → const bool
The kDebugMode constants is used to determine if the application is running in a debug mode. In actuality it is true when kReleaseMode and kProfileMode are false.
kDefaultMaxBodySize → const int
The default maximum body size in bytes.
kProfileMode → const bool
The kProfileMode constants is used to determine if the application is running in a profile mode.
kReleaseMode → const bool
The kReleaseMode constants is used to determine if the application is running in a compiled release mode.
saltLength → const int
The length of the salt
serinus → const SerinusFactory
The serinus instance is used to create a new instance of the SerinusFactory class.

Properties

defaultLogger LoggerService
The defaultLogger is used to create a new instance of the LoggerService class.
final
sharedJsonUtf8Encoder JsonUtf8Encoder
Shared JSON encoder to avoid repeated allocations.
final
utf8JsonDecoder Converter<List<int>, Object?>
The UTF-8 JSON decoder.
final

Functions

boolean() → AcanthisBoolean
Create a boolean validator
date() → AcanthisDate
Create a new date type
number() → AcanthisNumber
object(Map<String, AcanthisType> fields) → AcanthisMap
Create a map of fields
string() → AcanthisString
Create a new AcanthisString instance
trace<T>(T toTrace(), {required RequestContext context, required String eventName, String? traced}) → T
Traces a function.
traceAsync<T>(Future<T> toTrace(), {required RequestContext context, required String eventName, String? traced}) Future<T>
Traces an asynchronous function.
tuple(List<AcanthisType> elements) → AcanthisTuple
Creates a new AcanthisTuple with the given elements.
union<T>(List elements) → AcanthisUnion<T>
Factory for union of types / variants.

Typedefs

ErrorHandler = Object? Function(SerinusException e, StackTrace stackTrace)
The ErrorHandler type is used to define the error handler.
EventHandler = Future<void> Function(RpcContext context)
Type definition for an event handler function.
MessageHandler<T> = Future<T> Function(RpcContext context)
Type definition for a message handler function.
NextFunction = Future<void> Function([Object? data])
The NextFunction type is used to define the next function of the middleware.
NotFoundHandler = SerinusException Function(Request request)
The NotFoundHandler type is used to define the not found handler.
RequestCallback<TRequest, TResponse> = Future<void> Function(TRequest request, TResponse response)
The RequestCallback type is used to define the request callback.
WsMessageHandler = Future<void> Function(dynamic data, WebSocketContext context)
The WsRequestHandler is used to handle the web socket request

Exceptions / Errors

BadGatewayException
The class BadGatewayException is used to throw a bad gateway exception
BadRequestException
The class BadRequestException is used to throw a bad request exception
ConflictException
The class ConflictException is used to throw a conflict exception
ForbiddenException
The class ForbiddenException is used to throw a forbidden exception
GatewayTimeoutException
The class GatewayTimeoutException is used to throw a gone exception
GoneException
The class GoneException is used to throw a gone exception
HttpVersionNotSupportedException
The class HttpVersionNotSupportedException is used to throw an http version notsupported exception
InitializationError
The InitializationError should be thrown when something during the initialization of the Serinus Application went wrong not for an error of the library but caused by the user.
InternalServerErrorException
The class InternalServerErrorException is used to throw a internal server error exception
MethodNotAllowedException
The class MethodNotAllowedException is used to throw a method not allowed exception
NotAcceptableException
The class NotAcceptableException is used to throw a not acceptable exception
NotFoundException
The class NotFoundException is used to throw a not found exception
NotImplementedException
The class NotImplementedException is used to throw a not implemented exception
PayloadTooLargeException
The class PayloadTooLargeException is used to throw a payload too large exception
PreconditionFailedException
The class PreconditionFailedException is used to throw a precondition failed exception
RequestTimeoutException
The class RequestTimeoutException is used to throw a request timeout exception
RpcException
Exception class for RPC errors.
SerinusException
The class SerinusException is used as superclass for all exceptions defined in Serinus
ServiceUnavailableException
The class ServiceUnavailableException is used to throw a service unavailable exception
TooManyRequestsException
Exception thrown when rate limit is exceeded.
UnauthorizedException
The class UnauthorizedException is used to throw a unauthorized exception
UnprocessableEntityException
The class UnprocessableEntityException is used to throw a unsupported media type exception
UnsupportedMediaTypeException
The class UnsupportedMediaTypeException is used to throw a unsupported media type exception