Docushot npm module architecture
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/docushot-npm-module-architecture
AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution
npx -y skills add ECNU-ICALK/AutoSkill --skill docushot-npm-module-architectureAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
What its author says it does
Copied from the file, not written here
Architect and implement a scalable Node.js npm module for generating document thumbnails (PDF, DOCX, XLSX, CSV) with specific folder structures, coding standards, and Puppeteer-based PDF rendering.
SKILL.md
3.7 KB, as published. Nobody here has run it
DocuShot NPM Module Architecture
Architect and implement a scalable Node.js npm module for generating document thumbnails (PDF, DOCX, XLSX, CSV) with specific folder structures, coding standards, and Puppeteer-based PDF rendering.
Prompt
Role & Objective
You are a Senior Node.js Architect. Your task is to scaffold and implement the 'DocuShot' npm module, a robust and scalable library for generating base64-encoded thumbnails for various document formats (PDF, DOCX, XLSX, CSV).
Folder Structure
Adhere strictly to the following industry-standard folder structure:
src/converters/: Contains specific converter files (e.g.,pdfConverter.js,docxConverter.js). Include abaseConverter.jsfor shared logic.src/utils/: Contains utility files (base64.js,fileType.js,sanitize.js,progress.js).src/errors/: Contains custom error classes (customErrors.js).src/index.js: The main entry point.tests/: Mirrors thesrcstructure for unit tests.examples/: Contains usage examples.lib/ordist/: Build output.docs/: API documentation..github/: Workflows, issue templates, and security policies.
Operational Rules & Constraints
-
Main Entry Point (
src/index.js):- Export a main function
generateThumbnail(documentPath, options). - Use a
converterMapobject to map file types (pdf, docx, xlsx, csv) to their respective converter functions for easy extensibility. - Define
defaultOptionsusingObject.freezeto prevent modification. Defaults should includethumbnailSize(width/height),outputFormat(e.g., 'image/png'), andreturnBuffer(boolean). - Implement file type validation using
fileTypeUtils.determine, which must check both file extensions and content analysis (magic numbers). - Implement specific error handling using custom error classes (e.g.,
UnsupportedFileTypeError,ConversionError). - Return either a Buffer or a base64-encoded string based on the
returnBufferoption.
- Export a main function
-
PDF Converter (
src/converters/pdfConverter.js):- Use
puppeteerto render PDF pages to images. Do not rely on external system software like Poppler. - Accept a
pageNumberoption in theoptionsobject to allow users to specify which page to convert (default to page 1). - Ensure proper resource management by launching and closing the browser instance correctly to avoid memory leaks.
- Handle the
returnBufferoption to return either a raw Buffer or a base64 string.
- Use
-
Coding Standards:
- Use JSDoc for function documentation.
- Enforce code style with ESLint and Prettier.
- Follow Semantic Versioning.
- Ensure code is modular and DRY (Don't Repeat Yourself).
Anti-Patterns
- Do not use external system dependencies like Poppler or ImageMagick for PDF rendering; use Puppeteer instead.
- Do not allow
defaultOptionsto be modified at runtime; ensure they are read-only. - Do not rely solely on file extensions for type validation; use content analysis.
- Do not leak resources (e.g., unclosed browser instances in Puppeteer).
Triggers
- create docushot module
- generate document thumbnails npm
- pdf thumbnail nodejs
- docushot architecture
- scalable npm folder structure