CORE CONCEPTS
Config & Build
defineConfig() is a typed pass-through helper for your rasengan.server.ts file, read by both the CLI and bootstrap().
import { defineConfig } from '@rasenganjs/server'; export default defineConfig({ entry: 'src/main.ts', port: 4000, host: '0.0.0.0', preset: 'node', watchDir: 'src/', build: { outDir: 'dist', minify: true, formats: ['single-file'], }, });
RasenganServerConfig
port and host aren't hardcoded defaults
3000/"0.0.0.0" are the final fallback, not a value baked into
RasenganServerConfig itself. dev/start resolve config.port ?? process.env.PORT ?? 3000 (and the HOST equivalent) first. See
Environment Variables
for the full precedence chain.
BuildConfig
Resolution Order
Configuration merges from four sources, later ones winning:
- Built-in defaults (the table above).
rasengan.server.jsorrasengan.server.tsat the project root..env*files are already loaded by this point, so this file can readprocess.envitself (see Environment Variables).PORT/HOSTenvironment variables, forport/hostspecifically.- CLI flag overrides (
--port,--host,--entry,--preset,--watch-dir), see CLI.
Build Output Formats
rasengan-server build bundles your server with esbuild:
single-file: everything bundled into oneserver.bundle.mjs. Simplest to deploy, copy one file.directory: one.mjsper source file, preserving your project's structure. Useful when you want to inspect or patch individual output files.
Both formats can be produced in the same build by listing both in formats.
Programmatic Overrides
bootstrap() accepts an optional second argument, a partial config that merges on top of everything else, useful for tests or embedding:
bootstrap( (app) => { app.registerModule(appModule); }, { port: 0 } ); // port 0 lets the OS assign a free port, handy in tests
Module Plugins
Environment Variables
