Below is the updated README.md file with instructions for adding the .env file with the required variables:
This repository contains the source code for the Document Signing Application API, which includes routes for user authentication and document management.
To get started with the API, follow the steps below.
Make sure you have the following installed on your machine:
- Node.js
- npm (Node Package Manager)
- MongoDB
Clone this repository to your local machine:
git clone https://github.com/ribhar/document_signing_app_api.git
-
Open a terminal window.
-
Navigate to the project's root directory:
cd document_signing_app_api
- Install the required dependencies:
npm install
Before running the application, ensure you configure the necessary environment variables. Create a .env file in the project's root directory and add the following variables:
# Server Port
PORT=8080
# Database URI
DB_URI=mongodb://localhost:27017/document_signing_app
# JWT
JWT_SECRET=yourjwtsecret
JWT_SECRET_EXPIRY=1h
# Misc
SESSION_SECRET=yoursecret
To start the API server, use the following command:
npm start
The API server will be running on http://localhost:3000.
-
POST /user/register
- Register a new user.
- Sample Request Body:
{ "username": "user1", // Should be alphanumeric, example: "user1", "user2" "email": "user@example.com", "password": "Password@123" // The password must consist of 8 to 15 characters and include at least one number, one uppercase letter, and one lowercase letter. } - Sample Response (Success):
{ "status": 200, "message": "User registered successfully.", "credentials": {} } - Sample Response (Error):
{ "message": "Registration failed", }
-
POST /user/login
- Authenticate a user.
- Sample Request Body:
{ "email": "exampleuser", "password": "examplepassword" } - Sample Response (Success):
{ "status": 200, "message": "Login Success", "credentials": {}, "token": "Token_string" } - Sample Response (Error):
{ "message": "User not found", }
-
POST /doc/upload
- Upload a new document.
- Sample Request Body:
{ "file": "Example Document", // formdata } - Sample Response (Success):
{ "status": 200, "message": "Document uploaded successfully", "pdfUrl": "pdf_url_string" } - Sample Response (Error):
{ "status": 500, "error": "Error saving document details", "message": "err.message (error_trace)", }
-
POST /doc/sign
- Sign a document.
- Sample Request Body:
{ "name": "Sample signatary name", "email": "Sample signatary email", "signature": "base64_string", "pdfUrl": "pdf_url_string" } - Sample Response (Success):
pdf binary representation data - Sample Response (Error):
{ "status": 500, "error": "Error signing document", "message": "err.message (error_trace)", }
-
GET /doc/:id
- Get a document by ID.
- Sample Response (Success):
{ "name": "Sample signatary name", "email": "Sample signatary email", "ownerId": "", "isSigned": true, "docUrl": "pdf_url_string", "signedDocUrl": "pdf_url_string", } - Sample Response (Error):
{ "status": 404, "message": "Document not found or not signed by the user" }
-
GET /doc/
- Get all documents.
- Sample Response (Success):
[ { "name": "success", "email": "Document fetched successfully.", "ownerId": "", "isSigned": true, "docUrl": "pdf_url_string", "signedDocUrl": "pdf_url_string", }, {} ] - Sample Response (Error):
{ "status": 500, "error": "Error saving document details", "message": "err.message (error_trace)", }
For any issues or questions related to the API, please open an issue in the GitHub repository or contact the maintainers directly.
Contributions are welcome! If you have any improvements or new features you would like to add to the API, please feel free to open a pull request.
This API is licensed under the MIT License. See the LICENSE file for more details.