Skip to content

SN2006/secure-api-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📄 Document & Employee API

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.


🚀 Installation & Run

  1. Install dependencies:

    npm install
  2. Start the server:

    npm start
  3. Run the test client:

    npm test

🔑 Authentication

To access most endpoints you must provide the following headers:

  • X-Login: user login
  • X-Password: user password

Endpoints

Method & URL Description Required Headers Request Body (JSON) Possible Responses
GET /documents Retrieve all documents X-Login, X-Password 200 OK – list of documents
401 Unauthorized – invalid credentials
POST /documents Create a new document X-Login, X-Password { "title": "string", "content": "string" } 201 Created – document created
400 Bad Request – missing fields
401 Unauthorized – invalid credentials
DELETE /documents/:id Delete a document by ID X-Login, X-Password 204 No Content – successfully deleted
404 Not Found – document not found
401 Unauthorized – invalid credentials
GET /employees Retrieve all employees (admin only) X-Login, X-Password (admin role required) 200 OK – list of employees
401 Unauthorized – invalid credentials
403 Forbidden – access denied

🔗 Repository

Public Repository Link

📄 Work Report

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published