ImgBin is a web app that allows users to temporarily upload and manage images. It leverages Cloudinary for the storage and uses NSFWJS or Google Vision API for image moderation.
- Clone the repository:
git clone https://github.com/SlavyanDesu/ImgBin.git
- Navigate to the project directory:
cd ImgBin
- Install the dependencies:
npm install
- Set up environment variables:
CLOUDINARY_CLOUD_NAME="your-cloud-name"
CLOUDINARY_API_KEY="your-api-key"
CLOUDINARY_API_SECRET="your-api-secret"
PORT=3000
DATABASE_URL="postgresql://your-neondb:url@ep-cool-darkness-a1b2c3d4-pooler.us-east-2.aws.neon.tech/dbname?sslmode=require"
GOOGLE_APPLICATION_CREDENTIALS="./key/your-gcp-key.json"
MODERATION="nsfwjs"
CLEANUP_SECRET="your-cleanup-secret"
MODERATION
can be eithernsfwjs
orgoogle-vision
.- If you choose
google-vision
, you must set up a Google Cloud Project, enable the Vision API, and download the service account JSON key. - Google Cloud Vision API may require billing activation. See Google's Documentation for details.
- Build the application:
npm run build
- The compiled files will be in
dist/
directory.
To start the application, run:
npm start
Visit http://localhost:3000 in your browser to access the app.
- Temporary image hosting with expiration
- A simple and intuitive UI
- Cookie-based validation for image deletion (only the uploader can delete)
- Responsive design for mobile and desktop
- Image moderation using NSFWJS or Google Cloud Vision API
- Node.js
- Express.js
- NSFWJS
- Google Cloud Vision
- Cloudinary
- Prisma ORM
- NeonDB
- TypeScript
- EJS
- GitHub Action
- POST
/upload
- Request Body: Form data containing the file to upload.
- Response example:
{
"success": true,
"url": "https://res.cloudinary.com/abcd/image/upload/v1741948827/1741948783559-picture.png",
"publicId": "1741948783559-picture",
"message": "File deleted successfully"
}
- DELETE
/delete/:publicId
- Parameters:
publicId
of the file to delete. - Response example:
{
"success": true,
"message": "File deleted successfully"
}
- GET
/files
- Response: Renders a page displaying uploaded images.
- GET
/api/cleanup?token=YOUR_SECRET_TOKEN
- Description: Deletes files older than 3 days from both Cloudinary and the database.
- Authorization: Requires a valid token via query parameter
token
. - Response example (success):
{
"success": true,
"message": "Deleted 3 files"
}
- Response example (unauthorized):
{
"message": "Forbidden"
}
- Response example (error):
{
"success": false,
"message": "An error occurred during cleanup."
}
Note: This endpoint is intended to be triggered programmatically (e.g., via a cron job or GitHub Action). Do not expose your secret token publicly.
This project is licensed under the MIT License. See the LICENSE file for details.