Published onI recently answered a question on StackOverflow pertaining to decoupling services from controllers in NestJS with interfaces. I’ve seen this accomplished with both interfaces and abstract classes but will be focusing on interface for this post. If you’ve worked with in .NET or Java/Spring, you’ll know this has become very common practice when building systems while some might consider it over engineering. Regardless we’ll demonstrate how to register your services with the NestJS dependency injector to allow for injection to interface types.
Published onIn a previous post we created generic crud service that we could extend from in order to provide basic crud operations to an Angluar service. I had received a comment and was ask how I would apply this pattern with pagination. Pagination can be either client side or server side so this is really dependant on how the pagination is implemented. Since we just created server side pagination, I figured I’d provide an update to the generic crud service and modify it to work with a paginated findAll method.
Published onIn our previous post we create a basic Crud API with an endpoint to pull all users from the database. Pulling all users may not not be the best solution especially if millions of rows exist in the users table. A common approach to solving this to use pagination. You can think of pagination as only getting the page of a book that you need rather than getting the whole book.
Published onPrerquisites The following dependencies are required for this project. NodeJS Angular CLI NestJS CLI Setup This post builds upon our previous post here. You can also clone this Github repository if you prefer to skip the first part. Creating Our CRUD Endpoints We are going to quickly create endpoints to create, read, update and delete users from our SQLite database. We will also create a “find all” endpoint which will return all users in the database.
Published onOne of the new technologies I’ve been very interested in has been the Nest.JS framework. Nest.JS is a wrapper around Express (or Fastify) that provides a ton build in features that would otherwise require some configuration/boilerplate code. In the next few blog post I’m going to build out a very simple CRUD api with support for pagination. We’re also going to use Angular to build a simple table showing our paginated endpoint in use.