Back to Lowdefy

Servers Overview

code-docs/servers/overview.md

5.2.04.4 KB
Original Source

Servers Overview

Next.js-based servers for running Lowdefy applications.

Package Summary

PackagePurposeUse Case
@lowdefy/serverProduction serverDeployment
@lowdefy/server-devDevelopment serverLocal development
@lowdefy/server-e2eE2E testing serverPlaywright testing with auth

Architecture

All three servers are built on Next.js 13.5.4 and share:

  • Core API handlers for requests and endpoints
  • Plugin loading from build artifacts
  • Page rendering with server-side props

The production and dev servers use NextAuth for authentication. The e2e server replaces NextAuth with cookie-based session injection for Playwright testing.

Key Differences

AspectProductionDevelopmentE2E
Startupnext startProcess managernext start
BuildPre-built artifactsDynamic rebuildingPre-built artifacts
WatchingNone3 concurrent watchersNone
ReloadN/ASSE-based hot reloadN/A
AuthNextAuthNextAuth + mock userCookie-based
OptimizationFullDisabledFull

Build Artifacts

Both servers load from ./build/ directory:

build/
├── config.json           # Main configuration
├── auth.json             # Auth configuration
├── reload                # Trigger file (dev only)
├── pages/                # Page configurations
├── connections/          # Connection configs
├── plugins/
│   ├── blocks.js         # Block components
│   ├── actions.js        # Action handlers
│   ├── connections.js    # Connection types
│   ├── icons.js          # Icon components
│   ├── styles.less       # Custom styles
│   └── operators/
│       ├── client.js     # Client operators
│       ├── server.js     # Server operators
│       ├── clientJsMap.js
│       └── serverJsMap.js
└── auth/
    ├── adapters.js
    ├── callbacks.js
    ├── events.js
    └── providers.js

API Routes

Shared Routes

RoutePurpose
/api/request/[pageId]/[requestId]Execute requests
/api/endpoints/[endpointId]Execute API endpoints
/api/auth/[...nextauth]NextAuth handlers (production/dev only)
/api/auth/sessionSession retrieval (e2e: returns cookie user)
/api/usageUsage logging

Dev-Only Routes

RoutePurpose
/api/reloadSSE for hot reload
/api/pingHealth check
/api/page/[pageId]Page config fetch
/api/rootRoot config fetch

Page Routes

RoutePurpose
/Homepage (redirects to home page)
/[pageId]Dynamic page rendering
/404Not found page

Context Object

API handlers receive a context with:

javascript
{
  rid: 'request-uuid',
  buildDirectory: './build',
  config,           // From build/config.json
  connections,      // Available connections
  fileCache,        // Cached files
  headers,          // Request headers
  jsMap,            // JS operator map
  logger,           // Pino logger
  operators,        // Available operators
  req, res,         // Express-like objects
  secrets,          // Environment secrets
  session,          // NextAuth session
  authOptions       // NextAuth config
}

See Also