Files
TokenWatch/dist/server.js
T
Jannik eaec6ed5c8
Build and Push Docker Image / build-and-push (push) Canceled after 0s
feat: complete TokenWatch implementation with Docker, GH actions, and Live Sync
2026-08-28 16:35:08 +02:00

49 lines
1.8 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = __importDefault(require("express"));
const path_1 = __importDefault(require("path"));
const db_1 = require("./services/db");
const providers_1 = require("./services/providers");
require("./cron"); // Start the cron jobs
const app = (0, express_1.default)();
const PORT = process.env.PORT || 3000;
app.use(express_1.default.static(path_1.default.join(__dirname, '../public')));
app.use(express_1.default.json());
app.get('/api/quotas', async (req, res) => {
try {
const quotas = await (0, providers_1.fetchAllQuotas)();
res.json(quotas);
}
catch (error) {
console.error('Error fetching quotas:', error);
res.status(500).json({ error: 'Internal Server Error' });
}
});
app.get('/api/history', async (req, res) => {
try {
const history = await (0, db_1.getQuotaHistory)();
res.json(history);
}
catch (error) {
console.error('Error fetching history:', error);
res.status(500).json({ error: 'Internal Server Error' });
}
});
app.post('/api/webhook/antigravity', (req, res) => {
try {
const { updateAntigravityQuota } = require('./services/providers');
updateAntigravityQuota(req.body);
res.json({ success: true, message: 'Antigravity quota updated' });
}
catch (error) {
console.error('Error updating Antigravity via webhook:', error);
res.status(500).json({ error: 'Failed to update' });
}
});
app.listen(PORT, () => {
console.log(`TokenWatch server running on port ${PORT}`);
});
//# sourceMappingURL=server.js.map