This project provides a simple REST API for managing documents and accessing the list of employees.
The API supports authentication via HTTP headers and demonstrates basic authorization (user vs. admin), request logging, and CRUD operations for documents.
-
Install dependencies:
npm install
-
Start the server:
npm start
-
Run the test client:
npm test
To access most endpoints you must provide the following headers:
X-Login
: user loginX-Password
: user password
Method & URL | Description | Required Headers | Request Body (JSON) | Possible Responses |
---|---|---|---|---|
GET /documents | Retrieve all documents | X-Login , X-Password |
– | 200 OK – list of documents401 Unauthorized – invalid credentials |
POST /documents | Create a new document | X-Login , X-Password |
{ "title": "string", "content": "string" } |
201 Created – document created400 Bad Request – missing fields401 Unauthorized – invalid credentials |
DELETE /documents/:id | Delete a document by ID | X-Login , X-Password |
– | 204 No Content – successfully deleted404 Not Found – document not found401 Unauthorized – invalid credentials |
GET /employees | Retrieve all employees (admin only) | X-Login , X-Password (admin role required) |
– | 200 OK – list of employees401 Unauthorized – invalid credentials403 Forbidden – access denied |
The detailed report of this project is available in a separate document.
You can find it here:
ℹ️ This report includes explanations, screenshots, and all relevant details about the implementation and testing of the project.