Youtube video showcasing the project (in portuguese): https://youtu.be/8AQKo-_t8EY
This is a tech challenge for the company sharenergy. The project consists of:
- Create one API with CRUD operations and saving the data in mongodb
- Integrate the server with the Dog API
- Integrate the server with the Cat API
- Integrate the server with the Random User API and with search and pagination functionality
- Login page to have access to the endpoints
- Doing the frontend in React
- The project has 2 separate entities, the frontend and backend, let's see how to run the backend first.
- The login functionality requires an username
desafiosharenergy
and a passwordsh@r3n3rgy
. However the password stored in the database is hashed, so you need to hash the password using argon2 and store it in the Admin collection. The Admin collection requires a document with the following structure:
{ username: String, password: String, session: { token: String, expiresIn: Date }}
You can omit the session object since it'll be created automatically once you log in.
- Go to the MongoDB website and create an account, this project uses the Atlas Cloud Database.
- Follow their tutorial and create a database
- Get your Atlas URI, usually it's something like mongodb+srv://username:[email protected]/Sharenergy?retryWrites=true&w=majority
Assuming you just cloned the repository, do the following:
$ cd desafio-sharenergy-2023-01/
$ git checkout patrick-dos-reis
$ cd backend/
$ vim .env
Inside the .env file, the only variable is the Atlas URI, so the file has to be like this:
ATLAS_URI=<your-atlas-uri>
Still inside the backend directory, do the following:
$ npm install
Still inside the backend directory, do the following:
$ npm run dev
$ npm run build
$ npm start
In the root folder, do the following:
$ cd frontend/
$ npm install
$ npm start