Pruebas de cors
This commit is contained in:
parent
9683bd4883
commit
bb83aa1482
|
@ -12,6 +12,7 @@
|
||||||
"@nestjs/core": "^8.0.0",
|
"@nestjs/core": "^8.0.0",
|
||||||
"@nestjs/microservices": "^8.4.7",
|
"@nestjs/microservices": "^8.4.7",
|
||||||
"@nestjs/platform-express": "^8.0.0",
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
|
"cors": "^2.8.5",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rxjs": "^7.2.0"
|
"rxjs": "^7.2.0"
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
"@nestjs/core": "^8.0.0",
|
"@nestjs/core": "^8.0.0",
|
||||||
"@nestjs/microservices": "^8.4.7",
|
"@nestjs/microservices": "^8.4.7",
|
||||||
"@nestjs/platform-express": "^8.0.0",
|
"@nestjs/platform-express": "^8.0.0",
|
||||||
|
"cors": "^2.8.5",
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"rxjs": "^7.2.0"
|
"rxjs": "^7.2.0"
|
||||||
|
|
|
@ -34,9 +34,10 @@ export class AppController {
|
||||||
@Body('user_type') user_type: string,
|
@Body('user_type') user_type: string,
|
||||||
@Body('status') status: string,
|
@Body('status') status: string,
|
||||||
@Body('date_entry') date_entry: Date,
|
@Body('date_entry') date_entry: Date,
|
||||||
|
@Body('community_id') community_id:string
|
||||||
) {
|
) {
|
||||||
return this.appService.createGuard(dni, name, last_name, email, phone, password,
|
return this.appService.createGuard(dni, name, last_name, email, phone, password,
|
||||||
user_type, status, date_entry);
|
user_type, status, date_entry,community_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('user/createUser')
|
@Post('user/createUser')
|
||||||
|
|
|
@ -51,11 +51,11 @@ export class AppService {
|
||||||
}
|
}
|
||||||
|
|
||||||
createGuard(dni: string, name: string, last_name: string, email: string, phone: number
|
createGuard(dni: string, name: string, last_name: string, email: string, phone: number
|
||||||
, password: string, user_type: string, status: string, date_entry: Date) {
|
, password: string, user_type: string, status: string, date_entry: Date, community_id: string) {
|
||||||
const pattern = { cmd: 'createGuard' };
|
const pattern = { cmd: 'createGuard' };
|
||||||
const payload = {
|
const payload = {
|
||||||
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
|
dni: dni, name: name, last_name: last_name, email: email, phone: phone,
|
||||||
password: password, user_type: user_type, status: status, date_entry: date_entry
|
password: password, user_type: user_type, status: status, date_entry: date_entry, community_id
|
||||||
};
|
};
|
||||||
return this.clientUserApp
|
return this.clientUserApp
|
||||||
.send<string>(pattern, payload)
|
.send<string>(pattern, payload)
|
||||||
|
|
|
@ -4,6 +4,6 @@ const cors= require('cors');
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
await app.listen(4000);
|
await app.listen(4000);
|
||||||
app.use(cors());
|
app.use(cors())
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"chart.js": "3.3.2",
|
"chart.js": "3.3.2",
|
||||||
"classnames": "^2.2.6",
|
"classnames": "^2.2.6",
|
||||||
|
"cors": "^2.8.5",
|
||||||
"primeflex": "3.1.0",
|
"primeflex": "3.1.0",
|
||||||
"primeicons": "^5.0.0",
|
"primeicons": "^5.0.0",
|
||||||
"primereact": "7.2.0",
|
"primereact": "7.2.0",
|
||||||
|
@ -5183,6 +5184,18 @@
|
||||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
|
||||||
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
|
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
|
||||||
},
|
},
|
||||||
|
"node_modules/cors": {
|
||||||
|
"version": "2.8.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
|
||||||
|
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
|
||||||
|
"dependencies": {
|
||||||
|
"object-assign": "^4",
|
||||||
|
"vary": "^1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">= 0.10"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/cosmiconfig": {
|
"node_modules/cosmiconfig": {
|
||||||
"version": "5.2.1",
|
"version": "5.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz",
|
||||||
|
@ -21869,6 +21882,15 @@
|
||||||
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz",
|
||||||
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
|
"integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ=="
|
||||||
},
|
},
|
||||||
|
"cors": {
|
||||||
|
"version": "2.8.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
|
||||||
|
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
|
||||||
|
"requires": {
|
||||||
|
"object-assign": "^4",
|
||||||
|
"vary": "^1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"cosmiconfig": {
|
"cosmiconfig": {
|
||||||
"version": "5.2.1",
|
"version": "5.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.2.1.tgz",
|
||||||
|
|
|
@ -12,12 +12,15 @@
|
||||||
"@fullcalendar/core": "^5.7.2",
|
"@fullcalendar/core": "^5.7.2",
|
||||||
"@fullcalendar/daygrid": "^5.7.2",
|
"@fullcalendar/daygrid": "^5.7.2",
|
||||||
"@fullcalendar/interaction": "^5.7.2",
|
"@fullcalendar/interaction": "^5.7.2",
|
||||||
"@fullcalendar/timegrid": "^5.7.2",
|
|
||||||
"@fullcalendar/react": "^5.7.0",
|
"@fullcalendar/react": "^5.7.0",
|
||||||
|
"@fullcalendar/timegrid": "^5.7.2",
|
||||||
|
"axios": "^0.19.0",
|
||||||
"chart.js": "3.3.2",
|
"chart.js": "3.3.2",
|
||||||
"primereact": "7.2.0",
|
"classnames": "^2.2.6",
|
||||||
|
"cors": "^2.8.5",
|
||||||
"primeflex": "3.1.0",
|
"primeflex": "3.1.0",
|
||||||
"primeicons": "^5.0.0",
|
"primeicons": "^5.0.0",
|
||||||
|
"primereact": "7.2.0",
|
||||||
"prismjs": "1.9.0",
|
"prismjs": "1.9.0",
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-app-polyfill": "^1.0.6",
|
"react-app-polyfill": "^1.0.6",
|
||||||
|
@ -25,9 +28,7 @@
|
||||||
"react-router-dom": "^5.2.0",
|
"react-router-dom": "^5.2.0",
|
||||||
"react-scripts": "3.4.1",
|
"react-scripts": "3.4.1",
|
||||||
"react-transition-group": "^4.4.1",
|
"react-transition-group": "^4.4.1",
|
||||||
"sass": "^1.32.8",
|
"sass": "^1.32.8"
|
||||||
"axios": "^0.19.0",
|
|
||||||
"classnames": "^2.2.6"
|
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
|
|
|
@ -18,7 +18,7 @@ const GuardasSeguridad = () => {
|
||||||
fetchP();
|
fetchP();
|
||||||
},[])
|
},[])
|
||||||
|
|
||||||
function registrarAdmin() {
|
function registrarGuarda() {
|
||||||
var data = {
|
var data = {
|
||||||
dni: document.getElementById('identificacion').value,
|
dni: document.getElementById('identificacion').value,
|
||||||
name: document.getElementById('nombre').value,
|
name: document.getElementById('nombre').value,
|
||||||
|
@ -26,15 +26,27 @@ const GuardasSeguridad = () => {
|
||||||
email: document.getElementById('correo_electronico').value,
|
email: document.getElementById('correo_electronico').value,
|
||||||
phone: document.getElementById('telefono').value,
|
phone: document.getElementById('telefono').value,
|
||||||
password: document.getElementById('correo_electronico').value,
|
password: document.getElementById('correo_electronico').value,
|
||||||
user_type: "1", //1 es admin
|
user_type: "4", //4 es guarda
|
||||||
status: "1"
|
status: "1",
|
||||||
|
community_id:"62be68215692582bbfd77134"
|
||||||
};
|
};
|
||||||
// console.log(data);
|
var data2={
|
||||||
|
dni: "98765",
|
||||||
|
name: "Danielito",
|
||||||
|
last_name: "Rodriguez",
|
||||||
|
email: "danirodriguez@gmail.com",
|
||||||
|
phone: 84664515,
|
||||||
|
password: "1203",
|
||||||
|
user_type: "2",
|
||||||
|
status: "4",
|
||||||
|
community_id:"62be68215692582bbfd77134"
|
||||||
|
}
|
||||||
|
console.log(data2);
|
||||||
|
|
||||||
fetch('http://localhost:4000/user/createAdminSystem/', {
|
fetch('http://localhost:4000/user/createGuard', {
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data2),
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
|
@ -73,7 +85,7 @@ const GuardasSeguridad = () => {
|
||||||
</div>
|
</div>
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<h5>Registro de un administrador del sistema</h5>
|
<h5>Registro de un guarda de seguridad</h5>
|
||||||
<div className="p-fluid formgrid grid">
|
<div className="p-fluid formgrid grid">
|
||||||
<div className="field col-12 md:col-6">
|
<div className="field col-12 md:col-6">
|
||||||
<label htmlFor="nombre">Nombre</label>
|
<label htmlFor="nombre">Nombre</label>
|
||||||
|
@ -95,7 +107,7 @@ const GuardasSeguridad = () => {
|
||||||
<label htmlFor="telefono">Teléfono</label>
|
<label htmlFor="telefono">Teléfono</label>
|
||||||
<InputText id="telefono" type="number" rows="4" />
|
<InputText id="telefono" type="number" rows="4" />
|
||||||
</div>
|
</div>
|
||||||
<Button label="Registrar" onClick={registrarAdmin}></Button>
|
<Button label="Registrar" onClick={registrarGuarda}></Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue