RestoDB (Rest over database) is a micro-service that exposes any existing database through REST. Each table or vue will have its own endpoints to be queried in json or csv. You can expose all tables and vues, or select which ones you want to be exposed. It uses aspnet minimal API for routes declarations and can provide authentication, caching, CORS, Swagger and rate limiting.
Thanks to SQLKata, RestoDB natively supports SQL Server, PostgreSQL, Mysql and SQLite.
Open a terminal and run the following command:
docker run --rm --env=DbProvider=<<YOUR_DB_PROVIDER>> --env=DbConnection="<<YOUR_CONNECTION_STRING>>" -p 3000:80 roddone/restodb # replace YOUR_DB_PROVIDER and YOUR_CONNECTION_STRING, see Config section for possible values
RestoDb is now available on your host at http://localhost:3000.
If you need to use array parameters, you must give and index to the environment variable name, exemple with 'LimitTo' parameter:
docker run --rm --env=DbProvider=<<YOUR_DB_PROVIDER>> --env=DbConnection="<<YOUR_CONNECTION_STRING>>" --env=LimitTo:0=Users --env=LimitTo:1=Cities -p 3000:80 roddone/restodb # replace YOUR_DB_PROVIDER and YOUR_CONNECTION_STRING, see 'Config' section for possible values
If you need to use any of the objects parameters (Config, Authentication, Cors, RateLimiting or Csv), you must prefix by the section's name, exemple with 'Csv' section :
docker run --rm --env=DbProvider=<<YOUR_DB_PROVIDER>> --env=DbConnection="<<YOUR_CONNECTION_STRING>>" --env=Csv:Enabled=true --env=Csv:Separator="|" -p 3000:80 roddone/restodb # replace YOUR_DB_PROVIDER and YOUR_CONNECTION_STRING, see 'Config' section for possible values
DbProvider (string, MANDATORY)
: the database provider that will be used. Possible values are 'NpgSql', 'SqlServer', 'MySql' or 'Sqlite'DbConnection (string, MANDATORY)
: the database connection stringLimitTo (string[])
: entities allowed to expose. if null or empty, all entities in the database will be exposedEnableSwagger (boolean)
: indicates if the swagger should be enabled or notApiSegment (string)
: the base path for all routes, default is "api"Authentication (Object)
: see Authentication sectionCache (Object)
: see Cache sectionCors (Object)
: see Cors sectionRateLimiting (Object)
: see Rate limiting sectionCsv (Object)
: see Csv section
Authentication is based on Jwt. You can configure how Jwt token should be interpreted :
Authentication:Enabled (boolean)
: indicates if the Api should use authentication or notAuthentication:RequireHttpsMetadata (bool)
: indicates if HTTPS is required for the metadata address or authority, default : falseAuthentication:ValidateIssuer (boolean)
: indicates if the Api should validate the issuer of the token, default : trueAuthentication:Issuer (string)
: the issuer of the tokenAuthentication:ValidateIssuerSigningKey (boolean)
: indicates if the Signin key should be validated, default: trueAuthentication:Key (string)
: the key to validateAuthentication:ValidateAudiance (boolean)
: indicates if the Api should validate the audience, default : falseAuthentication:Audience (string)
: the audience to validateAuthentication:ValidateLifetime (boolean)
: indicates if the Api should validate the lifetime of the token, default false
RestoDB can use a cache to be more performant and limit the requests to the database, to do so, use the 'Cache' section in configuration :
Cache:Enabled (boolean)
: indicates if the Api should use cache or not, default: falseCache:DurationInSeconds (int)
: indicates the cache duration in seconds, default: 60sCache:Absolute (boolean)
: indicates if the cache should be absolute(true) or sliding(false), default: true
You can enable and configure Cors this way :
Cors:Enabled (boolean)
: indicates if the Api should use Cors or not, default: falseCors:AllowedOrigins (string[])
: the allowed originsCors:AllowedMethods (string[])
: the allowed methodsCors:AllowedHeaders (string[])
: the allowed headers
You can enable and configure rate limiting this way :
RateLimiter:Enabled (boolean)
: indicates if the Api should enable rate limiter, default: falseRateLimiter:PermitLimit (int)
: the number of requests allowed during the specified window, default: 100RateLimiter:WindowInSeconds (int)
: the window in seconds, default: 60RateLimiter:QueueLimit (int)
: the number of requests to be queued if the limit is reached, default: 0
You can natively export get data in csv format by adding "/csv" to any route.
Csv:Enabled (boolean)
: indicates if the Api should enable Csv routes, default: trueCsv:Separator (string)
: the separator used in Csv results, default: "," (comma)