by Yusra H.

CapRover is an easy-to-use app and database deployment platform supporting Node.js, Python, PHP, Ruby, Go, and more, with built-in SSL, load balancing, and Docker Swarm clustering.
This block is the full server-side source of CapRover: a Docker Swarm-backed PaaS that manages app deployment, SSL termination, nginx load balancing, and a REST API. The typical buyer is a developer who wants to self-host an app deployment platform or embed CapRover's backend logic into an existing Node.js/Express server.
api/ - API status codes, base response shape, and typed error classdatastore/ - Persistence layer for apps, registries, projects, and pro featuresdocker/ - Dockerode wrappers (DockerApi, DockerUtils) for Swarm/container operationshandlers/ - Business-logic handlers for app data, app definitions, and projectsinjection/ - Express middleware for dependency injection (Injector, InjectionExtractor)models/ - TypeScript interfaces and types for every domain objectroutes/ - Express routers for auth, user actions, apps, webhooks, one-click apps, and downloadsscripts/ - Utility/bootstrap scriptsuser/ - Captain system manager and user-level service orchestrationutils/ - Constants, logger, environment variables, and misc utilitiesapp.ts - Express application factory and proxy setup; exports the configured appserver.ts - HTTP server entry point; calls initializeCaptainWithDelay and listens on port 3000npm install axios bcryptjs body-parser configstore cookie-parser cron debug \
dockerode ejs express fs-extra http-proxy is-valid-path js-base64 \
jsonwebtoken moment morgan multer on-finished prettier public-ip \
recursive-readdir request require-from-string serve-favicon
npm install --save-dev @types/node @types/express @types/bcryptjs \
@types/dockerode @types/jsonwebtoken @types/morgan @types/multer \
@types/cookie-parser @types/body-parser @types/serve-favicon \
@types/fs-extra typescript ts-node
No native modules or pod installs are required. Docker must be available on the host for runtime Swarm operations.
source/ into src/ at the root of your project.tsconfig.json:
Spin up an isolated sandbox and run it server-side — no local setup.
Tetrees AI Review of this version
This TypeScript cli / script completed archive review. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Pipeline avcp-2026-08-04.1 · SHA-256 8063618baeeda395…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Reviewed Aug 4, 2026
Push this product straight into your AI IDE, web builder or cloud IDE.
Connect Tetrees to a compatible AI IDE, list products you own, and request the verified ZIP without exposing seller upload controls.
No reviews yet.
Sign in to join the discussion
Loading discussion…
{
"compilerOptions": {
"target": "ES2019",
"module": "commonjs",
"rootDir": "src",
"outDir": "dist",
"esModuleInterop": true,
"resolveJsonModule": true,
"strict": false
},
"include": ["src/**/*"]
}
views/ and public/ directories exist at the project root (CapRover uses EJS templates and serves favicon.ico).export IS_CAPTAIN_INSTANCE=1
export CAPTAIN_ROOT_DOMAIN=captain.yourdomain.com
export CAPTAIN_DOCKER_SOCKET=/var/run/docker.sock
export CAPTAIN_PORT=3000
npx tsc
node dist/server.js
# or in development:
npx ts-node src/server.ts
CaptainConstants.serviceContainerPort3000 (default 3000).app.ts)import app, { initializeCaptainWithDelay } from './app'
app is the fully configured Express application with all middleware, routers, and proxy logic applied. Use it directly with http.createServer(app) or pass it to a test harness. initializeCaptainWithDelay bootstraps the CaptainManager asynchronously; call it once before the server starts accepting traffic.
export function initializeCaptainWithDelay(): void
Triggers the Captain system initialization (Docker Swarm setup, Let's Encrypt, nginx config) after a short delay. Called once in server.ts. Do not call it more than once per process; it is not idempotent.
api/ApiStatusCodes.ts)import ApiStatusCodes from './api/ApiStatusCodes'
// Usage:
ApiStatusCodes.STATUS_OK // 100
ApiStatusCodes.AUTHENTICATION_FAILED // 1100
ApiStatusCodes.SERVER_ERROR // ...
A static map of numeric status codes used in every API response. Reference these codes when constructing BaseApi responses or writing custom route handlers that must conform to CapRover's response contract.
api/BaseApi.ts)import BaseApi from './api/BaseApi'
// BaseApi wraps response payload with status, description, and data fields
The standard response envelope used by all routes. Instantiate it with a status code and description, then attach data before sending. Ensures all API responses are consistent and parseable by the CapRover frontend.
You want to mount CapRover's Express app as a sub-application or run it alongside another service.
import * as http from 'http'
import app, { initializeCaptainWithDelay } from './src/app'
// Initialize Captain services before accepting connections
initializeCaptainWithDelay()
const server = http.createServer(app)
server.listen(3000, () => {
console.log('CapRover backend running on port 3000')
})
server.on('error', (err: NodeJS.ErrnoException) => {
console.error('Server error:', err)
process.exit(1)
})
You need to add a custom endpoint that returns data in the same format as existing CapRover routes.
import { Router, Request, Response } from 'express'
import ApiStatusCodes from './src/api/ApiStatusCodes'
import BaseApi from './src/api/BaseApi'
const router = Router()
router.get('/health', (req: Request, res: Response) => {
const response = new BaseApi(ApiStatusCodes.STATUS_OK, 'System healthy')
response.data = { uptime: process.uptime() }
res.json(response)
})
export default router
You want to query the local Docker daemon using CapRover's existing abstraction.
import DockerApi from './src/docker/DockerApi'
async function listServices() {
const dockerApi = DockerApi.get()
const services = await dockerApi.getServices()
for (const svc of services) {
console.log('Service:', svc.Spec?.Name)
}
}
listServices().catch(console.error)
app.ts - Creates and configures the Express app: registers middleware (morgan, body-parser, cookie-parser), mounts all routers, sets up the HTTP proxy for NetData, and exports initializeCaptainWithDelay.server.ts - Entry point: checks for installer mode, calls initializeCaptainWithDelay, creates the HTTP server, and binds to the configured port.api/ApiStatusCodes.ts - Numeric status code constants for every API outcome.api/BaseApi.ts - Response envelope class wrapping status, description, and payload.api/CaptainError.ts - Typed error class used throughout the codebase for structured error propagation.datastore/ - Nedb/configstore-backed persistence: apps, registries, projects, and pro feature configs.docker/DockerApi.ts - Singleton Dockerode wrapper for all Swarm, service, and container operations.docker/DockerUtils.ts - Pure utility functions for Docker name validation and tag parsing.handlers/ - Stateless handlers that implement business logic; called by routers.injection/Injector.ts - Express middleware that attaches CaptainManager, DataStore, and DockerApi instances to res.locals.injection/InjectionExtractor.ts - Typed accessors to pull injected dependencies from res.locals without casting.models/ - TypeScript interface definitions for app definitions, registry info, JWT payloads, and all domain types.routes/ - Express routers organized by feature: login, user app management, webhooks, one-click apps, pro features, and static downloads.user/ - CaptainManager and related services that own the lifecycle of Docker Swarm, nginx, and Let's Encrypt.utils/ - Logger, CaptainConstants, EnvVars, CaptainInstaller, and generic utility helpers.scripts/ - Standalone scripts for bootstrapping or maintenance tasks.IS_CAPTAIN_INSTANCE not set: Without this env var, server.ts runs the installer path and exits immediately. Fix: always export IS_CAPTAIN_INSTANCE=1 for normal server operation.DockerApi connects to /var/run/docker.sock by default; the process must run as root or in the docker group. Fix: chmod 666 /var/run/docker.sock or add your user to the docker group.views/ or public/ directory: EJS setup and serve-favicon will throw at startup if these directories don't exist. Fix: create views/ and public/ at the project root and place a favicon.ico in public/.esModuleInterop not enabled: Several imports use import x = require(...) syntax. Fix: set "esModuleInterop": true and "allowSyntheticDefaultImports": true in tsconfig.json.serviceContainerPort3000 unconditionally. Fix: override via CaptainConstants or ensure the port is free before starting.configstore permissions error in non-home environments: Configstore writes to ~/.config. Fix: set XDG_CONFIG_HOME to a writable path or run with a user that has a valid home directory.I have purchased the CapRover backend source block. The source files are in `source/`
and the integration guide is in `USAGE.md`. The upstream npm package is `user@example.com`.
Please integrate this source into my existing Node.js/TypeScript/Express project step by step:
1. Read USAGE.md fully before writing any code.
2. Copy source/ into src/ of my project.
3. Merge the required dependencies from USAGE.md into my package.json and run npm install.
4. Update my tsconfig.json as described in USAGE.md.
5. Create or confirm the views/ and public/ directories exist.
6. Wire initializeCaptainWithDelay and the app export into my existing server entry point.
7. Add any missing environment variables to my .env file.
8. Show me the final server entry point and confirm the app compiles with `npx tsc --noEmit`.
9. If there are conflicts with my existing routes, show me how to mount CapRover's routers
under a sub-path (e.g., /caprover).
Only use symbols and imports that appear in source/ and USAGE.md. Do not invent APIs.
CapRover is open source; see source/LICENSE if present, or the upstream repository at https://github.com/caprover/caprover. The upstream package on npm is caprover. Review the license before redistributing or embedding in a commercial product.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
The full install guide and integration prompts unlock after purchase.
Automation, Utilities & Developer Tools
$6