|
| | ~MantisBase () |
| | MantisBase (const MantisBase &)=delete |
| MantisBase & | operator= (const MantisBase &)=delete |
| | MantisBase (MantisBase &&)=delete |
| MantisBase & | operator= (MantisBase &&)=delete |
| int | run () |
| | Start the http server and start listening for requests.
|
| void | close () |
| | Close the application and reset object instances that are dependent on the class.
|
| int | quit (const int &exitCode=0, const std::string &reason="Something went wrong!") |
| | Quit the running application immediately.
|
| int | port () const |
| | Retrieve HTTP Listening port.
|
| void | setPort (const int &port) |
| | Set a new port value for HTTP server.
|
| int | poolSize () const |
| | Retrieve the database pool size value.
|
| void | setPoolSize (const int &pool_size) |
| std::string | host () const |
| | Retrieve HTTP Server host address. For instance, a host of 127.0.0.1, 0.0.0.0, etc.
|
| void | setHost (const std::string &host) |
| | Update HTTP Server host address.
|
| std::string | publicDir () const |
| | Retrieve the public static file directory.
|
| void | setPublicDir (const std::string &dir) |
| | Update HTTP server static file directory.
|
| std::string | dataDir () const |
| | Retrieves the data directory where SQLite db and files are stored.
|
| void | setDataDir (const std::string &dir) |
| | Update the data directory for MantisApp.
|
| std::string | scriptsDir () const |
| | Retrieves the scripts directory where JavaScript files are stored used for extending functionality in Mantis.
|
| void | setScriptsDir (const std::string &dir) |
| | Update the scripts directory for MantisApp.
|
| std::string | templatesDir () const |
| | Retrieves the templates directory where email template files are stored used for sending confirmation/password reset emails.
|
| void | setTemplatesDir (const std::string &dir) |
| | Update the templates directory for MantisBase.
|
| std::string | migrationsDir () const |
| | Retrieves the migrations directory path.
|
| void | setMigrationsDir (const std::string &dir) |
| | Update the migrations directory path.
|
| bool | skipAdminSetup () const |
| void | setSkipAdminSetup (bool skip) |
| std::string | dbType () const |
| | Retrieves the active database type.
|
| void | setDbType (const std::string &dbType) |
| | Update the active database type for Mantis.
|
| std::string | jwtSecretKey () const |
| | Retrieve the JWT secret key.
|
| std::string | snowflakeId () const |
| MbDatabase & | db () const |
| | Get the database unit object.
|
| argparse::ArgumentParser & | cmd () const |
| MbRouter & | router () const |
| MbKVStore & | settings () const |
| MbLogger & | logs () const |
| MbRealtimeDB & | rt () const |
| MbFilesMgr & | files () const |
| MbLogger & | logger () const |
| MbAuth & | auth () const |
| MbMailer & | mailer () const |
| MbEntity | entity (const std::string &entity_name) const |
| | Fetch a table schema encapsulated by an MbEntity object from given the table name. If table does not exist yet, return an emty object.
|
| bool | hasEntity (const std::string &entity_name) const |
| | Check if table schema encapsulated by an MbEntity object from given the table name exists. If table does not exist yet, return false.
|
| void | openBrowserOnStart () const |
| | Get the duktape context.
|
| std::chrono::time_point< std::chrono::steady_clock > | startTime () const |
| | Get the server start time in std::chrono::
|
| bool | isDevMode () const |
| bool | isScriptingDisabled () const |
MantisBase entry point.
This class handles the entrypoint to the Mantis world, where we can set/get application flags and variables, as well as access other application units. These units are:
- DatabaseMgr: For all database handling,
- See also
- DatabaseMgr for more information.
- HttpMgr: Low-level http server operation and routing.
- See also
- HttpMgr for low-level access or
-
RouterMgr for a high level routing methods.
- LogsMgr: For logging capabilities,
- See also
- LoggingMgr for more details.
- RouterMgr: High level routing wrapper on top of
- See also
- HttpMgr,
-
RouterMgr for more details.
- ValidatorMgr: A validation store using regex,
- See also
- Validator for more details.
- Note
- create() returns a std::unique_ptr<MantisBase> that you own. Pass a const MantisBase& (or capture it in lambdas) to reach services such as auth(), entity(), and db(). Types that participate in request handling (MbRequest, MbEntity, MbRouter, MbApiKeyMgr, etc.) inherit MbAppMixin and expose mbApp() for the same access. There is no global instance() accessor.
| std::unique_ptr< MantisBase > mb::MantisBase::create |
( |
const json & | config = json::object() | ) |
|
|
static |
Convenience function to allow creating class instance given the values needed to set up the app without any need for passing in cmd args.
The expected values are: { "db": "<db type>", "db_url": "<connection string>", "data-dir": "<path to dir>", "public-dir": "<path to dir>", "scripts-dir": "<path to dir>", "migrations-dir": "<path to dir>", "dev": true, "serve": { "port": <int value>, "host": "<host IP/addr>", "pool-size": <int value>, "skip-admin-setup": <boolean true/false> }, "admins": { "add": ["<email>", "<password>"], "ls": true, "rm": "<email or id>" }, "migrations": { "up": true, "down": false }, "schema": { "ls": true, "rm": "<entity>", "add": "<json>", "update": { "entity": "<name>", "body": "<json>" } } }
- Note
- All primary options above are optional, you can omit to use default values.
-
admins subcommand expects a subcommand with either the add or rm.
-
serve command can have an empty json object and the app will configure with defaults.
return app->run();
cfg["db"] = "postgresql";
cfg["db_url"] = "dbname=mantis user=postgres password=12342532";
cfg["dev"] = true;
cfg["serve"] = json::object();
auto token = app->auth().createToken({{"id", "u1"}, {"table", "users"}});
return app->run();
static std::unique_ptr< MantisBase > create(int argc, char **argv)
Create class instance given cmd args passed in.
Definition mantisbase.cpp:75
nlohmann::json json
Shorten JSON namespace.
Definition api_keys.h:36
- Parameters
-
| config | JSON Object bearing the cmd args values to be used |
- Returns
- Owned application instance