Legacy decorator routing from @koala-ts/framework is deprecated in 2.x and should be replaced with function-first routing from @koala-ts/framework/routing.
Deprecated legacy surface:
Routefrom@koala-ts/frameworkgetRoutesfrom@koala-ts/frameworkregisterRoutesfrom@koala-ts/frameworkKoalaConfig.controllers
Recommended replacement:
Routefrom@koala-ts/framework/routingKoalaConfig.routes
import { Route, type HttpScope } from '@koala-ts/framework';
class UsersController {
@Route({ method: 'GET', path: '/users' })
list(scope: HttpScope): void {
scope.response.body = [];
}
}import { Route } from '@koala-ts/framework/routing';
import type { HttpScope } from '@koala-ts/framework';
export const listUsers = Route({
method: 'GET',
path: '/users',
handler: async (scope: HttpScope) => {
scope.response.body = [];
},
});Route from @koala-ts/framework/routing accepts:
methodpathhandler- optional
middleware - optional
options
import { create } from '@koala-ts/framework';
create({
controllers: [UsersController],
});import { create } from '@koala-ts/framework';
import { Route } from '@koala-ts/framework/routing';
import type { HttpScope } from '@koala-ts/framework';
const listUsers = Route({
method: 'GET',
path: '/users',
handler: async (scope: HttpScope) => {
scope.response.body = [];
},
});
create({
routes: [listUsers],
});import { createTestAgent } from '@koala-ts/framework';
const agent = createTestAgent({
controllers: [UsersController],
});import { createTestAgent, type HttpScope } from '@koala-ts/framework';
import { Route } from '@koala-ts/framework/routing';
const listUsers = Route({
method: 'GET',
path: '/users',
handler: async (scope: HttpScope) => {
scope.response.body = [];
},
});
const agent = createTestAgent({
routes: [listUsers],
});An application instance must use exactly one routing style:
- legacy routing with
controllers - function-first routing with
routes
Mixing both in the same app or test agent is rejected.
Invalid configuration:
create({
controllers: [UsersController],
routes: [listUsers],
});- Move route declarations out of controller classes and into exported route values.
- Import
Routefrom@koala-ts/framework/routing. - Replace
controllersusage withroutes. - Update test agents to use the same
routesconfiguration. - Do not mix
controllersandroutesin the same application instance.