Skip to main content

Configuration

Learn how to configure Lighthouse for your development environment.

Configuration File

Create lighthouse.config.ts in your project root:

import { defineLighthouseConfig } from '@serverless-monolith/lighthouse';

export default defineLighthouseConfig({
// Proxy configuration
proxy: {
port: 5454,
cors: true,
logRequests: true,
defaultTimeout: 30000,
},

// Path to Bruno collections
brunoPath: './bruno',

// Core groups (services)
coreGroups: [...],

// Managed processes
processes: [...],

// UI options
ui: {
defaultLayout: 'split',
},
});

Configuration Options

Proxy Configuration

OptionTypeDefaultDescription
portnumber5454Proxy server port
corsbooleantrueEnable CORS
logRequestsbooleantrueLog requests
defaultTimeoutnumber30000Request timeout (ms)

Core Groups

Define your backend services:

coreGroups: [
{
coreName: 'user-service',
baseUrl: 'http://localhost:4005',
routes: [
{
name: 'users',
pathPrefix: '/api/http/user/',
timeout: 30000,
},
{
name: 'global',
routeByPath: {
'v2/users': {
pathPrefix: '/api/http/users/',
preserveMatchedPath: true,
},
'': {
pathPrefix: '/api/http/global/',
},
},
},
],
},
]

Process Configuration

Define managed processes:

processes: [
{
id: 'api-server',
name: 'API Server',
description: 'Main API service',
command: 'pnpm',
args: ['dev'],
cwd: '/path/to/service',
mode: 'auto',
autoStart: false,
env: {
NODE_ENV: 'development',
},
healthCheck: { // Required
url: 'http://localhost:4005/health',
interval: 5000,
timeout: 3000,
},
},
]

Process Options

OptionTypeRequiredDescription
idstringUnique identifier
namestringDisplay name
descriptionstringProcess description
commandstringCommand to run
argsstring[]Command arguments
cwdstringWorking directory
modestringmanaged, external, or auto
healthCheckobjectHealth check config (required)
autoStartbooleanStart on launch
envobjectEnvironment variables

Process Modes

ModeDescription
managedLighthouse starts and manages the process
externalProcess runs outside Lighthouse (just monitors)
autoAuto-detect: managed if not running, external if already running

Health Check Configuration

The healthCheck field is required for all processes:

healthCheck: {
url: 'http://localhost:4005/health', // Required
interval: 5000, // Required - Check every 5 seconds (ms)
timeout: 3000, // Optional - Timeout after 3 seconds (default: 5000)
}
OptionTypeRequiredDefaultDescription
urlstring-URL to check health
intervalnumber-Check interval in ms
timeoutnumber5000Timeout per check in ms

UI Options

ui: {
defaultLayout: 'split', // 'split' or 'fullscreen'
}

Route Configuration

Simple Route

{
name: 'users',
pathPrefix: '/api/http/user/',
timeout: 30000,
}

Route By Path

For complex routing:

{
name: 'global',
routeByPath: {
'v2/users': {
pathPrefix: '/api/http/users/',
preserveMatchedPath: true,
},
'admin': {
pathPrefix: '/api/http/admin/',
fallbackUrls: ['http://localhost:4006/api/http/admin/'],
},
'': {
pathPrefix: '/api/http/global/',
},
},
timeout: 30000,
}

Route Target Options

OptionTypeDescription
pathPrefixstringPath prefix for backend
preserveMatchedPathbooleanKeep matched path in request
fallbackUrlsstring[]Fallback URLs on 404
transformPathfunctionTransform path before forwarding

Environment Variables

Override configuration with environment variables:

LIGHTHOUSE_PORT=5454
LIGHTHOUSE_CORS=true
LIGHTHOUSE_LOG_REQUESTS=true

Multiple Environments

const isDev = process.env.NODE_ENV !== 'production';

export default defineLighthouseConfig({
proxy: {
port: 5454,
logRequests: isDev,
},
brunoPath: './bruno',
coreGroups: [...],
processes: isDev ? devProcesses : [],
});

Complete Example

import { defineLighthouseConfig } from '@serverless-monolith/lighthouse';

export default defineLighthouseConfig({
proxy: {
port: 5454,
cors: true,
logRequests: true,
},
brunoPath: './bruno',
coreGroups: [
{
coreName: 'api-service',
baseUrl: 'http://localhost:4005',
routes: [
{ name: 'users', pathPrefix: '/api/http/user/' },
{ name: 'orders', pathPrefix: '/api/http/order/' },
],
},
],
processes: [
{
id: 'api',
name: 'API Server',
command: 'pnpm',
args: ['dev'],
cwd: './api',
mode: 'auto',
healthCheck: {
url: 'http://localhost:4005/health',
interval: 5000,
},
},
],
ui: {
defaultLayout: 'split',
},
});

Next Steps