Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add API documentation for 'BackendContribution' #11

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions packages/core/src/node/backend-application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,54 @@ import { AddressInfo } from 'net';
import { ApplicationPackage } from '@theia/application-package';

export const BackendApplicationContribution = Symbol('BackendApplicationContribution');

/**
* Contribution for hooking into the backend lifecycle.
*/
export interface BackendApplicationContribution {
initialize?(): void;
configure?(app: express.Application): void;
/**
* Called during the initialization of the backend application.
* Use this for functionality which has to run as early as possible.
*
* The implementation may be async, however it will still block the
* initialization step until it's resolved.
*
* @returns either `undefined` or a Promise resolving to `undefined`.
*/
initialize?(): MaybePromise<void>;

/**
* Called after the initialization of the backend application is complete.
* Use this to configure the Express app before it is started, for example
* to offer additional endpoints.
*
* The implementation may be async, however it will still block the
* configuration step until it's resolved.
*
* @param app the express application to configure.
*
* @returns either `undefined` or a Promise resolving to `undefined`.
*/
configure?(app: express.Application): MaybePromise<void>;

/**
* Called right after the server for the Express app is started.
* Use this to additionally configure the server or as ready-signal for your service.
*
* The implementation may be async, however it will still block the
* startup step until it's resolved.
*
* @param server the backend server running the express app.
*
* @returns either `undefined` or a Promise resolving to `undefined`.
*/
onStart?(server: http.Server | https.Server): MaybePromise<void>;

/**
* Called when the backend application shuts down. Contributions must perform only synchronous operations.
* Any kind of additional asynchronous work queued in the event loop will be ignored and abandoned.
*
* @param app the express application.
*/
onStop?(app?: express.Application): void;
}
Expand Down