BaseHttpServer
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.
The simple mental model
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 pattern explains the named API. Application classes, credentials, and assets may need to be supplied; use a complete recipe for a runnable starting point.
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'))- 1
The constructor configures either your Express app or a new one.
- 2
Static folders and service definitions are registered in deterministic order.
- 3
You pass base.app to http.createServer, a test harness, or another host when you are ready.
Choices you can make
- All `HttpServer` app-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.