or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

application.mdhooks.mdindex.mdservice-interfaces.mdservices.md
tile.json

application.mddocs/

Application Management

Core application functionality for creating Feathers instances, managing settings, and controlling application lifecycle.

Capabilities

Application Factory

Creates a new Feathers application instance with event handling and service management capabilities.

/**
 * Creates a new Feathers application instance
 * @returns New Feathers application instance
 */
function feathers<T = any, S = any>(): Application<T, S>;

Usage Example:

import { feathers } from "@feathersjs/feathers";

const app = feathers();
console.log(app.version); // "5.0.34"

Application Class

The main application class that extends EventEmitter and provides core functionality.

/**
 * Main Feathers application class extending EventEmitter
 */
class Feathers<Services, Settings> extends EventEmitter implements FeathersApplication<Services, Settings> {
  services: Services;
  settings: Settings;
  mixins: ServiceMixin<Application<Services, Settings>>[];
  version: string;
  _isSetup: boolean;
}

Settings Management

Get and set application-wide configuration values.

/**
 * Retrieve an application setting by name
 * @param name - The setting name
 * @returns The setting value
 */
get<L extends keyof Settings & string>(name: L): Settings[L];

/**
 * Set an application setting
 * @param name - The setting name
 * @param value - The setting value
 * @returns The application instance for chaining
 */
set<L extends keyof Settings & string>(name: L, value: Settings[L]): this;

Usage Examples:

// Set configuration
app.set("host", "localhost");
app.set("port", 3030);
app.set("paginate", { default: 10, max: 50 });

// Get configuration
const host = app.get("host"); // "localhost"
const port = app.get("port"); // 3030

Application Configuration

Configure the application using callback functions.

/**
 * Runs a callback configure function with the current application instance
 * @param callback - The callback function to run
 * @returns The application instance for chaining
 */
configure(callback: (this: this, app: this) => void): this;

Usage Example:

app.configure(function(app) {
  app.set("host", "0.0.0.0");
  app.set("port", process.env.PORT || 3030);
});

Application Lifecycle

Methods for initializing and tearing down the application and all its services.

/**
 * Set up the application and call all services .setup method if available
 * @param server - A server instance (optional)
 * @returns Promise resolving to the application instance
 */
setup(server?: any): Promise<this>;

/**
 * Tear down the application and call all services .teardown method if available  
 * @param server - A server instance (optional)
 * @returns Promise resolving to the application instance
 */
teardown(server?: any): Promise<this>;

Usage Examples:

// Initialize application
await app.setup();

// Tear down application (cleanup)
await app.teardown();

Debug Configuration

Set debug mode for the Feathers application.

/**
 * Set debug mode for logging and development
 */
feathers.setDebug: (debug: boolean) => void;

Usage Example:

import { feathers } from "@feathersjs/feathers";

// Enable debug mode
feathers.setDebug(true);

const app = feathers();

Types

Application Interface

interface FeathersApplication<Services = any, Settings = any> {
  version: string;
  mixins: ServiceMixin<Application<Services, Settings>>[];
  services: Services;
  settings: Settings;
  _isSetup: boolean;
  
  get<L extends keyof Settings & string>(name: L): Settings[L];
  set<L extends keyof Settings & string>(name: L, value: Settings[L]): this;
  configure(callback: (this: this, app: this) => void): this;
  defaultService(location: string): ServiceInterface;
  use<L extends keyof Services & string>(
    path: L,
    service: ServiceInterface | Application,
    options?: ServiceOptions
  ): this;
  unuse<L extends keyof Services & string>(location: L): Promise<FeathersService>;
  service<L extends keyof Services & string>(path: L): FeathersService;
  setup(server?: any): Promise<this>;
  teardown(server?: any): Promise<this>;
  hooks(map: ApplicationHookOptions<this>): this;
}

interface Application<Services = any, Settings = any>
  extends FeathersApplication<Services, Settings>,
    EventEmitter {}

Service Mixin

type ServiceMixin<A> = (service: FeathersService<A>, path: string, options: ServiceOptions) => void;