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>
136 lines
5.7 KiB
JavaScript
136 lines
5.7 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.AuthController = void 0;
|
|
const common_1 = require("@nestjs/common");
|
|
const swagger_1 = require("@nestjs/swagger");
|
|
const auth_service_1 = require("./auth.service");
|
|
const register_dto_1 = require("./dto/register.dto");
|
|
const jwt_auth_guard_1 = require("./guards/jwt-auth.guard");
|
|
let AuthController = class AuthController {
|
|
constructor(authService) {
|
|
this.authService = authService;
|
|
}
|
|
async register(dto) {
|
|
return this.authService.register(dto);
|
|
}
|
|
async login(dto) {
|
|
return this.authService.login(dto);
|
|
}
|
|
async refreshToken(dto) {
|
|
return this.authService.refreshToken(dto.refreshToken);
|
|
}
|
|
async changePin(req, body) {
|
|
await this.authService.changePin(req.user.sub, body.currentPin, body.newPin);
|
|
return { message: 'PIN cambiado exitosamente' };
|
|
}
|
|
};
|
|
exports.AuthController = AuthController;
|
|
__decorate([
|
|
(0, common_1.Post)('register'),
|
|
(0, swagger_1.ApiOperation)({
|
|
summary: 'Registrar nuevo negocio',
|
|
description: 'Crea un nuevo tenant y usuario con periodo de prueba de 14 días',
|
|
}),
|
|
(0, swagger_1.ApiResponse)({
|
|
status: 201,
|
|
description: 'Registro exitoso',
|
|
schema: {
|
|
properties: {
|
|
accessToken: { type: 'string' },
|
|
refreshToken: { type: 'string' },
|
|
user: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'string' },
|
|
name: { type: 'string' },
|
|
isOwner: { type: 'boolean' },
|
|
},
|
|
},
|
|
tenant: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'string' },
|
|
businessName: { type: 'string' },
|
|
plan: { type: 'string' },
|
|
subscriptionStatus: { type: 'string' },
|
|
trialEndsAt: { type: 'string', format: 'date-time' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
(0, swagger_1.ApiResponse)({ status: 409, description: 'Teléfono ya registrado' }),
|
|
__param(0, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [register_dto_1.RegisterDto]),
|
|
__metadata("design:returntype", Promise)
|
|
], AuthController.prototype, "register", null);
|
|
__decorate([
|
|
(0, common_1.Post)('login'),
|
|
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
(0, swagger_1.ApiOperation)({
|
|
summary: 'Iniciar sesión',
|
|
description: 'Autenticación con teléfono y PIN',
|
|
}),
|
|
(0, swagger_1.ApiResponse)({
|
|
status: 200,
|
|
description: 'Login exitoso',
|
|
}),
|
|
(0, swagger_1.ApiResponse)({ status: 401, description: 'Credenciales inválidas' }),
|
|
__param(0, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [register_dto_1.LoginDto]),
|
|
__metadata("design:returntype", Promise)
|
|
], AuthController.prototype, "login", null);
|
|
__decorate([
|
|
(0, common_1.Post)('refresh'),
|
|
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
(0, swagger_1.ApiOperation)({
|
|
summary: 'Refrescar token',
|
|
description: 'Obtiene un nuevo access token usando el refresh token',
|
|
}),
|
|
(0, swagger_1.ApiResponse)({
|
|
status: 200,
|
|
description: 'Token refrescado exitosamente',
|
|
}),
|
|
(0, swagger_1.ApiResponse)({ status: 401, description: 'Token inválido o expirado' }),
|
|
__param(0, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [register_dto_1.RefreshTokenDto]),
|
|
__metadata("design:returntype", Promise)
|
|
], AuthController.prototype, "refreshToken", null);
|
|
__decorate([
|
|
(0, common_1.Post)('change-pin'),
|
|
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
|
(0, swagger_1.ApiBearerAuth)(),
|
|
(0, common_1.HttpCode)(common_1.HttpStatus.OK),
|
|
(0, swagger_1.ApiOperation)({
|
|
summary: 'Cambiar PIN',
|
|
description: 'Cambiar el PIN de acceso',
|
|
}),
|
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'PIN cambiado exitosamente' }),
|
|
(0, swagger_1.ApiResponse)({ status: 401, description: 'PIN actual incorrecto' }),
|
|
__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)
|
|
], AuthController.prototype, "changePin", null);
|
|
exports.AuthController = AuthController = __decorate([
|
|
(0, swagger_1.ApiTags)('auth'),
|
|
(0, common_1.Controller)('v1/auth'),
|
|
__metadata("design:paramtypes", [auth_service_1.AuthService])
|
|
], AuthController);
|
|
//# sourceMappingURL=auth.controller.js.map
|