- Why This Project Exists
- Features
- Prerequisites
- Installation
- Development
- Docker
- API Documentation
- Production
- API Endpoints
- Error Responses
- Project Structure
- Architecture
- Technologies Used
- Configuration Defaults
- Development Scripts
- License
- Contributors
Broken links in open source projects are a common pain. We've all seen README files that are outdated, full of links that lead nowhere.
This project was created to solve that. Its goal is simple: scan README files and report broken links, so it's easier to keep documentation clean, useful, and frustration-free. This repo is for checking the validady of the links via http request.
You can also check https://github.com/Deadlink-Hunter/Broken-Link-Website , this is the website where the user can insert some links to check.
A TypeScript Express application that checks if URLs are broken or not. Built with ES modules syntax, pnpm package manager, and follows the MVC pattern.
- ✅ Check if a single URL is broken
- ✅ Check multiple URLs at once (up to 10 URLs per request)
- ✅ Response time tracking
- ✅ Detailed error reporting
- ✅ TypeScript with ES modules
- ✅ CORS enabled
- ✅ Health check endpoint
- ✅ MVC architecture pattern
- ✅ Swagger/OpenAPI documentation
- Node.js (v16 or higher)
- pnpm package manager
- Install dependencies:
pnpm installStart the development server with hot reload:
pnpm devThe server will start on http://localhost:3000
The API documentation is available at:
- Swagger UI:
http://localhost:3000/api-docs - OpenAPI JSON:
http://localhost:3000/api-docs/swagger.json
Build the application:
pnpm buildStart the production server:
pnpm startThis application includes Docker support for easy deployment and containerization.
- Docker installed on your system
- Docker Compose (optional, for easier management)
Build the Docker image locally:
docker build -t broken-link-checker .Run the container and map port 3000:
docker run -p 3000:3000 broken-link-checkerThe application will be available at http://localhost:3000
To run the container in the background:
docker run -d -p 3000:3000 --name broken-link-checker-app broken-link-checkerGET /api/health
POST /api/check-url
Content-Type: application/json
{
"url": "https://example.com"
}
Response:
{
"success": true,
"data": {
"url": "https://example.com",
"isBroken": false,
"statusCode": 200,
"responseTime": 245
}
}POST /api/check-urls
Content-Type: application/json
{
"urls": [
"https://example.com",
"https://google.com",
"https://invalid-url-that-does-not-exist.com"
]
}
Response:
{
"success": true,
"data": {
"results": [
{
"url": "https://example.com",
"isBroken": false,
"statusCode": 200,
"responseTime": 245
},
{
"url": "https://google.com",
"isBroken": false,
"statusCode": 200,
"responseTime": 156
},
{
"url": "https://invalid-url-that-does-not-exist.com",
"isBroken": true,
"error": "Request failed",
"responseTime": 10000
}
],
"summary": {
"total": 3,
"broken": 1,
"working": 2
}
}
}{
"success": false,
"data": {
"url": "invalid-url",
"isBroken": true,
"error": "Invalid URL format"
}
}{
"success": false,
"error": "URL is required"
}{
"success": false,
"error": "Maximum 10 URLs allowed per request"
}src/
├── index.ts # Main application entry point
├── config/
│ └── swagger.ts # Swagger/OpenAPI configuration
├── controllers/
│ └── urlController.ts # URL checking controller logic
├── routes/
│ └── urlRoutes.ts # URL checking routes with Swagger docs
├── services/
│ └── urlService.ts # URL checking service logic
└── constants/
└── index.ts # Application constants
The application follows the MVC (Model-View-Controller) pattern:
- Controllers (
src/controllers/): Handle HTTP requests and responses, contain business logic - Routes (
src/routes/): Define API endpoints and connect them to controllers - Services (
src/services/): Contain core business logic and data processing - Models: Represented by TypeScript interfaces and data structures
- Config (
src/config/): Configuration files like Swagger documentation
- Express.js - Web framework
- TypeScript - Type safety and modern JavaScript features
- ES Modules - Modern import/export syntax
- Axios - HTTP client for URL checking
- CORS - Cross-origin resource sharing
- Swagger/OpenAPI - API documentation
- pnpm - Fast, disk space efficient package manager
The application uses the following default configuration:
- Port: 3000 (can be overridden with
PORTenvironment variable) - Timeout: 10 seconds for URL checks
- Max Redirects: 5
- Max URLs per request: 10
pnpm dev- Start development server with hot reloadpnpm build- Build the TypeScript applicationpnpm start- Start the production serverpnpm test- Run tests (placeholder)
You can see the licence file
Thanks to all the amazing contributors: