Skip to content

REST API sederhana yang mengambil data komik dari bacakomik.my menggunakan teknik scraping.

Notifications You must be signed in to change notification settings

ilman-ramdhan/api-comic

Repository files navigation

📘 Comic API

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.

✨ Features

  • Hybrid Architecture: Database-first strategy with scraping fallback.
  • Smart Scraper: Uses axios + cheerio with 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.

🛠️ Tech Stack

  • Runtime: Node.js
  • Framework: Express.js (v5)
  • Database: MongoDB (Mongoose ODM)
  • Scraping: Axios, Cheerio
  • Image Processing: Sharp
  • Quality: ESLint, Prettier

🚀 Installation

1. Clone Repository

git clone https://github.com/ilmanpusat/comic-api.git
cd comic-api

2. Install Dependencies

npm install

3. Setup Environment Variables

Create 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/

4. Run Server

Development Mode:

npm run dev

Production Mode:

npm start

5. API Documentation

Base URL: /api

Comics

  • 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)

Chapters

  • Chapter Images: GET /api/:slug/chapter/:number

Genres

  • Get Genres: GET /api/genres
  • Comics by Genre: GET /api/genres/:slug?page=1

System

  • Health Check: GET /api/health
  • Popular Comics: GET /api/popular
  • Trending Comics: GET /api/trending
  • Image Proxy: GET /api/image-proxy?url=...

📂 Project Structure

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

📄 License

MIT License.

✨ Author

Ilman M Ramdhan

About

REST API sederhana yang mengambil data komik dari bacakomik.my menggunakan teknik scraping.

Topics

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published