Simple & Lightweight Comic API (Manga, Manhwa, Manhua) scraper for bacakomik.my with MongoDB persistence.
Built with Express.js, Cheerio, and Mongoose, designed to be fast, reliable, and easy to deploy.
- Hybrid Architecture: Database-first strategy with scraping fallback.
- Smart Scraper: Uses
axios+cheeriowith User-Agent Rotation and Cloudflare Detection. - Persistence: Stores comic details and chapters in MongoDB to minimize external requests.
- Image Proxy: Optimizes external images (resize, quality adjustment) using
sharp. - Clean Architecture: Highly modular code (Controllers, Services, Repositories, Strategies).
- Security: Helmet, CORS, and robust error handling.
- Runtime: Node.js
- Framework: Express.js (v5)
- Database: MongoDB (Mongoose ODM)
- Scraping: Axios, Cheerio
- Image Processing: Sharp
- Quality: ESLint, Prettier
git clone https://github.com/ilmanpusat/comic-api.git
cd comic-apinpm installCreate a .env file:
PORT=3000
NODE_ENV=development
API_URL=http://localhost:3000
# Database
MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/comic-db
# Allowed Origins (comma separated)
ALLOWED_ORIGIN=http://localhost:3000,https://your-domain.com
# Target Source (Optional)
SOURCE_URL=https://bacakomik.my/Development Mode:
npm run devProduction Mode:
npm startBase URL: /api
- Get Latest Comics:
GET /api/latest?page=1 - Search Comics:
GET /api/search?q=naruto&page=1 - Comic Detail:
GET /api/:slug - Comics by Type:
GET /api/type/:typeName?page=1(manga/manhwa/manhua)
- Chapter Images:
GET /api/:slug/chapter/:number
- Get Genres:
GET /api/genres - Comics by Genre:
GET /api/genres/:slug?page=1
- Health Check:
GET /api/health - Popular Comics:
GET /api/popular - Trending Comics:
GET /api/trending - Image Proxy:
GET /api/image-proxy?url=...
src/
├── config/ # Configuration & Envs
├── controllers/ # Request Handlers (Class-based)
├── middlewares/ # Express Middlewares
├── models/ # Mongoose Models
├── repositories/ # Database Access Layer
├── routes/ # Route Definitions
├── services/ # Business Logic & Scrapers
│ ├── core/ # Strategies (Anti-bot, HTTP)
│ └── parsers/ # HTML Parsing Logic
└── utils/ # Helper Functions
MIT License.
Ilman M Ramdhan