Take home test for ProjectMark
Find a file
Rodrigo Pinto d7748229ef 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.
2025-04-06 01:41:54 -03:00
src Shortest path algorithm, tests and Postman 2025-04-06 01:41:54 -03:00
tests Shortest path algorithm, tests and Postman 2025-04-06 01:41:54 -03:00
.gitignore Initial commit 2025-04-01 17:28:15 -03:00
eslint.config.mjs Install NodeJS, TypeScript, ExpressJS and ESLint 2025-04-01 17:58:14 -03:00
jest.config.ts Shortest path algorithm, tests and Postman 2025-04-06 01:41:54 -03:00
LICENSE Initial commit 2025-04-01 17:28:15 -03:00
package-lock.json Basic structure of the project 2025-04-02 17:07:06 -03:00
package.json Basic structure of the project 2025-04-02 17:07:06 -03:00
ProjectMark.postman_collection.json Shortest path algorithm, tests and Postman 2025-04-06 01:41:54 -03:00
README.md Shortest path algorithm, tests and Postman 2025-04-06 01:41:54 -03:00
tsconfig.json Install NodeJS, TypeScript, ExpressJS and ESLint 2025-04-01 17:58:14 -03:00

ProjectMark-Rodrigo

Take home test for ProjectMark

Run the project

This project requires NodeJS version 19 or newer.

  • Install dependencies:
npm install

Start project:

npm run start

Usage

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:

curl -X POST http://localhost:3000/api/topics \
  -H "Content-Type: application/json" \
  -d '{"name": "A topic", "content": "Topic content"}'

Get all topics:

curl -X GET http://localhost:3000/api/topics

Get specific topic:

curl -X GET http://localhost:3000/api/topics/1234567890

Replace 1234567890 with the topic id.

Update a topic:

curl -X PUT http://localhost:3000/api/topics/1234567890 \
  -H "Content-Type: application/json" \
  -d '{"name": "Updated topic"}'

Replace 1234567890 with the topic id.

Get specific version of a topic:

curl -X GET http://localhost:3000/api/topics/1234567890/1

Create a child topic:

curl -X POST http://localhost:3000/api/topics \
  -H "Content-Type: application/json" \
  -d '{"name": "A topic", "content": "Topic content", "parentTopicId": 1234567890 }'

Delete a topic:

curl -X DELETE http://localhost:3000/api/topics/1234567890

Replace 1234567890 with the topic id.

Utilities

Retrieve topic and all its subtopics recursively

curl -X GET http://localhost:3000/api/topics/recursive/1234567890

Replace 1234567890 with the topic id.

Shortest path between two topics in a tree

curl -X GET http://localhost:3000/api/topics/shortest/1234567890/0987654321

Replace 1234567890 and 0987654321 with the topic ids.

Tests

Run tests with:

npm run test