BaseHttpServer
Documentation for Redweb 0.13.2. Install that exact version when following these examples.
Public Express app builder used by HttpServer and HttpsServer. Use it for advanced composition when you want Redweb middleware, static files, and services without any listener behavior.
Explain it like I’m five
BaseHttpServer prepares the kitchen but does not open the restaurant. You get a fully arranged Express app and decide which Node server will serve it.
When should I use it?
Use it for custom composition, tests, serverless adapters, or any setup where creating and listening on the HTTP server belongs to your application.
Follow the example
This API pattern illustrates the named surface; it may require application-owned classes, credentials, or assets. Start from a complete recipe for a runnable application.
const { BaseHttpServer, METHODS } = require('redweb')
const base = new BaseHttpServer({
publicPaths: ['./public'],
services: [
{ serviceName: '/health', method: METHODS.GET, function: (req, res) => res.json({ ok: true }) },
],
})
base.app.get('/extra', (req, res) => res.send('ok'))- The constructor configures either your Express app or a new one.
- Static folders and service definitions are registered in deterministic order.
- You pass base.app to http.createServer, a test harness, or another host when you are ready.
Options
- All
HttpServerapp-building options - server: existing Express application to configure
- listen is ignored because BaseHttpServer never binds a port
Methods and members
constructor(options)
Builds or configures an Express app with body parsing, CORS, static serving, and REST services.
app (Express instance)
The configured Express application. Pass it to http.createServer(app) for custom server ownership.
What should I watch for?
It intentionally ignores listener settings. If requests are not arriving, confirm that your own server is listening and forwarding them to base.app.