Overview
TheLoopar class is the core of the Loopar Framework. It extends the Document class and provides essential functionality for application management, database operations, authentication, server initialization, and multi-tenancy support.
Installation
The Loopar instance is exported as a singleton and can be imported directly:Constructor
- Date utilities (
dateUtils) - Server instance
- Database ORM connection
- Unique tenant ID
Initialization
init(options)
Initializes the Loopar instance with tenant-specific configuration.Configuration object for initialization
Unique identifier for the tenant
Base path for applications
initialize()
Internal method that:- Builds the global environment
- Loads configuration
- Initializes the database
- Builds the application
- Builds icons
- Initializes Tailwind CSS
Properties
Core Properties
Root path of the application (defaults to
process.cwd())Current tenant identifier
File system path to tenant-specific data
Path to Loopar core package
Base path for installed applications
Database ORM instance
HTTP server instance
Authentication manager
Collection of utility functions from
HelpersDate manipulation utilities
Markdown rendering function
Getters
Returns the authentication token name (format:
loopar-{hash(tenantId)})Returns the JWT secret for token signing (SHA1 hash of tenant ID)
Cookie management instance from request context
Session management instance from request context
Decoded JWT token data for the currently authenticated user
Object containing all installed applications configuration
Returns true if an app installation is in progress
Document Management
getDocument(document, name, data, options)
Retrieves a document instance by document type and name.Document type name (e.g., ‘User’, ‘Entity’)
Document identifier/name
Optional data to merge with document
Behavior when document not found: ‘throw’ or ‘null’
Whether to parse markdown fields
newDocument(document, data)
Creates a new document instance (not yet saved to database).Document type name
Initial document data
deleteDocument(document, name, options)
Deletes a document from the database.Document type name
Document identifier
Soft delete (mark as deleted) vs hard delete
Force delete even if document has connections
Create history entry for deletion
getList(document, options)
Retrieves a paginated list of documents.Document type name
Fields to retrieve (defaults to list view fields)
Filter conditions
Search query object
Return only rows without metadata
User & Authentication
getUser(userId)
Retrieves user data for authentication.User name or email
disabledUser(userId)
Checks if a user is disabled.User name or email
App Management
setApp(app)
Registers or updates an installed application.Application configuration object
unsetApp(appName)
Unregisters an installed application.Application name to remove
Database Configuration
getDbConfig()
Retrieves the current database configuration.setDbConfig(config)
Updates the database configuration.Database configuration object
Settings
systemsSettings()
Retrieves system settings document.getSettings()
Retrieves cached system settings.Git Operations
git(appName)
Returns a SimpleGit instance for app repository operations.Application name (optional)
gitRepositoryIsValid(repository)
Validates git repository URL format.Git repository URL
validateGitRepository(appName, repository)
Validates and throws error if repository is invalid.Utility Methods
hash(value)
Generates SHA1 hash of a value.Value to hash
throw(error, redirect)
Throws a formatted error with optional redirect.Error message or object with code and message
Optional redirect URL
Example Usage
Additional Exports
SystemController
Extended controller for system-level operations. Inherits fromBaseController with additional methods for system management tasks.
packages/loopar/apps/core/modules/system/controllers/system/system-controller.js.
CoreInstaller
Internal class used for the framework installation wizard. Handles initial setup, database configuration, and site creation during first-time installation.Related
- BaseDocument - Document class methods
- BaseController - Controller class for routing
- File Manager - File operations