Skip to content

[Startup MVP recipes #14] JWT Authentication with Nest.js + Passport + MikroOrm

Official doc(https://docs.nestjs.com/security/authentication#authentication) is also recommended but this tutorial is easier to read and contains much clear essentials Background Although recently our team migrated to MikroOrm, indeed MikroOrm is very similar to TypeOrm and you can easily replace the code pointers here with your own TypeOrm… Read More »[Startup MVP recipes #14] JWT Authentication with Nest.js + Passport + MikroOrm

[Startup MVP recipes #13] Quick glance: Inheritance of TypeOrm’s Entity and GraphQL’s Object

This is a quick tutorial and code pointer sharing of how to create a reusable base entity that contains common columns. There are more advanced topics on this e.g. https://jczhang.com/2022/07/29/startup-mvp-recipes-6-graphql-resolver-inheritance-and-a-crud-base-resolver-with-generics/ , etc. The Base Entity The abstract modifier is used to mark it as an… Read More »[Startup MVP recipes #13] Quick glance: Inheritance of TypeOrm’s Entity and GraphQL’s Object

[Startup MVP recipes #11] Nest.js Run Unit Tests with Github Actions

If interested, please also check previous two articles on setting up the tests: https://jczhang.com/2022/08/08/startup-mvp-recipes-9-nest-js-typeorm-postgres-unit-testing-service-onlywith-jest-pg-mem/ https://jczhang.com/2022/08/09/startup-mvp-recipes-10-nest-js-unit-testing-mocking-service-and-the-universal-mock/ References https://medium.com/swlh/jest-and-github-actions-eaf3eaf2427d https://github.com/marketplace/actions/run-jest https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs Config On PR open, we will trigger this github action workflow on the cloud and let it run the checks remotely. Demo

[Startup MVP recipes #10] Nest.js Unit Testing: Mocking service and the universal mock

Intro and TL; DR In last article: https://jczhang.com/2022/08/08/startup-mvp-recipes-9-nest-js-typeorm-postgres-unit-testing-service-onlywith-jest-pg-mem/, we had a first glance at how to setup unit test with jest, and inject an in-memory postgres for testing the services. Now we move back to write unit tests for resolvers, and the idea and philosophy… Read More »[Startup MVP recipes #10] Nest.js Unit Testing: Mocking service and the universal mock

[Startup MVP recipes #9] Nest.js TypeORM Postgres Unit Testing (service only)with Jest, pg-mem

In this tutorial we will cover basic strategy of unit testing a service in Nest.js + TypeORM setup. We don’t create an environment for test purpose, but instead, we use pg-mem adapter to run a local in-memory Postgres simulator instance. In this way the db… Read More »[Startup MVP recipes #9] Nest.js TypeORM Postgres Unit Testing (service only)with Jest, pg-mem

[Startup MVP recipes #8] Pagination – Nest.js, GraphQL, and TypeORM

For this topic, there are already good examples over the internet and I will just paste some references and give an code pointer directly. References https://docs.nestjs.com/graphql/resolvers#generics https://graphql.org/learn/pagination/#pagination-and-edges https://gist.github.com/tumainimosha/6652deb0aea172f7f2c4b2077c72d16c The Code Usage We have a field called sellerId which is just the user id. A sample… Read More »[Startup MVP recipes #8] Pagination – Nest.js, GraphQL, and TypeORM

[Startup MVP recipes #6] GraphQL Resolver inheritance and a CRUD base resolver with generics

Background For your background information, we have our own defined auth guard named MagentoAuth (that interacts with Magento and issue our own tokens) and we have a sellerId which is just the user id. We self defined @CurrentSellerId() to get the sellerId for GQL from… Read More »[Startup MVP recipes #6] GraphQL Resolver inheritance and a CRUD base resolver with generics

[Startup MVP recipes #5.2] A simple resource generated by nest-cli then configured (part 2)

Warning: we are using typeorm 0.3 and postgres for this tutorial This tutorial continues where we left in And let’s fill in the rest of generated boilerplate by nest-cli. The Read of CRUD Find queries are pretty straightforward: The Update of CRUD Define update DTO… Read More »[Startup MVP recipes #5.2] A simple resource generated by nest-cli then configured (part 2)