se agregó implementacion de Api para ampliación
This commit is contained in:
@@ -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=
|
||||
|
||||
Generated
+1897
-1558
File diff suppressed because it is too large
Load Diff
@@ -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';
|
||||
|
||||
@@ -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
|
||||
|
||||
+1
-5
@@ -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
@@ -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: [
|
||||
|
||||
@@ -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])],
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user