Decorator reference

Every decorator in Bustan 0.0.1.

Vous consultez la version 0.0.1. La dernière est 0.0.2.

Voir 0.0.2

@Module(...)#

Argument Type Default Description
imports list of modules [] Modules whose exports become available
controllers list of classes [] Controllers this module owns
providers list of classes or Provider [] Providers this module owns
exports list [] Providers visible to importing modules

@Controller(prefix)#

Marks a class as a controller. prefix is prepended to every route in it.

@Controller("/tasks")
class TaskController: ...

@Injectable()#

Marks a class as constructible by the container. Required for anything listed in providers.

Route decorators#

Decorator Method
@Get(path) GET
@Post(path) POST
@Put(path) PUT
@Patch(path) PATCH
@Delete(path) DELETE

Path parameters use {name} and are matched to handler arguments by name.

Parameter helpers#

Helper Reads from
Body() JSON request body
Query() Query string
Header(name) Request header
Param(name) Path parameter, when the names differ

Provider(...)#

Argument Description
provide The type this satisfies
token String token, as an alternative to provide
value A ready-made instance
factory A callable that builds the instance
inject What to pass the factory

Inject(token)#

Injects by string token rather than by type.

Bustan(root_module)#

Builds the ASGI application from a root module.