Shortest path algorithm, tests and Postman

- Added algorithm and endpoint to find the shortest path between two
  topics;
- Added respective test;
- Added a JSON collection with API calls that can be imported into
  Postman for the convenience of the user.
This commit is contained in:
Rodrigo Pinto 2025-04-06 01:41:54 -03:00
commit d7748229ef
9 changed files with 419 additions and 118 deletions

View file

@ -20,7 +20,11 @@ npm run start
## Usage
You can use Postman or Curl to make calls to the API. The examples below use Curl.
You can use Postman or Curl to make calls to the API.
If using Postman, you can import the collection `ProjectMark.postman_collection.json` from the root.
The examples below use Curl.
### Create a topic:
@ -76,6 +80,24 @@ curl -X DELETE http://localhost:3000/api/topics/1234567890
> Replace `1234567890` with the topic id.
## Utilities
### Retrieve topic and all its subtopics recursively
```sh
curl -X GET http://localhost:3000/api/topics/recursive/1234567890
```
> Replace `1234567890` with the topic id.
### Shortest path between two topics in a tree
```sh
curl -X GET http://localhost:3000/api/topics/shortest/1234567890/0987654321
```
> Replace `1234567890` and `0987654321` with the topic ids.
## Tests
Run tests with: