The available options for routing in Deepkit are:
- Functional API: You can define routes using the
HttpRouterRegistry
with functions that handle the requests. - Class Controller API: You can define routes using classes and decorators (
@http.*
) to define the HTTP methods and paths.
Here is an example of using the Class Controller API:
import { http, HttpRouterRegistry } from '@deepkit/http'; class MyController { @http.GET('/hello') hello() { return 'Hello, World!'; } } const app = new App({ controllers: [MyController] }); app.run();
This creates an HTTP server with a /hello
route that responds with "Hello, World!" when accessed with a GET request.