An authentication API that can perform register and login operations with get and post methods. The aim is to learn how to hide passwords inside database and using tokens for sessions to login without users being asked with credentials everytime they perform an operation. For these useful tricks there are some dependencies that you need to install. They are not mandatory, optional, but since regarding the purpose of this API, these packages will not be listed under Optional dependencies list.
Initially, clone this repository. Then, under the same directory you need to initialize npm and create package.json
file with:
npm init
- express
- nodemon
- mongoose
- joi
- bcryptjs
- jsonwebtoken
- dotenv
Follow these commands:
npm install express npm install --save-dev nodemon npm install mongoose npm install @hapi/joi npm install bcryptjs npm install jsonwebtoken //optional npm install dotenvNote:
There are some parts inside source code that uses variables from .env
file which has not pushed to this repository due to privacy. Those piece of codes have comments for explanation about what is going on on that specific line. Write your own scripts that best suits your needs to those parts.