7/5/2023 0 Comments Crud express postgres app![]() While the controllers provide application routing (think GET ), our service providers are responsible for doing the lifting to execute whatever type of operation against our data that the controller needs. ![]() These are called providers at the module level and are injected into controllers that ask for them. Notice that the controller takes a service in its constructor. We can define as many of these as we want, and they will automatically be picked up for routing as long as we register the controller with the module file. Each method in the controller class is typically given a decorator corresponding to the HTTP method (GET, PUT, POST, DELETE, etc.) required to call it. This is what we use to expose HTTP routes. ![]() If you look at this file, you'll notice that it takes in a controller and service through its decorator. Later on, we'll create a new module for Todo objects. NestJS uses modules to help organize our code and enforce seperation of concerns. This file will import and invoke (call) the app module that we export.
0 Comments
Leave a Reply. |