Manual implementation
In this section, we will implement the authentication manually using passport without using the Nest.js package.
Implementation
In order to configure passport, three things need to be configured:
- The authentication strategy
 - The application middleware
 - The session, which is optional
 
Passport uses the strategy to authenticate a request, and the verification of the credential is delegated to the strategies in some of the requests.
Before using passport, you must configure the strategy, and in this case we will use the passport-jwt strategy.
Before anything else, you must install the appropriate packages:
npm i passport-jwt @types/passport-jwtnpm i jsonwebtoken @types/jsonwebtoken
Authentication module
In order to have a working example, you must implement some modules, and we will start with AuthenticationModule. The AuthenticationModule will configure the strategy using the jwt strategy. To configure the strategy we will extend the Strategy class provided...