michangarrito/apps/backend/dist/modules/billing/billing.controller.js
rckrdmrd 48dea7a5d0 feat: Initial commit - michangarrito
Marketplace móvil para negocios locales mexicanos.

Estructura inicial:
- apps/backend (NestJS API)
- apps/frontend (React Web)
- apps/mobile (Expo/React Native)
- apps/mcp-server (Claude MCP Server)
- apps/whatsapp-service (WhatsApp Business API)
- database/ (PostgreSQL DDL)
- docs/ (Documentación)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 04:41:02 -06:00

113 lines
5.1 KiB
JavaScript

"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BillingController = void 0;
const common_1 = require("@nestjs/common");
const jwt_auth_guard_1 = require("../auth/guards/jwt-auth.guard");
const billing_service_1 = require("./billing.service");
let BillingController = class BillingController {
constructor(billingService) {
this.billingService = billingService;
}
async getPlans() {
return this.billingService.getPlans();
}
async getTokenPackages() {
return this.billingService.getTokenPackages();
}
async getBillingSummary(req) {
return this.billingService.getBillingSummary(req.user.tenantId);
}
async getTokenBalance(req) {
const balance = await this.billingService.getTokenBalance(req.user.tenantId);
return balance || { availableTokens: 0, usedTokens: 0, totalTokens: 0 };
}
async getTokenUsage(req, limit) {
return this.billingService.getTokenUsageHistory(req.user.tenantId, limit ? parseInt(limit, 10) : 50);
}
async createSubscriptionCheckout(req, body) {
return this.billingService.createSubscriptionCheckout(req.user.tenantId, body.planCode, body.successUrl, body.cancelUrl);
}
async createTokenCheckout(req, body) {
return this.billingService.createTokenPurchaseCheckout(req.user.tenantId, body.packageCode, body.successUrl, body.cancelUrl);
}
async createPortalSession(req, body) {
return this.billingService.createPortalSession(req.user.tenantId, body.returnUrl);
}
};
exports.BillingController = BillingController;
__decorate([
(0, common_1.Get)('plans'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], BillingController.prototype, "getPlans", null);
__decorate([
(0, common_1.Get)('token-packages'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", Promise)
], BillingController.prototype, "getTokenPackages", null);
__decorate([
(0, common_1.Get)('summary'),
__param(0, (0, common_1.Request)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], BillingController.prototype, "getBillingSummary", null);
__decorate([
(0, common_1.Get)('token-balance'),
__param(0, (0, common_1.Request)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", Promise)
], BillingController.prototype, "getTokenBalance", null);
__decorate([
(0, common_1.Get)('token-usage'),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Query)('limit')),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, String]),
__metadata("design:returntype", Promise)
], BillingController.prototype, "getTokenUsage", null);
__decorate([
(0, common_1.Post)('checkout/subscription'),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], BillingController.prototype, "createSubscriptionCheckout", null);
__decorate([
(0, common_1.Post)('checkout/tokens'),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], BillingController.prototype, "createTokenCheckout", null);
__decorate([
(0, common_1.Post)('portal'),
__param(0, (0, common_1.Request)()),
__param(1, (0, common_1.Body)()),
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object, Object]),
__metadata("design:returntype", Promise)
], BillingController.prototype, "createPortalSession", null);
exports.BillingController = BillingController = __decorate([
(0, common_1.Controller)('billing'),
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
__metadata("design:paramtypes", [billing_service_1.BillingService])
], BillingController);
//# sourceMappingURL=billing.controller.js.map