Controllers
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
DB_USERNAME=
|
||||
DB_DATABASE=
|
||||
DB_PASSWORD=
|
||||
DB_PORT=
|
||||
DB_HOST=
|
||||
PORT=
|
||||
JWT=
|
||||
CARPETA=
|
||||
MAIL_URL=
|
||||
MAIL_TOKEN=
|
||||
ESCOLARES=
|
||||
ESCOLARES_PASS=
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
"scripts": {
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start": "source ~/.nvm/nvm.sh && nvm use 22.10.0 && npm install && nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
|
||||
+25
-29
@@ -17,12 +17,10 @@ import { UsuarioModule } from './usuario/usuario.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot(
|
||||
{isGlobal: true}
|
||||
),
|
||||
|
||||
ConfigModule.forRoot({ isGlobal: true }),
|
||||
|
||||
TypeOrmModule.forRoot({
|
||||
type: 'mysql',
|
||||
type: 'mysql',
|
||||
host: process.env.db_host,
|
||||
username: process.env.db_username,
|
||||
database: process.env.db_database,
|
||||
@@ -31,32 +29,30 @@ import { UsuarioModule } from './usuario/usuario.module';
|
||||
synchronize: true,
|
||||
dropSchema: false, // elimina la base de datos
|
||||
// logging: true, // Habilita los logs para depuración
|
||||
autoLoadEntities: true, // Carga automáticamente las entidades
|
||||
|
||||
autoLoadEntities: false, // Carga automáticamente las entidades
|
||||
}),
|
||||
|
||||
CarreraModule,
|
||||
|
||||
CasoEspecialModule,
|
||||
|
||||
CuestionarioAlumnoModule,
|
||||
|
||||
CuestionarioAlumno2Module,
|
||||
|
||||
CuestionarioProgramaModule,
|
||||
|
||||
CuestionarioPrograma2Module,
|
||||
|
||||
ProgramaModule,
|
||||
|
||||
ServicioModule,
|
||||
|
||||
StatusModule,
|
||||
|
||||
TipoUsuarioModule,
|
||||
|
||||
UsuarioModule,
|
||||
|
||||
CarreraModule,
|
||||
|
||||
CasoEspecialModule,
|
||||
|
||||
CuestionarioAlumnoModule,
|
||||
|
||||
CuestionarioAlumno2Module,
|
||||
|
||||
CuestionarioProgramaModule,
|
||||
|
||||
CuestionarioPrograma2Module,
|
||||
|
||||
ProgramaModule,
|
||||
|
||||
ServicioModule,
|
||||
|
||||
StatusModule,
|
||||
|
||||
TipoUsuarioModule,
|
||||
|
||||
UsuarioModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { JwtModule } from '@nestjs/jwt';
|
||||
import { JwtModule, JwtService } from '@nestjs/jwt';
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AuthService } from './auth.service';
|
||||
import { Usuario } from 'src/usuario/entities/usuario.entity';
|
||||
|
||||
@@ -7,7 +7,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
|
||||
constructor() {
|
||||
super({
|
||||
jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
|
||||
secretOrKey: process.env.JWT_SECRET,
|
||||
secretOrKey: process.env.JWT,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Carrera } from './entities/carrera.entity';
|
||||
|
||||
@Module({
|
||||
controllers: [],
|
||||
providers: [],
|
||||
exports: [],
|
||||
imports: [TypeOrmModule.forFeature([Carrera])],
|
||||
exports: [TypeOrmModule],
|
||||
})
|
||||
export class CarreraModule {}
|
||||
|
||||
@@ -16,6 +16,7 @@ import { DriveService } from 'src/drive/drive.service';
|
||||
import { Status } from 'src/status/entities/status.entity';
|
||||
import { FilterCasoEspecialDto } from './dto/filter-caso-especial.dto';
|
||||
import { arch } from 'os';
|
||||
import { SendMailDto } from 'src/helpers.services/dto/send-email.dto';
|
||||
|
||||
@Injectable()
|
||||
export class CasoEspecialService {
|
||||
@@ -181,7 +182,7 @@ export class CasoEspecialService {
|
||||
idStatus: caso.status.idStatus === 11 ? 13 : 14,
|
||||
};
|
||||
|
||||
let sendcorreo = {
|
||||
let sendMessage: SendMailDto = {
|
||||
to: caso.correo,
|
||||
|
||||
subject: correo.subject,
|
||||
@@ -193,7 +194,7 @@ export class CasoEspecialService {
|
||||
};
|
||||
|
||||
// Envía correo
|
||||
await this.gmail.enviarCorreo(sendcorreo);
|
||||
await this.gmail.enviarCorreo(sendMessage);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
|
||||
@@ -1,9 +1,27 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ProgramaService } from './programa.service';
|
||||
import { ProgramaController } from './programa.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Programa } from './entities/programa.entity';
|
||||
import { Usuario } from 'src/usuario/entities/usuario.entity';
|
||||
import { UsuarioModule } from 'src/usuario/usuario.module';
|
||||
import { ValidacionService } from 'src/helpers.services/validacion.service';
|
||||
import { AuthService } from 'src/auth/auth.service';
|
||||
import { gmail } from 'src/helpers.services/gmail.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
import { JwtService } from '@nestjs/jwt';
|
||||
import { Servicio } from 'src/servicio/entities/servicio.entity';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Programa, Servicio]), UsuarioModule],
|
||||
controllers: [ProgramaController],
|
||||
providers: [ProgramaService],
|
||||
providers: [
|
||||
ProgramaService,
|
||||
AuthService,
|
||||
ValidacionService,
|
||||
gmail,
|
||||
JwtService,
|
||||
],
|
||||
exports: [TypeOrmModule],
|
||||
})
|
||||
export class ProgramaModule {}
|
||||
|
||||
@@ -92,10 +92,6 @@ export class ProgramaService {
|
||||
fecha_recibido: new Date(),
|
||||
};
|
||||
|
||||
if (!process.env.TOKEN_GMAIL) {
|
||||
throw new Error('No existe el token');
|
||||
}
|
||||
|
||||
try {
|
||||
responsable = await this.usuarioRepo.save(responsable);
|
||||
|
||||
|
||||
@@ -8,9 +8,19 @@ import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Servicio } from './entities/servicio.entity';
|
||||
import { Usuario } from 'src/usuario/entities/usuario.entity';
|
||||
import { ArchivoService } from 'src/helpers.services/archivo.service';
|
||||
import { UsuarioModule } from 'src/usuario/usuario.module';
|
||||
import { ProgramaModule } from 'src/programa/programa.module';
|
||||
import { Programa } from 'src/programa/entities/programa.entity';
|
||||
import { Carrera } from 'src/carrera/entities/carrera.entity';
|
||||
import { Auth } from 'googleapis';
|
||||
import { AuthService } from 'src/auth/auth.service';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Servicio, Usuario])],
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([Servicio, Usuario, Programa, Carrera]),
|
||||
AuthModule,
|
||||
],
|
||||
controllers: [ServicioController],
|
||||
providers: [
|
||||
ServicioService,
|
||||
@@ -19,5 +29,6 @@ import { ArchivoService } from 'src/helpers.services/archivo.service';
|
||||
gmail,
|
||||
ArchivoService,
|
||||
],
|
||||
exports: [TypeOrmModule],
|
||||
})
|
||||
export class ServicioModule {}
|
||||
|
||||
@@ -230,10 +230,6 @@ export class ServicioService {
|
||||
adjuntos: undefined,
|
||||
};
|
||||
|
||||
if (!process.env.TOKEN_GMAIL) {
|
||||
throw new Error('No existe el token');
|
||||
}
|
||||
|
||||
if (servicio.correo) {
|
||||
await this.gmailService.enviarCorreo(sendCorreoAlumnoDto);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { StatusService } from './status.service';
|
||||
import { StatusController } from './status.controller';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { Status } from './entities/status.entity';
|
||||
|
||||
@Module({
|
||||
imports: [TypeOrmModule.forFeature([Status])],
|
||||
controllers: [StatusController],
|
||||
providers: [StatusService],
|
||||
})
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
|
||||
import { TipoUsuarioService } from './tipo-usuario.service';
|
||||
import { CreateTipoUsuarioDto } from './dto/create-tipo-usuario.dto';
|
||||
import { UpdateTipoUsuarioDto } from './dto/update-tipo-usuario.dto';
|
||||
|
||||
@Controller('tipo-usuario')
|
||||
export class TipoUsuarioController {
|
||||
constructor(private readonly tipoUsuarioService: TipoUsuarioService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() createTipoUsuarioDto: CreateTipoUsuarioDto) {
|
||||
return this.tipoUsuarioService.create(createTipoUsuarioDto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll() {
|
||||
return this.tipoUsuarioService.findAll();
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.tipoUsuarioService.findOne(+id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() updateTipoUsuarioDto: UpdateTipoUsuarioDto) {
|
||||
return this.tipoUsuarioService.update(+id, updateTipoUsuarioDto);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.tipoUsuarioService.remove(+id);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,23 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { UsuarioService } from './usuario.service';
|
||||
import { UsuarioController } from './usuario.controller';
|
||||
import { Usuario } from './entities/usuario.entity';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { CarreraModule } from 'src/carrera/carrera.module';
|
||||
import { ServicioModule } from 'src/servicio/servicio.module';
|
||||
import { gmail } from 'src/helpers.services/gmail.service';
|
||||
import { Auth } from 'googleapis';
|
||||
import { AuthModule } from 'src/auth/auth.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([Usuario]),
|
||||
CarreraModule,
|
||||
ServicioModule,
|
||||
AuthModule,
|
||||
],
|
||||
controllers: [UsuarioController],
|
||||
providers: [UsuarioService],
|
||||
providers: [UsuarioService, gmail],
|
||||
exports: [TypeOrmModule],
|
||||
})
|
||||
export class UsuarioModule {}
|
||||
|
||||
@@ -59,17 +59,22 @@ export class UsuarioService {
|
||||
async escolares(numeroDeCuenta: string) {
|
||||
let response;
|
||||
try {
|
||||
response = await axios.post(
|
||||
`${process.env.ESCOLARES}${numeroDeCuenta}`,
|
||||
{ password: process.env.ESCOLARES_PASS },
|
||||
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json', // Tipo de contenido
|
||||
Authorization: `Bearer ${process.env.API_TOKEN}`, // Header de auth
|
||||
},
|
||||
},
|
||||
);
|
||||
if (process.env.MODE == 'pruebas') {
|
||||
response = new Promise((res) => {
|
||||
res({
|
||||
data: {
|
||||
nombre: 'nombre',
|
||||
carrconst: 'Carrera',
|
||||
avance: '80',
|
||||
},
|
||||
});
|
||||
});
|
||||
} else {
|
||||
response = await axios.post(
|
||||
`${process.env.ESCOLARES}${numeroDeCuenta}`,
|
||||
{ password: process.env.ESCOLARES_PASS },
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
throw new UnauthorizedException(
|
||||
'No se pudo conectar con el servicio de escolares',
|
||||
|
||||
Reference in New Issue
Block a user