This project aims to materialize my knowledge in building rest apis with javascript and node.js. It simulates a simple organizational structure that has administrators and members, and these administrators are responsible for actions in the system.
First of all, you need to install this project in your environment.
git clone https://github.com/devwander/rest_api-javascript
# NPM
npm install --save-dev
# Yarn
yarn install --save-dev
For this project to run in your environment, a ".env" file must be created containing the necessary information. For more details access the ".env.example" file.
After installing and configuring the environment variables we can run the magrations so that the environment is ready for use.
# NPM
npx sequelize db:migrate
# Yarn
yarn sequelize db:migrate
Now that our environment is ready we must run the following commands to start it.
# NPM
npm run dev
# Yarn
yarn dev
All routes have been documented using Swagger Docs, go to "/api-docs" for more details and testing.
However, below is a table containing the functionalities of the application.
ROUTER | TYPE | OCCUPATION |
---|---|---|
/login | POST | This route is responsible for the administrator login generating its Access Token (JWT). |
/administrator | POST | The route is responsible for registering new administrators. |
/administrator | GET | The route is responsible for searching all existing administrators in the application. |
/administrator/{id} | GET | The route is responsible for searching only an existing administrator in the application. |
/administrator/{id} | PUT | This route is responsible for changing the administrator's data. Note: Only the administrator himself can change his data. |
/administrator/{id} | DELETE | This route is responsible for deleting the administrator. Note: Only the administrator himself can delete your data. |
/members | POST | This route has the function of registering new members. |
/members | GET | This route is responsible for searching all existing members in the application. |
/members/{id} | GET | The route is responsible for searching only an existing member in the application. |
/members/{id} | PUT | This route is responsible for changing the member's data. |
/members/{id} | DELETE | This route is responsible for deleting the member. |
The application has integration and unit testing coverage, to access your data use:
note: It is necessary that the database is changed in the environment variables (".env") before starting the tests.
# NPM
npm run test
# Yarn
yarn test
If you have any questions about the project that was developed here, I will be happy to help you. Contact me by email: josewanderson173@gmail.com.