Additional Features Documentation
Table of Contents
Email Templates
BAASIX supports customizable email templates for various system communications.
Default Template Location
The default email template is located at:
baasix/templates/mails/default.liquidCustom Templates
Custom email templates can be placed in:
extensions/baasix-templates/mails/Template Format
Email templates use the Liquid templating language. Here's an example of the default template structure:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ subject }}</title>
</head>
<body>
<div style="max-width: 600px; margin: 0 auto;">
<header style="text-align: center; padding: 20px;">
<img src="{{ logo_url }}" alt="Logo" style="max-width: 200px;">
</header>
<main>
{{ content }}
</main>
<footer style="text-align: center; padding: 20px; font-size: 12px; color: #888;">
© {{ "now" | date: "%Y" }} Your Company Name. All rights reserved.
</footer>
</div>
</body>
</html>Using Templates
To use a specific template when sending an email, specify the template name in the sendMail options:
await mailService.sendMail({
to: 'user@example.com',
subject: 'Welcome',
templateName: 'welcome',
context: {
name: 'John Doe',
content: '<h1>Welcome to our service!</h1>'
}
});Logo Customization
You can customize the logo used in email templates and potentially other parts of the application.
Default Logo Location
The default logo is located at:
baasix/templates/logo/logo.pngCustom Logo
To use a custom logo, place your logo file at:
extensions/baasix-templates/logo/logo.pngThe system will automatically use the custom logo if it exists, falling back to the default logo otherwise.
Storage Services
BAASIX supports multiple storage services for file handling.
Configuring Storage Services
Storage services are configured through environment variables:
STORAGE_SERVICES_ENABLED=local,s3
STORAGE_DEFAULT_SERVICE=localLocal Storage Configuration
LOCAL_STORAGE_PATH=/path/to/local/storageS3 Storage Configuration
S3_STORAGE_ACCESS_KEY_ID=your_access_key
S3_STORAGE_SECRET_ACCESS_KEY=your_secret_key
S3_STORAGE_REGION=your_region
S3_STORAGE_BUCKET=your_bucket_name
S3_STORAGE_ENDPOINT=your_s3_endpointCache Management
BAASIX includes a caching system to improve performance.
Cache Initialization
The cache is initialized in the server.js file:
await initializeCache({ ttl: process.env.CACHE_TTL * 1000 || 30000 });Cache Configuration
Cache settings can be configured through environment variables:
CACHE_TTL=30000Using the Cache
The cache can be used in various parts of the application to store and retrieve frequently accessed data:
const cache = getCache();
await cache.set('key', value, expiresIn);
const cachedValue = await cache.get('key');TasksService
BAASIX includes a built-in TasksService for managing background tasks efficiently.
Overview
The TasksService manages background tasks from the baasix_Tasks table by:
- Caching "Not started" tasks scheduled within 4 hours to reduce database calls and memory usage
- Coordinating task execution to prevent concurrent processing
- Automatically refreshing cache when tasks change (max refresh interval: 3 hours)
- Providing graceful shutdown with task completion waiting
Quick Start
import tasksService from "../../baasix/services/TasksService";
// Check if a task is running
if (await tasksService.isTaskRunning()) {
return; // Skip if already running
}
// Mark task as running
await tasksService.setTaskRunning(true);
try {
// Get available tasks
const tasks = await tasksService.getNotStartedTasks();
// Process tasks...
} finally {
await tasksService.setTaskRunning(false);
}Environment Configuration
# Cache refresh interval in seconds (default: 600, maximum: 10800 = 3 hours)
TASK_LIST_REFRESH_INTERVAL=600
# Shutdown wait time in seconds (default: 30)
TASK_SHUTDOWN_WAIT_TIME=30Note: Only tasks with scheduled_time within 4 hours are cached to optimize memory usage.
For Complete Documentation
See the dedicated TasksService Documentation for comprehensive usage examples, API reference, and best practices.
These additional features enhance the functionality and customization options of the BAASIX system. Proper utilization of email templates, logo customization, storage services, caching, and task management can significantly improve the user experience and performance of your application.
Related Documentation
- TasksService Documentation - Complete TasksService guide
- File Routes - Working with files and assets
- Baasix Extensions - Create custom extensions
- Socket.IO Integration - Real-time features