tspace-spear
Version:
tspace-spear is a lightweight, high-performance API framework for Node.js that leverages the native HTTP server and supports uWebSockets.js (C++) for maximum speed and efficiency.
35 lines (34 loc) • 871 B
TypeScript
/**
* Declares a class as a controller and assigns a base route path.
*
* The provided path will be used as the **base URL prefix**
* for all routes defined inside the controller. The path must
* start with `/`.
*
* This decorator stores the controller path using
* `Reflect.defineMetadata` under the key `"controllers"`.
* The framework can later read this metadata to register
* routes automatically.
*
* @example
* ```ts
* \@Controller('/users')
* class UserController {
*
* async list(ctx: T.Context) {
* return [{ id: 1, name: "John" }];
* }
*
* }
* ```
*
* If a route handler defines `/profile`, the final route becomes:
*
* ```
* /users/profile
* ```
*
* @param {`/${string}`} path - Base route path for the controller.
* @returns {ClassDecorator}
*/
export declare const Controller: (path: `/${string}`) => ClassDecorator;