Client and REST API
Client
DearDiary.connect — Function
connect(base_url; username, password, token)::ClientBuild a Client pointed at base_url.
Pass username and password to sign in via POST /auth and store the issued token. Pass token instead to attach an already-issued bearer token. Pass neither when the server runs with auth disabled; the client will work without an Authorization header.
Arguments
base_url::AbstractString: Base URL of the server (with or without trailing slash).username::Optional{AbstractString}: Username for sign-in.password::Optional{AbstractString}: Password for sign-in.token::Optional{AbstractString}: Pre-issued bearer token.
Returns
A Client ready to issue authenticated requests.
DearDiary.disconnect — Function
disconnect(client::Client)::NothingClear the local token. The server is stateless so this is purely a client-side reset; any copies of the token issued earlier remain valid until they expire.
DearDiary.refresh_token! — Function
refresh_token!(client::Client)::ClientCall POST /auth/refresh and replace the client's token with the freshly-minted one.
DearDiary.whoami — Function
whoami(client::Client)::UserResponseResolve the user behind the current token via GET /auth/me. Also refreshes the cached client.user.
REST API
DearDiary.APIConfig — Type
APIConfigA struct to hold the configuration for the API server.
Fields
host::String: The host of the API server.port::UInt16: The port of the API server.db_file::String: The path to the DuckDB database file.jwt_secret::String: The JWT secret for authentication.enable_auth::Bool: Whether to enable authentication or not.cors_origins::Vector{String}: Browser origins allowed to call the API. Use["*"]to allow any origin (default in development).artifact_backend::String: WhichAbstractArtifactStorebackend handlesResourcebytes. One of"inline"(default, bytes stored inline in the DB),"filesystem", or"s3". Selected at server startup by theDEARDIARY_ARTIFACT_BACKENDenv var.artifact_fs_root::String: Root directory for theFilesystemStorebackend. Honoured only whenartifact_backend == "filesystem". Created on first write.artifact_s3_bucket::String: Bucket name for theS3Storebackend.artifact_s3_endpoint::String: Scheme + host for S3 requests (e.g.https://s3.us-east-1.amazonaws.com,http://localhost:9000for MinIO).artifact_s3_region::String: Region used in the SigV4 credential scope.artifact_s3_access_key::String,artifact_s3_secret_key::String: SigV4 credentials.enable_ui::Bool: Settrueto makeDearDiary.runboot the embedded Bonito dashboard onui_host:ui_portalongside the REST API server. Defaults totrue.ui_host::String: Host the dashboard binds to. Defaults to127.0.0.1.ui_port::UInt16: Port the dashboard binds to. Defaults to9001.
DearDiary.run — Function
run(; env_file::String=".env")Start the server. Reads configuration from env_file (defaults to .env). The server binds to 127.0.0.1:9000 unless overridden by DEARDIARY_HOST and DEARDIARY_PORT.
DearDiary.stop — Function
stop()Stops the server. Alias for Oxygen.Core.terminate().