se agregó implementacion de Api para ampliación

This commit is contained in:
2025-08-19 12:16:17 -06:00
parent d6f28003b3
commit 0aa0d514cb
9 changed files with 1936 additions and 1574 deletions
+4
View File
@@ -24,3 +24,7 @@ PORT_TYL=3306
USUARIO_TYL=usr_tl
CONTRASENA_TYL=A1m_p@$
DATABASE_TYL=Betelgeuse_TL_test
#Funciones para la api
API_URL=
TOKEN=
+1897 -1558
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,6 +1,6 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Almacenamiento } from '../entities/almacenamiento.entity';
import { Almacenamiento } from './entity/almacenamiento.entity';
import { AlmacenamientoService } from './almacenamiento.service';
import { AlmacenamientoController } from './almacenamiento.controller';
import { ConfigModule, ConfigService } from '@nestjs/config';
+29 -6
View File
@@ -1,7 +1,7 @@
import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { Almacenamiento } from '../entities/almacenamiento.entity';
import { Almacenamiento } from './entity/almacenamiento.entity';
@Injectable()
export class AlmacenamientoService {
@@ -11,13 +11,36 @@ export class AlmacenamientoService {
) {}
// Example method to create a new record
async create(correo: string): Promise<Almacenamiento> {
async create(correo: string): Promise<void> {
const existente = await this.almacenamientoRepository.findOneBy({ correo });
if (existente) {
return existente; // o lanzar un error si prefieres
if (!existente) {
throw new Error("Este usuario no tiene acceso")
}
const nuevo = this.almacenamientoRepository.create({ correo });
return this.almacenamientoRepository.save(nuevo);
const apiUrl = process.env.API_URL;
const entrada = {
user_name: "acatlan",
email: correo
};
try{
let resonse= fetch(apiUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${process.env.TOKEN}`
},
body: JSON.stringify(entrada)
})
return
}catch(error){
throw new Error(error)
}
}
// Example method to get all records
@@ -8,9 +8,5 @@ export class Almacenamiento {
@Column('varchar', { name: 'correo', length: 100 })
correo: string;
@Column('timestamp', {
name: 'fecha_ampliacion',
default: () => 'CURRENT_TIMESTAMP',
})
fechaAmpliacion: Date;
}
+2 -2
View File
@@ -49,11 +49,11 @@ import { MulterModule } from '@nestjs/platform-express';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
import { CarruselModule } from './carrusel/carrusel.module';
import { Carrusel } from './entities/carrusel.entity';
import { Carrusel } from './carrusel/entity/carrusel.entity';
import { ComentariosModule } from './comentarios/comentarios.module';
import { Comentarios } from './comentarios/entity/comentarios.entity';
import { AlmacenamientoModule } from './almacenamiento/almacenamiento.module';
import { Almacenamiento } from './entities/almacenamiento.entity';
import { Almacenamiento } from './almacenamiento/entity/almacenamiento.entity';
@Module({
imports: [
+1 -1
View File
@@ -2,7 +2,7 @@ import { Module } from '@nestjs/common';
import { CarruselController } from './carrusel.controller';
import { CarruselService } from './carrusel.service';
import { TypeOrmModule } from '@nestjs/typeorm';
import { Carrusel } from 'src/entities/carrusel.entity';
import { Carrusel } from 'src/carrusel/entity/carrusel.entity';
@Module({
imports: [TypeOrmModule.forFeature([Carrusel])],
+1 -1
View File
@@ -4,7 +4,7 @@ import {
InternalServerErrorException,
} from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Carrusel } from 'src/entities/carrusel.entity';
import { Carrusel } from 'src/carrusel/entity/carrusel.entity';
import { Repository } from 'typeorm';
import { carruselDto } from './dto/carruselDto.dto';
import * as fs from 'fs';