A modern serverless API for managing VIP subscriptions with automatic webhook notifications. Built to run on Vercel with MongoDB as the database.
- β Create, query, and delete VIP subscriptions
- β° Automatic processing of expired VIPs
- π Webhook notifications (optional)
- π API health endpoint
- π Flexible CORS configuration
- π Pagination for VIP listings
- Node.js 18+
- Vercel account
- MongoDB database (we recommend MongoDB Atlas)
git clone <https://github.com/CachorroninjaBot/Vip-api>
cd vipapi-vercel
npm install
cp .env.example .envEdit the .env file:
# Required
MONGODB_URI=mongodb+srv://username:[email protected]/database
# Optional (for webhooks)
WEBHOOK_URL=https://your-webhook-url.com/endpoint
WEBHOOK_AUTH=your-auth-token
# Production (optional)
ALLOWED_ORIGINS=https://yourdomain.com,https://app.yourdomain.com# Via CLI
npm i -g vercel
vercel
vercel env add MONGODB_URI
# Or via web interface at vercel.comGET /api/healthChecks API status and database connection.
POST /api/vip
Content-Type: application/json
{
"userId": "user123",
"timestamp": 1672531200,
"plano": "Premium"
}GET /api/vip/user123GET /api/vips?page=1&limit=10DELETE /api/vip/user123POST /api/check-expired{
"message": "VIP purchase recorded successfully",
"vip": {
"userId": "user123",
"timestamp": 1672531200,
"plano": "Premium",
"expiresAt": "2023-01-01T00:00:00.000Z"
}
}{
"userId": "user123",
"timestamp": 1672531200,
"plano": "Premium",
"expiresAt": "2023-01-01T00:00:00.000Z",
"isActive": true
}{
"error": "VIP subscription not found for this user"
}Since Vercel doesn't support native cron jobs (except on Pro plan), you can automate expired VIP checks using:
name: Check Expired VIPs
on:
schedule:
- cron: '*/30 * * * *' # Every 30 minutes
jobs:
check-expired:
runs-on: ubuntu-latest
steps:
- name: Check Expired VIPs
run: |
curl -X POST https://your-api.vercel.app/api/check-expired- cron-job.org (free)
- EasyCron
{
"crons": [{
"path": "/api/check-expired",
"schedule": "*/30 * * * *"
}]
}βββββββββββββββββββ ββββββββββββββββ βββββββββββββββ
β Client App βββββΆβ Vercel API βββββΆβ MongoDB β
βββββββββββββββββββ ββββββββββββββββ βββββββββββββββ
β
βΌ
ββββββββββββββββ
β Webhook β
β(Notifications)β
ββββββββββββββββ
- β Strict input data validation
- β Parameter sanitization
- β Flexible CORS configuration
- β Webhook request timeouts
- β Detailed logs for auditing
vercel logs --followAccess Vercel dashboard β Functions β Logs
| Aspect | Hobby Plan | Pro Plan |
|---|---|---|
| Timeout | 10 seconds | 60 seconds |
| Cron Jobs | β | β |
| Cold Start | ~1-3 seconds | ~1-3 seconds |
- Fork the project
- Create your feature branch (
git checkout -b feature/awesome-feature) - Commit your changes (
git commit -am 'Add: awesome feature') - Push to the branch (
git push origin feature/awesome-feature) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
Found a bug? Open an issue or check the Vercel documentation.
Made with β€οΈ for the community