quds_server library
A core server for creating fast dart servers with support of routers, controllers, middlewares.
Classes
- ApiValidator
- The base class of api validators
- AuthorizationCheckerMiddleware
- A middleware to prevent unauthorized users to connect the server apis.
- BodyGeneratorMiddleware
- CliCommand
- CorsMiddleware
-
A middleware to provide the response with cors headers if
OPTIONS
method recieved. - InjectAuthorizationDetailsMiddleware
- Inject the request context with user auth details if authorized
- IsBoolean
- IsDateTime
- IsDouble
- IsEmail
- IsInteger
-
IsListOfType<
T> -
IsMapOf<
K, V> - IsNegative
- IsNegativeInteger
- IsNonNegative
- IsNonNegativeInteger
- IsNonPositive
- IsNonPositiveInteger
- IsPositive
- IsPositiveInteger
- IsString
- IsUrl
- LoggingMiddleware
- A middleware to print the requested routes
- MatchRegex
- Max
- Min
- QudsController
- Represents the base class of the server controllers.
- QudsMiddleware
- A base class of QudsMiddleware
-
QudsRouter<
T extends QudsController> - A base class of the routers
- QudsRouterHandler
- Define a route with handler
- QudsServer
- Define the server app
- RequestLoggerMiddleware
- Required
- ServerConfigurations
- The server configurations
- TokenPair
- Combine current token with refresh token.
- TokenService
- Class represents the tokens service
- TokenServiceConfigurations
- A class combines token service configurations
- UserWebSocket
- UserWebSocketsManager
- WebSocketHandler
- A class that exposes a handler for upgrading WebSocket requests.
Enums
- RouteMethod
- The desired http method
- ServerStatusCode
- Represents named title of the server status code
- ServerStatusCodeGroup
Extensions
-
BodyMapValidation
on Map<
String, dynamic> - BooleansValidationExtention on ApiValidator
- CommonsValidationExtention on ApiValidator
- DateTimesValidationExtention on ApiValidator
- ListsValidationExtention on ApiValidator
- NumbersValidationExtention on ApiValidator
- RequestExtension on Request
- Provide some methods on request for decoding the recieved body into json map.
- StringsValidationExtention on ApiValidator
Properties
- serverDefaultJsonEncoder ↔ (Object? Function(Object? obj)?)
-
getter/setter pair
Functions
-
generateJwt(
String subject, String issuer, TokenServiceConfigurations configurations, {String? jwtId, required Duration expiryDuration}) → String - Generate a Json Web Token.
-
generateSalt(
[int length = 32]) → String - Generate random salt for hashing passwords.
-
hashPassword(
String password, String salt) → String - Hash a password using the passed salt.
-
responseApi(
{required ServerStatusCode httpStatus, int apiStatus = 0, String? message, Encoding? encoding, dynamic data, Map< String, Object> ? context, Map<String, Object> ? headers, Object? jsonEncodingFunction(Object? obj)?}) → Response -
Get an instance of
Response
with forbidden status -
responseApiBadRequest(
{int apiStatus = HttpStatus.badRequest, String? message, Encoding? encoding, dynamic data, Map< String, Object> ? context, Map<String, Object> ? headers, Object? jsonEncodingFunction(Object? obj)?}) → Response -
Get an instance of
Response
with bad request status -
responseApiForbidden(
{int apiStatus = HttpStatus.forbidden, String? message, Encoding? encoding, dynamic data, Map< String, Object> ? context, Map<String, Object> ? headers, Object? jsonEncodingFunction(Object? obj)?}) → Response -
Get an instance of
Response
with forbidden status -
responseApiInternalServerError(
{int apiStatus = HttpStatus.internalServerError, String? message, Encoding? encoding, dynamic data, Map< String, Object> ? context, Map<String, Object> ? headers, Object? jsonEncodingFunction(Object? obj)?}) → Response -
Get an instance of
Response
with internal server error status -
responseApiNotFound(
{int apiStatus = HttpStatus.notFound, String? message, Encoding? encoding, dynamic data, Map< String, Object> ? context, Map<String, Object> ? headers, Object? jsonEncodingFunction(Object? obj)?}) → Response -
Get an instance of
Response
with not found status -
responseApiOk(
{int apiStatus = 0, String? message, Encoding? encoding, dynamic data, Map< String, Object> ? context, Map<String, Object> ? headers, Object? jsonEncodingFunction(Object? obj)?}) → Response -
Get an instance of
Response
with ok status -
validateRequest(
Map< String, ApiValidator> validationRules, Map<String, dynamic> bodyMap) → Response? -
validate the whole request
bodyMap
if matches the passedvalidationRules
-
verifyJwt(
String token, String secret) → dynamic - Verify if the token is valid and return its related JWT