To get authentication on order-api, we will use Passport. Passport is a piece of authentication middleware for Node.js, and is considered one of the most widely used pieces of middleware for this purpose. It is known as flexible and modular. There are a lot of strategies that support authentication using a username and password, Facebook, Twitter, JSON Web Tokens (JWTs), and other methods. For the purpose of this book, we will use JWT.
The first step is to install Passport and JWT:
$ npm install --save passport passport-jwt jsonwebtoken passport-local
Then, we need to install the types:
$ npm install --save-dev @types/jsonwebtoken @types/passport-jwt @types/passport @types/passport-local
Now that we have all of the dependencies ...