DataBank API
Central data storage system that decouples data producers from consumers.
import { start } from 'lucidlines';
const { databank } = start({
commands: [
{ name: 'web', command: 'npm run dev' }
]
});
// see databank methods belowWARNING
DataBank is automatically created and managed by LucidLines regardless of configuration. The API documented here is for advanced use cases where you need direct access to log data programmatically. Most users won't need to interact with DataBank directly.
Note: In the example above, serverPort is not set, meaning the web interface isn't running. While DataBank still collects and stores all command output, nothing is consuming or displaying it. Add serverPort to enable the web dashboard, or use databank.subscribe() to process logs programmatically. We invite those who are adventurous to create their own interface.
addData(type, data)
Adds data to the DataBank storage. This is done internally by the node-stream.ts library. Users typically don't use this.
Parameters
type(string) - Data type/categorydata(string) - The data content to store
Example
/* with:
commands: [
{ name: 'web', command: 'npm run dev' }
]
*/
databank.addData('web', 'log message');getRecentMessages(limit?)
Gets recent messages for newly connected clients.
Parameters
limit(number, optional) - Maximum number of messages to return (default: 1000)
Returns
LogEntry[]- Array of recent log entries
Example
const recent = databank.getRecentMessages(50);getMessageByType(type, lastTimestamp?, limit?)
Gets messages for a specific type.
Parameters
type(string) - Data type to filter bylastTimestamp(number, optional) - Get messages before this timestamplimit(number, optional) - Maximum number of messages to return (default: 20)
Returns
LogEntry[]- Array of log entries for the specified type
Example
/* with:
commands: [
{ name: 'web', command: 'npm run dev' }
]
*/
const appLogs = databank.getMessageByType('web', undefined, 100);getAllMessages()
Gets all stored messages (use with caution for large datasets).
Returns
LogEntry[]- Array of all log entries
Example
const allMessages = databank.getAllMessages();getTotalMessageCount()
Gets the total count of all stored messages.
Returns
number- Total message count
Example
const total = databank.getTotalMessageCount();getMessageCountByType(type)
Gets the count of messages for a specific type.
Parameters
type(string) - Data type to count
Returns
number- Message count for the specified type
Example
/* with:
commands: [
{ name: 'web', command: 'npm run dev' }
]
*/
const appCount = databank.getMessageCountByType('web');getAvailableTypes()
Gets all unique data types stored.
Returns
string[]- Array of available data types
Example
const types = databank.getAvailableTypes();subscribe(callback)
Subscribes to real-time data updates.
Parameters
callback(function) - Function called when new data arrives
Returns
function- Unsubscribe function
Example
const unsubscribe = databank.subscribe((entry: LogEntry) => {
console.log(`${entry.type}: ${entry.data}`);
});
// Later...
unsubscribe();cleanup()
Cleans up DataBank resources (should be called on shutdown).
Example
databank.cleanup();Types
LogEntry
interface LogEntry {
type: string; // Process name (e.g., "web-server")
data: string; // Output line
timestamp: number; // Unix timestamp
}