gatewate dinamico
This commit is contained in:
parent
5883a2bdc2
commit
69587c2954
26
package-lock.json
generated
26
package-lock.json
generated
@ -25,6 +25,7 @@
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.13.2",
|
||||
"csvtojson": "^2.0.10",
|
||||
"dotenv": "^16.0.3",
|
||||
"moment": "^2.29.4",
|
||||
"mysql2": "^2.3.3",
|
||||
"nodemailer": "^6.7.8",
|
||||
@ -1561,6 +1562,14 @@
|
||||
"rxjs": "^6.0.0 || ^7.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/config/node_modules/dotenv": {
|
||||
"version": "16.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.1.tgz",
|
||||
"integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/config/node_modules/uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
@ -3960,9 +3969,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.1.tgz",
|
||||
"integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ==",
|
||||
"version": "16.0.3",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
|
||||
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
@ -10794,6 +10803,11 @@
|
||||
"uuid": "8.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": {
|
||||
"version": "16.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.1.tgz",
|
||||
"integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ=="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
@ -12602,9 +12616,9 @@
|
||||
}
|
||||
},
|
||||
"dotenv": {
|
||||
"version": "16.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.1.tgz",
|
||||
"integrity": "sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ=="
|
||||
"version": "16.0.3",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
|
||||
"integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
|
||||
},
|
||||
"dotenv-expand": {
|
||||
"version": "8.0.3",
|
||||
|
@ -37,6 +37,7 @@
|
||||
"class-transformer": "^0.5.1",
|
||||
"class-validator": "^0.13.2",
|
||||
"csvtojson": "^2.0.10",
|
||||
"dotenv": "^16.0.3",
|
||||
"moment": "^2.29.4",
|
||||
"mysql2": "^2.3.3",
|
||||
"nodemailer": "^6.7.8",
|
||||
|
@ -1,3 +1,4 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
import {
|
||||
WebSocketGateway,
|
||||
OnGatewayInit,
|
||||
@ -7,17 +8,10 @@ import {
|
||||
} from '@nestjs/websockets';
|
||||
import { Socket, Server } from 'socket.io';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@WebSocketGateway({
|
||||
cors: {
|
||||
origin: [
|
||||
// 'http://localhost:3176',
|
||||
// 'http://localhost:3186',
|
||||
'https://pmodulospcpuma.unam.mx',
|
||||
'https://pmodulospcpuma.unam.mx:3015',
|
||||
// 'https://modulospcpuma.unam.mx',
|
||||
// 'https://modulospcpuma.unam.mx:3015',
|
||||
],
|
||||
},
|
||||
cors: { origin: [process.env.USUARIO_FRONT, process.env.OPERADOR_FRONT] },
|
||||
})
|
||||
export class AppGateway
|
||||
implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect
|
||||
|
@ -23,4 +23,5 @@ async function bootstrap() {
|
||||
});
|
||||
await app.listen(process.env.API_PORT);
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
|
36
src/operador/gateway/operador.gateway.ts
Normal file
36
src/operador/gateway/operador.gateway.ts
Normal file
@ -0,0 +1,36 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
import {
|
||||
WebSocketGateway,
|
||||
OnGatewayInit,
|
||||
WebSocketServer,
|
||||
OnGatewayConnection,
|
||||
OnGatewayDisconnect,
|
||||
} from '@nestjs/websockets';
|
||||
import { Socket, Server } from 'socket.io';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@WebSocketGateway({ cors: { origin: [process.env.OPERADOR_FRONT] } })
|
||||
export class AppGateway
|
||||
implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect
|
||||
{
|
||||
@WebSocketServer() server: Server;
|
||||
|
||||
actualizarOperador(id_institucion: number) {
|
||||
this.server.emit('actualizar-operador', { id_institucion });
|
||||
}
|
||||
|
||||
equiposNuevos(id_institucion: number, data) {
|
||||
this.server.emit('equipos-nuevos', { id_institucion, data });
|
||||
}
|
||||
|
||||
usuariosNuevos(id_institucion: number, data) {
|
||||
this.server.emit('usuarios-nuevos', { id_institucion, data });
|
||||
}
|
||||
|
||||
afterInit(server: Server) {}
|
||||
|
||||
handleConnection(client: Socket, ...args: any[]) {}
|
||||
|
||||
handleDisconnect(client: Socket) {}
|
||||
}
|
28
src/usuario/gateway/usuario.gateway.ts
Normal file
28
src/usuario/gateway/usuario.gateway.ts
Normal file
@ -0,0 +1,28 @@
|
||||
import * as dotenv from 'dotenv';
|
||||
import {
|
||||
WebSocketGateway,
|
||||
OnGatewayInit,
|
||||
WebSocketServer,
|
||||
OnGatewayConnection,
|
||||
OnGatewayDisconnect,
|
||||
} from '@nestjs/websockets';
|
||||
import { Socket, Server } from 'socket.io';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@WebSocketGateway({ cors: { origin: [process.env.USUARIO_FRONT] } })
|
||||
export class UsuarioGateway
|
||||
implements OnGatewayInit, OnGatewayConnection, OnGatewayDisconnect
|
||||
{
|
||||
@WebSocketServer() server: Server;
|
||||
|
||||
actualizarUsuario(id_usuario: number) {
|
||||
this.server.emit('actualizar-usuario', { id_usuario });
|
||||
}
|
||||
|
||||
afterInit(server: Server) {}
|
||||
|
||||
handleConnection(client: Socket, ...args: any[]) {}
|
||||
|
||||
handleDisconnect(client: Socket) {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user