This microservice processes text and extracts content from PDF and Word documents to apply bold formatting based on user-defined preferences. It is designed to help users with ADHD or Autism improve readability.
The service includes three endpoints:
/processText- Format visible text with bolding./extractFromPDF- Extract and format text from PDFs./extractFromWord- Extract and format text from Word documents.
- Base URL:
http://localhost:3000 - Content-Type:
application/json - Use Postman or any HTTP client to send
POSTrequests.
Processes plain text to apply bold formatting.
- Method:
POST - Endpoint:
/processText - Body:
{ "text": "This is a sample text.", "boldIntensity": "medium", "boldAmount": "first_half" }
Fields: text (string, required): The text to be formatted. boldIntensity (string, required): The intensity of bold formatting ("low", "medium", "high"). boldAmount (string, required): The portion of the word to bold ("first_half", "all").
Response: { "processedText": "This is a sample text." }
Example Postman Configuration: Method: POST URL: http://localhost:3000/processText Headers: Content-Type: application/json
Body (raw): { "text": "This is a sample text.", "boldIntensity": "medium", "boldAmount": "first_half" }
- /extractFromPDF Description Extracts and formats text from a PDF file.
Request Method: POST Endpoint: /extractFromPDF
Body (Base64 Input) { "pdfData": "BASE64_ENCODED_PDF_STRING", "boldIntensity": "high", "boldAmount": "all" }
Body (URL Input) { "pdfUrl": "https://example.com/sample.pdf", "boldIntensity": "medium", "boldAmount": "first_half" }
Fields: pdfData (string, optional): The Base64-encoded PDF file. pdfUrl (string, optional): A URL pointing to the PDF file. boldIntensity (string, required): The intensity of bold formatting ("low", "medium", "high"). boldAmount (string, required): The portion of the word to bold ("first_half", "all").
Response
Format: { "processedText": "This is a sample document." }
Example Postman Configuration: Method: POST URL: http://localhost:3000/extractFromPDF Headers: Content-Type: application/json Body (raw) (for Base64 input)
{ "pdfData": "BASE64_ENCODED_PDF_STRING", "boldIntensity": "high", "boldAmount": "all" }
Body (raw) (for URL input): { "pdfUrl": "https://example.com/sample.pdf", "boldIntensity": "medium", "boldAmount": "first_half" }
- /extractFromWord Description Extracts and formats text from Word documents (.docx files).
Request Method: POST Endpoint: /extractFromWord
Body (Base64 Input): { "wordData": "BASE64_ENCODED_DOCX_STRING", "boldIntensity": "medium", "boldAmount": "first_half" }
Body (URL Input): { "wordUrl": "https://example.com/sample.docx", "boldIntensity": "high", "boldAmount": "all" } Fields: wordData (string, optional): The Base64-encoded .docx file. wordUrl (string, optional): A URL pointing to the .docx file. boldIntensity (string, required): The intensity of bold formatting ("low", "medium", "high"). boldAmount (string, required): The portion of the word to bold ("first_half", "all").
Response Format: { "processedText": "This is a Word document." }
Example Postman Configuration: Method: POST URL: http://localhost:3000/extractFromWord Headers: Content-Type: application/json Body (raw) (for Base64 input):
{ "wordData": "BASE64_ENCODED_DOCX_STRING", "boldIntensity": "medium", "boldAmount": "first_half" } Body (raw) (for URL input): { "wordUrl": "https://example.com/sample.docx", "boldIntensity": "high", "boldAmount": "all" }
Error Handling Missing Fields Response: { "error": "Missing required fields: text/pdfData/pdfUrl/wordData/wordUrl, boldIntensity, or boldAmount." } Invalid File Response: { "error": "Failed to process the file.", "details": "Invalid file format." }
A test script (test_microservice.js) is included to demonstrate the functionality of the microservice. This script:
- Tests all endpoints (
/processText,/extractFromPDF,/extractFromWord). - Logs the responses for validation.
- Ensure the microservice is running (
node index.js). - Run the test script using:
node test_microservice.js
This microservice was implemented for Samuel Jamieson. The microservice handles text formatting to improve readability and includes endpoints for processing plain text, PDF files, and Word documents.
- Status: The microservice is fully implemented and tested.
- Tested Endpoints:
/processText: Formats plain text with bolding preferences./extractFromPDF: Extracts and formats text from PDF files (via Base64 or URL)./extractFromWord: Extracts and formats text from Word documents (via Base64 or URL).
- The microservice is ready for integration.
- Completion: The microservice is fully functional; no parts are pending.
- Testing Status: All endpoints have been tested using Postman and a custom test script (
test_microservice.js).
-
From GitHub:
- Clone the repository using the following link: GitHub Repository.
- Ensure Node.js and npm are installed locally.
-
Run Locally:
- Instructions:
- Clone the repository from GitHub.
- Install dependencies:
npm install
- Start the server:
node index.js
- Use the base URL
http://localhost:3000to make API calls.
- Instructions:
- Use the test script (
test_microservice.js) provided in the repository or test the endpoints via Postman.
-
Ensure Setup:
- Verify that the microservice is running locally by checking the logs for the message:
Microservice A is running on http://localhost:3000 - Confirm that the required dependencies (e.g., Node.js) are installed.
- Verify that the microservice is running locally by checking the logs for the message:
-
Check Requests:
- Ensure that API requests are formatted correctly (refer to the
README.mdfor examples). - Test the microservice using Postman or the provided
test_microservice.jsscript.
- Ensure that API requests are formatted correctly (refer to the
-
Contact Me for Help:
-
If issues persist, Samuel can contact me via:
- Email: hashmia@oregonstate.edu
-
Availability:
- Tues to Thurs: 10 AM – 2 PM.
- Weekends: Available for urgent issues via email.
-
- Deadline for Reporting Issues: Samuel must report any access or functionality issues by November 30, 2024.
- Why This Deadline?
- This allows sufficient time to debug and resolve issues before the final project submission or integration deadline.
-
Assumptions:
- It is assumed that Samuel has basic familiarity with API testing tools (e.g., Postman) or is willing to use the
test_microservice.jsscript. - Samuel will set up the microservice locally unless a hosted version is explicitly provided.
- It is assumed that Samuel has basic familiarity with API testing tools (e.g., Postman) or is willing to use the
-
Known Issues:
- Scanned PDFs may not extract text correctly unless OCR is applied (not implemented in this microservice).
- Ensure that provided URLs are publicly accessible and correctly formatted.
-
Backup Plan:
- If Samuel encounters issues and I am unavailable, detailed usage instructions in the
README.mdand test cases intest_microservice.jsshould serve as a fallback. - As a last resort, Samuel can provide sample input files, and I can process them manually and return results.
- If Samuel encounters issues and I am unavailable, detailed usage instructions in the
This mitigation plan ensures that Samuel Jamieson has clear instructions for accessing, testing, and using Microservice A. It provides detailed fallback steps and points of contact to handle integration issues efficiently.