Questions & Answers

What are the available options for routing?

Deepkit HTTP
50 up-votes
Warning: The answer is generated by an artificial intelligence. It might not be correct.
To adjust rating, open the thread in Discord and click on the up/down vote button.

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.