Skip to content

Namespace Decorator

This file defines the Namespace decorator, which is used to assign a script namespace to a controller class in the @sodacore/core library. It sets up the necessary metadata for the class to be recognized as a script controller and associates it with the specified namespace.


Features

  • Namespace Assignment: Associates a controller class with a specific script namespace.
  • Controller Registration: Marks the class as a controller for autowiring.
  • Service Metadata: Registers the controller as a script service for discovery and management.

Usage

typescript
import Namespace from './decorator/namespace';

@Namespace('user')
export class UserController {
	// Controller methods here
}
  • Use @Namespace(name) on any class you want to register as a script controller under the given namespace.

API

Namespace(name: string): ClassDecorator

  • name: The namespace to associate with the controller.
  • Returns: A class decorator that sets the appropriate metadata for script controllers.

How It Works

  • Sets the type metadata to 'controller' for autowiring.
  • Sets the namespace metadata under the 'script' namespace.
  • Adds 'script' to the list of services in the controller's metadata.

Notes

  • Designed for use in script controllers that need to be grouped or routed by namespace.
  • The namespace helps organize and route script commands to the correct controller.

Released under the Apache-2.0 License.