End to end testing (e2e) in NestJS

Loading

Reading Time: 4 minutes This is part 3 of Use TypeOrm Custom Repository in NestJS and this post is about end- to-end testing (e2e) of NestJS endpoints. In part one and part two, controllers, services and custom repositories are tested and they pass all the test cases. The final step is to validate HTTP requests between frontend and backend … Read more

Unit Test Custom Repository in NestJS

Loading

Reading Time: 5 minutes This is part 2 of Use TypeOrm Custom Repository in NestJS and this post is about unit testing custom repository. In part one, I created a NestJS demo with controllers, services and custom repositories. The demo also added unit testing on controllers and services in which I mocked the methods of custom repositories with jest.fn(). … Read more

Dependency injection by abstract class in NestJS

Loading

Reading Time: 3 minutes When developers start using NestJS, they create new module with controllers and services to design backend APIs. Developers register controllers and services in the module and inject service into controller to perform CRUD operations. Provider Registration The following is a code snippet of a user module; user controller is registered in controller array while user … Read more

Use TypeOrm Custom Repository in NestJS

Loading

Reading Time: 5 minutes NestJS has out of box integration with TypeORM, a TypeScript and JavaScript ORM that has good support of PostgreSQL. The library offers decorators to model data types and entities and tools to generate migration scripts to update database schema; therefore, it is a popular choice to perform CRUD operations. TypeORM offers custom repository that allows … Read more

Replace MomentJS with date-fns in Nestjs

Loading

Reading Time: 2 minutes We use NestJS at work and the backend project needs to perform date calculations and formatting in the services. Our team chose momentJS because it is the one of the most popular date-time open source project. After a while, we discovered that the library size is huge (~290kb) and it is not tree-shakable. If I … Read more

You probably don’t need Lodash in Nestjs

Loading

Reading Time: 2 minutes I completed Angular Architect Training Course from Bonnie Brennan at Angular Nation and lesson 1 is about style and structure. Even though the tips are for Angular application but a couple of them applies to NestJS. One of them is to void fat libraries such as lodash and moment. In this post, I am going … Read more

My Spanish app in PANNG stack

Loading

Reading Time: < 1 minute Intention: I am learning Spanish from a Spanish teacher and I cannot read my own notes due to my horrible handwriting. My resolution is to build a full-stack app to store new Spanish vocabulary. Stack: PANNG (Prisma, Angular, NestJS, Nx, GraphQL) Repo: https://github.com/railsstudent/nx-apollo-angular-course Characteristics: Nx Monorepo GraphQL module in Nest Apollo GraphQL Angular Apollo TypeScript … Read more