Version 2.1.0
- About
- Features
- Tech Stack
- Installation
- Environment Variables
- Usage
- API Endpoints
- Folder Structure
- Docker Deployment
- Contributing
- License
AR CDN is a robust and flexible file upload service designed for handling various types of files, including images, videos, and audio. Built using TypeScript, this project emphasizes a clean directory structure and ease of use. With simple installation steps and a development server setup, users can quickly integrate file uploading functionality into their applications.
- File Uploads - Support for images, videos, audio, and documents
- Type Checking - Built with TypeScript for type safety
- RESTful API - Easy integration with your applications
- Image Processing - Resize, optimize, and convert images
- Admin Dashboard - Monitor and manage uploaded files
- Authentication - Secure your uploads with API keys
- Access Control - Public and private file options
- Rate Limiting - Prevent abuse of your CDN
- Responsive UI - Clean interface for upload and management
- Backend: Node.js, Express.js, TypeScript
- Frontend: Handlebars, TailwindCSS, DaisyUI
- Database: File system (with metadata tracking)
- File Processing: Multer, Sharp
- Security: Helmet, CORS, Rate limiting
- Logging: Winston, Morgan
- Clone the repository
git clone https://github.com/Arifzyn19/AR-CDN.git
cd AR-CDN
- Install dependencies
npm install
- Build the project
npm run build:all
- Start the development server
npm run dev
Create a .env
file in the root directory with the following variables:
PORT=3000
NODE_ENV=development
UPLOAD_DIR=uploads
MAX_FILE_SIZE=10485760
ALLOWED_ORIGINS=http://localhost:3000,https://yourdomain.com
API_KEY_SECRET=your-secret-key
- Navigate to
http://localhost:3000
in your browser - Use the upload form to select and upload files
- View and manage your uploads through the dashboard
// Example: Upload a file using fetch
const form = new FormData();
form.append('file', fileInput.files[0]);
fetch('http://localhost:3000/api/upload', {
method: 'POST',
headers: {
'X-API-KEY': 'your-api-key'
},
body: form
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Endpoint | Method | Description | Auth Required |
---|---|---|---|
/api/upload |
POST | Upload a file | Yes |
/api/files |
GET | List all files | Yes |
/api/files/:id |
GET | Get file details | Yes |
/api/files/:id |
DELETE | Delete a file | Yes |
/api/stats |
GET | Get storage statistics | Yes |
/files/:filename |
GET | Serve a file | No |
/images/:filename |
GET | Serve an image with processing options | No |
AR-CDN/
├── src/
│ ├── config/ # Configuration files
│ ├── controllers/ # Route controllers
│ ├── middlewares/ # Express middlewares
│ ├── routes/ # API routes
│ ├── services/ # Business logic
│ ├── types/ # TypeScript type definitions
│ ├── utils/ # Utility functions
│ ├── styles/ # CSS styles
│ └── index.ts # Application entry point
├── public/ # Static assets
├── uploads/ # Uploaded files directory
├── views/ # Handlebars templates
├── tests/ # Test files
├── dist/ # Compiled JavaScript
└── docker/ # Docker configuration
Build and run the Docker container:
# Build the Docker image
npm run docker:build
# Run the container
npm run docker:run
Or use Docker Compose:
docker-compose up -d
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the ISC License - see the LICENSE file for details.
Made with ❤️ by Arifzyn19