Questions & Answers

How can I define http routes using the functional API?

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.

Routes can be defined using the functional API by getting an instance of the HttpRouterRegistry and using its methods to define routes. For example:

const app = new App({
    imports: [new FrameworkModule()]
});

const router = app.get(HttpRouterRegistry);

router.get('/user/:id', (id: number, database: Database) => {
    // Route logic
});

app.run();