lucifer library Null safety

Classes

AnsiColor
This class handles colorizing of terminal output.
App
Lucifer Core App
ConsoleOutput
Default implementation of LogOutput.
Controller
Base Controller to be used in Lucifer application
DevelopmentFilter
Prints all logs with level >= Logger.level while in development mode (eg when asserts are evaluated, Flutter calls this debug mode).
HybridPrinter
A decorator for a LogPrinter that allows for the composition of different printers to handle different log messages. Provide it's constructor with a base printer, but include named parameters for any levels that have a different printer:
Jwt
JSON Web Token Handler
Log
Log object to be used as interface between logging middleware and Req Res
LogEvent
LogFilter
An abstract filter of log messages.
LogfmtPrinter
Outputs a logfmt message:
Logger
Use instances of logger to send log messages to the LogPrinter.
LogOutput
Log output receives a OutputEvent from LogPrinter and sends it to the desired destination.
LogPrinter
An abstract handler of log events.
MemoryOutput
Buffers OutputEvents.
Model
Base Model to be used in Lucifer application
MultiOutput
Logs simultaneously to multiple LogOutput outputs.
OutputEvent
PrefixPrinter
A decorator for a LogPrinter that allows for the prepending of every line in the log output with a string for the level of that log. For example:
PrettyPrinter
Default implementation of LogPrinter.
ProductionFilter
Prints all logs with level >= Logger.level even in production.
Repository
Req
Req request object to handle incoming request.
RequestBody
Res
Response object to handle response to the client.
Route
Router
SimplePrinter
Outputs simple log messages:
SocketServer
StatusCode
Status Codes
StreamOutput
UploadedFile
Uploaded File Data

Extensions

FileExtension
HttpRequestExtension
StringExtension
WebSocketExtension

Functions

contentSecurityPolicy() Callback
Content Security Policy (CSP) helps prevent unwanted content from being injected/loaded into your webpages.
cors({dynamic origin = '*', String methods = 'GET,HEAD,PUT,PATCH,POST,DELETE', String allowedHeaders = '*', String? exposedHeaders, bool? credentials, int? maxAge, bool? preflightContinue, int? optionsSuccessStatus}) Callback
Middleware to handle CORS.
crossDomain({String permitted = 'none'}) Callback
The X-Permitted-Cross-Domain-Policies header tells some web clients (like Adobe Flash or Adobe Acrobat) your domain's policy for loading cross-domain content.
crossOriginEmbedderPolicy() Callback
This middleware sets the Cross-Origin-Embedder-Policy header.
crossOriginOpenerPolicy({String policy = 'same-origin'}) Callback
This middleware sets the Cross-Origin-Opener-Policy header.
crossOriginResourcePolicy({String policy = 'same-origin'}) Callback
This middleware sets the Cross-Origin-Resource-Policy header.
dnsPrefetchControl({bool allow = false}) Callback
This middleware lets you set the X-DNS-Prefetch-Control to control browsers' DNS prefetching.
env(String key) → dynamic
get environment variable value based on key
expectCT({int maxAge = 0, bool enforce = false, String? reportUri}) Callback
The Expect-CT HTTP header tells browsers to expect Certificate Transparency.
getStatusMessage(int statusCode) String
hidePoweredBy() Callback
Simple middleware to remove the X-Powered-By HTTP header if it's set.
json() Callback
Middleware to parse json request body.
logger({Level level = Level.verbose, LogPrinter? printer}) Callback
Middleware to handle logging with package logger https://pub.dev/packages/logger
multipart() Callback
Middleware to parse multipart request body.
mustache([String? views]) Callback
Middleware to handle templating with Mustache.
noSniffMimetype() Callback
Some browsers will try to "sniff" mimetypes. For example, if my server serves file.txt with a text/plain content-type, some browsers can still run that file with .
originAgentCluster() Callback
Origin-Agent-Cluster is a new HTTP response header that instructs the browser to prevent synchronous scripting access between same-site cross-origin pages.
parseBody(HttpRequest request) Future<RequestBody>
parse raw body of a HttpRequest into RequestBody data
parseJson(String body) Map<String, dynamic>
Parse json request body into map
parseMultipart(Req req, {void onFieldListener(String name, Object field)?, void onFileListener(String name, UploadedFile file)?, void onErrorListener(dynamic error)?, void onEndListener()?}) Future
Parse multipart request into map body and uploaded files
parseUrlEncoded(String body) Map<String, dynamic>
Parse urlencoded request body into map
parseValue(String value) → dynamic
Parse string value into its appropriate type
rateLimiter() Callback
Middleware to handle rate limiting.
raw() Callback
Middleware to fill request body with its raw bytes
referrerPolicy({dynamic policy = 'no-referrer'}) Callback
The Referer HTTP header is typically set by web browsers to tell the server where it's coming from.
secureCookie(String secret) Callback
Middleware to use secure cookies
security() Callback
Middleware to handle all security.
session({required String secret}) Callback
Middleware to manage sessions.
static(String directory) Callback
Middleware to handle static content.
strictTransportSecurity({int maxAge = 180 * 24 * 60 * 60, bool includeSubdomains = true, bool preload = false}) Callback
This middleware adds the Strict-Transport-Security header to the response. This tells browsers, "hey, only use HTTPS for the next period of time".
text() Callback
Middleware to get request body as string.
urlencoded() Callback
Middleware to parse urlencoded request body.
xDownloadOptions() Callback
This middleware sets the X-Download-Options header to noopen to prevent Internet Explorer users from executing downloads in your site's context.
xFrameOptions({String action = 'SAMEORIGIN'}) Callback
The X-Frame-Options HTTP header restricts who can put your site in a frame which can help mitigate things like clickjacking attacks.
xssClean() Callback
Middleware to handle xss filtering.
xXssProtection() Callback
X-XSS-Protection is a feature of Internet Explorer and Chrome that stops pages from loading when they detect reflected cross-site scripting (XSS) attacks.

Enums

Level
Levels to control logging output. Logging can be enabled to include all levels above certain Level.
Method
HTTP Methods supported by Lucifer

Typedefs

Callback = FutureOr Function(Req req, Res res)
Type definition for both Middleware and Route Handler
LogCallback = void Function(LogEvent event)
@Deprecated('Use a custom LogFilter instead')
OutputCallback = void Function(OutputEvent event)
@Deprecated('Use a custom LogOutput instead')
SocketCloseCallback = FutureOr Function(WebSocket socket)
SocketErrorCallback = FutureOr Function(WebSocket socket, dynamic error)
SocketMessageCallback = FutureOr Function(WebSocket socket, dynamic data)
SocketOpenCallback = FutureOr Function(WebSocket socket)

Exceptions / Errors

BadRequestException
Bad Request Exception.
ConflictException
Conflict Exception.
ForbiddenException
Payment Required Exception.
HttpServerException
Http Server Exception
InternalErrorException
Internal Server Error Exception
JWTError
JWTError objects thrown in the case of a jwt sign or verify failure.
JWTExpiredError
An error thrown when jwt is expired
JWTInvalidError
An error thrown when jwt is invalid
JWTNotActiveError
An error thrown when jwt is not active
JWTParseError
An error thrown when parsing failed
JWTUndefinedError
An error thrown by default
MethodNotAllowedException
Method Not Allowed Exception.
NotFoundException
Not Found Exception.
NotImplementedException
Not Implemented Exception
PaymentRequiredException
Payment Required Exception.
RequestTimeoutException
Request Timeout Exception.
ServiceUnavailableException
Service Unavailable Exception
UnauthorizedException
Unauthorized Exception.
UnprocessableException
Unprocessable Entity Exception.