You need to run the command install on each dir (stock-service
and api-service
)
$ cd stock-service
$ npm i
$ cd ..
$ cd api-service
$ npm i
Get each .env.example
and change it's name to .env
If you don't have, install MongoDB or get a cluster from MongoDB Atlas
In api-service
it's needed to change the email and mongodb variables values for your own email and mongodb credentials
***If you are trying to use a gmail email,
$this$ (a document from nodemailer on how to use gmail) might help
Then run npm start
on each dir
The API will be on port 3001, unles you have changed it in the enviroment variables
If you want to use Docker, there is a docker-compose file inside the project, as for Running, you need to change the email credentials before you run
After changing the email credentials in docker-compose.yml file, you can run:
docker-compose up
The API will be on port 3001, unles you have changed it in the enviroment variables, it's important
to change the props ports
too.
There is an Insomnia json file inside the project, you can import it on your insomnia and the routes
and enviroment variables will be ready to use,
it's important to create an user and login-in before you test other routes
- (
POST
)/register - Send an email (optional: isAdmin as boolean) on body and it will return the email and a random password if the email is't already registered - (
POST
)/login - Send the email and password on body and it will return the user and a JWT token if the credentials are right - (
PATCH
)/users/reset/password -Bearer token needed
- Call this route and it will change the password to another random password and send it to the registered email - (
GET
)/history -Bearer token needed
- Call this route and it will return the search history from the user - (
GET
)/stats -Bearer token needed
-$Admins-only$ - Call this route and it will return each stock searched and how many times it was searched - (
GET
)/stock -Bearer token needed
- Send a stock id as query parameterq
and it will return the stock if it exists
Run npm run test
for Tests
****Remember starting the stock api locally, in Docker the api is not visible outside it's network****