Skip to main content

API Reference

Complete reference for documcp APIs.

Core APIs

initialize(options)

Initialize the application with the given options.

Parameters:

  • options (Object): Configuration options
    • port (number): Server port (default: 3000)
    • host (string): Server host (default: 'localhost')
    • debug (boolean): Enable debug mode (default: false)

Returns:

  • Application: Application instance

Example:

const app = initialize({
port: 8080,
debug: true
});

start()

Start the application server.

Returns:

  • Promise<void>: Resolves when server is running

Example:

await app.start();
console.log('Server running');

stop()

Stop the application server.

Returns:

  • Promise<void>: Resolves when server is stopped

Example:

await app.stop();
console.log('Server stopped');

Events

'ready'

Emitted when the application is ready to accept connections.

app.on('ready', () => {
console.log('Application ready');
});

'error'

Emitted when an error occurs.

app.on('error', (error) => {
console.error('Application error:', error);
});

Error Codes

CodeDescription
ERR_INVALID_CONFIGInvalid configuration provided
ERR_PORT_IN_USESpecified port is already in use
ERR_STARTUP_FAILEDApplication failed to start