├── clase 9 ├── x ├── package.json ├── public │ ├── prueba │ │ └── index.html │ └── index.html ├── 01-router.js ├── public2 │ └── index.html ├── 02-router.js ├── 03-router.js ├── 04-static.js └── 06-multer.js ├── clase 12 ├── public │ ├── style.css │ ├── ej1 │ │ ├── style.css │ │ ├── index.js │ │ └── index.html │ ├── ej2 │ │ ├── style.css │ │ ├── index.js │ │ └── index.html │ ├── ej3 │ │ ├── style.css │ │ ├── index.html │ │ └── index.js │ ├── indexx.js │ ├── index.html │ ├── indexx.html │ └── index.js ├── package.json ├── 02-sockets.js ├── 03-sockets.js ├── 04-sockets.js ├── 01-nuevo.js └── 01-server.js ├── clase 28 ├── nada.txt ├── 04-argv.js ├── 06-process.execPath.js ├── config │ └── .env ├── child.js ├── 07-stdout.js ├── 03-uncaughtException.js ├── 05-env.js ├── computo.js ├── 14-fork-padre.js ├── package.json ├── 01-global.js ├── 09-exec.js ├── package-lock.json ├── 10-execFile.js ├── 11-spawn.js ├── 02-exit.js ├── 13-fork-no-bloqueante.js ├── 12-bloqueante.js ├── 15-ejercicio.js └── 08-ejercicio.js ├── clase 0 ├── prueba2.js ├── prueba.js ├── valor.js ├── referencia.js ├── ej1.js ├── ej2b.js ├── ej2a.js └── ej2c.js ├── clase 2 ├── 16-globalThis.js ├── 09-bigint.js ├── 12-flatMap.js ├── 05-padding.js ├── typescript │ └── ejemplo │ │ ├── archivo.js │ │ ├── archivo.ts │ │ ├── package.json │ │ ├── tsconfig.json │ │ └── package-lock.json ├── 18-nullish.js ├── 10-matchAll.js ├── 02-expon.js ├── 15-optionalCatch.js ├── 11-flat.js ├── 07-dotall.js ├── 13-fromEntries.js ├── 14-trim.js ├── 04-values.js ├── 06-trailing.js ├── 03-ejemplo.js ├── 01-include.js ├── 19-optionalChaining.js ├── 08-rest.js ├── 17-privateClass.js └── 20-ejemplo.js ├── clase 6 ├── archivos │ ├── fyh.txt │ └── hola.txt ├── 04-unlinksync.js ├── 03-appendsync.js ├── 01-readsync.js ├── 02-writesync.js ├── package.json.coder ├── 14-promiseread.js ├── package.json ├── 05-unlinktry.js ├── 11-mkdir.js ├── 10-unlinkasync.js ├── 07-readasync.js ├── 12-readdir.js ├── 06-ejemplo.js ├── 08-writeasync.js ├── 09-appendasync.js ├── 15-awaitread.js ├── 16-ejemplo.js ├── info.txt └── 13-ejemplo.js ├── clase 14 ├── .babelrc ├── babel │ ├── .babelrc │ ├── origen.js │ ├── salida.js │ └── package.json ├── ts │ ├── index.ts │ ├── index.js │ ├── package.json │ ├── package-lock.json │ ├── 03-color.ts │ └── 03-color.js ├── 01-origen.js ├── ts3 │ ├── index.ts │ ├── index.js │ ├── package.json │ ├── package-lock.json │ ├── 03-color.ts │ └── 03-color.js ├── origen-es5.js ├── ts2 │ ├── lib │ │ ├── operaciones.ts │ │ └── operaciones.js │ ├── package-lock.json │ ├── package.json │ ├── dist │ │ └── lib │ │ │ └── operaciones.js │ ├── index.ts │ └── index.js ├── package.json └── 02-color.js ├── clase 30 ├── public │ ├── estilos.css │ ├── saludo.js │ └── index.html ├── Server01-pm2.json ├── 03-server.js └── 01-server.js ├── clase 11 ├── views │ ├── pages │ │ ├── about.ejs │ │ └── index.ejs │ ├── partials │ │ ├── footer.ejs │ │ ├── head.ejs │ │ └── header.ejs │ ├── hello.pug │ ├── barra-medicion.pug │ ├── barra-medicion.ejs │ └── personas.ejs ├── package.json ├── 01-pug.js ├── 04-ejercicio-ejs.js ├── 02-ejercicio-pug.js ├── 05-ejercicio.js └── 03-ejs.js ├── clase 15 ├── .vscode │ └── settings.json ├── index2.js ├── index3.js ├── index1.js ├── ts │ ├── src │ │ ├── lib │ │ │ ├── functions.js │ │ │ └── classes.ts │ │ └── index.ts │ ├── webpack.config.js │ └── package.json ├── perimetro │ ├── webpack.config.js │ ├── src │ │ └── lib │ │ │ ├── perimetro.ts │ │ │ └── superficie.ts │ └── package.json ├── package.json └── bundle.js ├── clase 27 ├── jwt │ ├── config │ │ └── .env │ ├── package.json │ ├── public │ │ ├── datos.html │ │ ├── index.html │ │ ├── register.html │ │ └── js │ │ │ ├── login.js │ │ │ ├── registrar.js │ │ │ └── datos.js │ └── utils │ │ └── utils.js ├── facebook │ ├── config │ │ └── .env │ ├── public │ │ ├── error-login.html │ │ └── index.html │ ├── package.json │ ├── sslcert │ │ └── req.cnf │ └── routes.js └── twitter │ ├── config │ └── .env │ ├── public │ ├── error-login.html │ └── index.html │ ├── package.json │ └── routes.js ├── clase 5 ├── 01-nodemon.js ├── 02-aleatorios.js ├── 04-server.js ├── 06-edad.js ├── 05-server.js ├── package.json └── 03-array.js ├── clase 10 ├── views │ ├── index.ntp │ ├── main2.hbs │ ├── partials │ │ ├── hatedChamps.hbs │ │ └── lovedChamps.hbs │ ├── main.hbs │ └── layouts │ │ └── index.hbs ├── cte1 │ ├── plantilla1.cte │ └── plantilla2.cte ├── public │ ├── style.css │ ├── indexx.html │ └── personales.html ├── 01-server.js ├── package.json ├── 05-ejercicio-handlebars.js ├── 02-motor.js └── 04-handlebars.js ├── clase 22 ├── mocks │ ├── model │ │ └── usuarios.js │ ├── generador │ │ └── usuarios.js │ ├── util.js │ ├── package.json │ ├── router │ │ └── usuarios.js │ ├── server-fake.js │ └── ejercicio-faker.js ├── 01-tdd.js ├── package.json ├── 03-faker.js └── 02-server.js ├── npm ├── prueba │ ├── prueba.js │ ├── package-lock.json │ └── package.json └── opera │ ├── operaciones.js │ └── package.json ├── clase 1 ├── 02-hoisting.js ├── 08-strict.js ├── 04-const.js ├── 07-closure.js ├── 11-prototipos.js ├── 03-let.js ├── 05_template.js ├── 12-clases.js ├── 09-this.js ├── 06-funcion.js ├── 01-variable.js └── 10-flecha.js ├── clase 17 ├── sqlite │ ├── db │ │ └── mydb.sqlite │ ├── options │ │ └── SQLite3.js │ └── package.json ├── options │ └── mariaDB.js ├── package.json ├── deleteRows.js ├── updateRows.js ├── selectRows.js ├── createTable.js ├── selectWhere.js ├── insertRows.js └── selectOrderBy.js ├── clase 4 ├── 08-async.js ├── 03-promisea.js ├── 05-ejemplos.js ├── 01-generadora.js ├── 04-promiseb.js ├── 07-allSettled.js ├── 06-finally.js ├── 09-await.js ├── 11-iteracion.js ├── 02-ejemplo.js └── 10-ejemplo.js ├── clase 25 ├── redis-session │ ├── leer-me-windows.txt │ ├── cloud.txt │ ├── package.json │ └── 02-server.js ├── package.json ├── mongo-session │ ├── package.json │ ├── 03-server.js │ └── 04-server.js └── 01-server.js ├── clase 3 ├── 05-timeout.js ├── 01-ejecutar.js ├── 06-sincro.js ├── 07-asincro.js ├── 02-flecha.js ├── 03-funcion-como-parametro.js ├── 04-ejemplo.js └── 08-mostrarLetras.js ├── clase 7 ├── 03-server.js ├── 02-edad.js ├── 01-edad.js ├── package.json ├── 05-server.js └── 04-server.js ├── clase 20 ├── package.json └── models │ ├── estudiantes.js │ └── estudiantes2.js ├── clase 23 ├── package.json └── package-lock.json ├── clase 26 ├── public │ ├── no-existe.html │ ├── error-password.html │ ├── ya-registrado.html │ ├── index.html │ └── register.html ├── aut-passport │ ├── public │ │ ├── error-login.html │ │ ├── error-signup.html │ │ ├── index.html │ │ └── register.html │ ├── package.json │ └── utils │ │ └── util.js └── package.json ├── clase 8 ├── package.json ├── 01-get.js ├── 02-get.js ├── 08-app.js ├── 04-server-get.js └── 03-get.js ├── facebook ├── public │ ├── error-login.html │ └── index.html ├── package.json └── sslcert │ ├── req.cnf │ └── cert.pem ├── clase 24 ├── package.json ├── session │ └── package.json ├── 01-server.js └── 02-server.js ├── clase 21 ├── package.json └── models │ ├── estudiantes.js │ └── estudiantes2.js ├── clase 13 ├── package.json ├── chat │ ├── package.json │ ├── public │ │ ├── js │ │ │ └── index.js │ │ └── index.html │ └── server.js ├── colores │ ├── package.json │ ├── public │ │ └── css │ │ │ └── estilos.css │ └── paint.js ├── public │ ├── main.js │ └── index.html └── server.js ├── after ├── sockets │ ├── package.json │ └── public │ │ ├── goles.html │ │ ├── index.html │ │ ├── main.js │ │ ├── estilos.css │ │ └── goles.js └── callbacks │ ├── 00-filter.js │ ├── 02-request.js │ └── 01-simulo.js ├── clase 29 └── server-cluster │ ├── package.json │ ├── 02-server.js │ ├── 01-server.js │ └── 03-server.js └── .gitignore /clase 9/x: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /clase 12/public/style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /clase 28/nada.txt: -------------------------------------------------------------------------------- 1 | nada!!! -------------------------------------------------------------------------------- /clase 12/public/ej1/style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /clase 12/public/ej2/style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /clase 12/public/ej3/style.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /clase 0/prueba2.js: -------------------------------------------------------------------------------- 1 | console.log('probando'); -------------------------------------------------------------------------------- /clase 12/public/ej1/index.js: -------------------------------------------------------------------------------- 1 | const socket = io(); -------------------------------------------------------------------------------- /clase 2/16-globalThis.js: -------------------------------------------------------------------------------- 1 | console.log(globalThis); -------------------------------------------------------------------------------- /clase 28/04-argv.js: -------------------------------------------------------------------------------- 1 | console.log(process.argv); -------------------------------------------------------------------------------- /clase 6/archivos/fyh.txt: -------------------------------------------------------------------------------- 1 | 2021-08-25T00:14:43.284Z -------------------------------------------------------------------------------- /clase 14/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ['env'] 3 | } -------------------------------------------------------------------------------- /clase 14/babel/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["env"] 3 | } -------------------------------------------------------------------------------- /clase 30/public/estilos.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | color:blue; 3 | } -------------------------------------------------------------------------------- /clase 6/archivos/hola.txt: -------------------------------------------------------------------------------- 1 | hola, los saludo en esta noche... -------------------------------------------------------------------------------- /clase 0/prueba.js: -------------------------------------------------------------------------------- 1 | console.log('hola!'); 2 | console.log(true); -------------------------------------------------------------------------------- /clase 11/views/pages/about.ejs: -------------------------------------------------------------------------------- 1 |

About

2 | <%= about %> -------------------------------------------------------------------------------- /clase 28/06-process.execPath.js: -------------------------------------------------------------------------------- 1 | console.log(process.execPath); -------------------------------------------------------------------------------- /clase 30/public/saludo.js: -------------------------------------------------------------------------------- 1 | console.log('Hola desde el servidor!!!'); -------------------------------------------------------------------------------- /clase 28/config/.env: -------------------------------------------------------------------------------- 1 | DB_HOST=localhost 2 | DB_USER=root 3 | DB_PASS=s1mpl3 -------------------------------------------------------------------------------- /clase 15/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "git.ignoreLimitWarning": true 3 | } -------------------------------------------------------------------------------- /clase 27/jwt/config/.env: -------------------------------------------------------------------------------- 1 | PORT = 8080 2 | SECRET_JWT = riverplate 3 | EXP_JWT = 24h -------------------------------------------------------------------------------- /clase 5/01-nodemon.js: -------------------------------------------------------------------------------- 1 | const nombre = 'Lopez'; 2 | console.log(`Hola!!! ${nombre}`); -------------------------------------------------------------------------------- /clase 14/babel/origen.js: -------------------------------------------------------------------------------- 1 | const arr = [2,5,6,10]; 2 | arr.map(x => x*x).forEach(x=>console.log(x)); -------------------------------------------------------------------------------- /clase 14/ts/index.ts: -------------------------------------------------------------------------------- 1 | const lista = [2,3,5,7]; 2 | lista.map(x => x*x).forEach(x => console.log(x)); -------------------------------------------------------------------------------- /clase 15/index2.js: -------------------------------------------------------------------------------- 1 | mensaje2 = 'Soy el mensaje 2'; 2 | setTimeout(()=>console.log(mensaje2),2000); -------------------------------------------------------------------------------- /clase 15/index3.js: -------------------------------------------------------------------------------- 1 | mensaje3 = 'Soy el mensaje 3'; 2 | setTimeout(()=>console.log(mensaje3),6000); -------------------------------------------------------------------------------- /clase 10/views/index.ntp: -------------------------------------------------------------------------------- 1 |

Listado

2 | #title#
3 | #message# 4 | $$aaa// 5 | {{hola}} 6 | -------------------------------------------------------------------------------- /clase 14/01-origen.js: -------------------------------------------------------------------------------- 1 | const lista = [2,3,5,7,8]; 2 | lista.map(x => x*x).forEach(x => console.log(x)); -------------------------------------------------------------------------------- /clase 14/ts3/index.ts: -------------------------------------------------------------------------------- 1 | const lista = [2,3,5,7]; 2 | lista.map(x => x*x).forEach(x => console.log(x)); -------------------------------------------------------------------------------- /clase 15/index1.js: -------------------------------------------------------------------------------- 1 | mensaje1 = 'Soy el mensaje 1111'; 2 | setTimeout(()=>console.log(mensaje1),1000); -------------------------------------------------------------------------------- /clase 22/mocks/model/usuarios.js: -------------------------------------------------------------------------------- 1 | let usuarios = []; 2 | 3 | module.exports = { 4 | usuarios 5 | } -------------------------------------------------------------------------------- /npm/prueba/prueba.js: -------------------------------------------------------------------------------- 1 | const operasiro = require('operasiro'); 2 | 3 | console.log(operasiro.modu(14,3)); -------------------------------------------------------------------------------- /clase 11/views/partials/footer.ejs: -------------------------------------------------------------------------------- 1 |

© Copyright 2020 The aaawesome People

-------------------------------------------------------------------------------- /npm/prueba/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "prueba", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1 5 | } 6 | -------------------------------------------------------------------------------- /clase 1/02-hoisting.js: -------------------------------------------------------------------------------- 1 | var precio; 2 | console.log('Antes ', precio); 3 | precio = 5; 4 | console.log('Despues ', precio); -------------------------------------------------------------------------------- /clase 17/sqlite/db/mydb.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ssirotinsky/coder-backend/HEAD/clase 17/sqlite/db/mydb.sqlite -------------------------------------------------------------------------------- /clase 11/views/hello.pug: -------------------------------------------------------------------------------- 1 | html 2 | head 3 | title='Mi primer plantilla de PUG' 4 | body 5 | h1=mensaje -------------------------------------------------------------------------------- /clase 27/facebook/config/.env: -------------------------------------------------------------------------------- 1 | PORT = 8443 2 | FACEBOOK_APP_ID = 843042359706039 3 | FACEBOOK_APP_SECRET = 586ed493a95ab0b0e92459129e5a1c93 -------------------------------------------------------------------------------- /clase 14/ts/index.js: -------------------------------------------------------------------------------- 1 | var lista = [2, 3, 5, 7]; 2 | lista.map(function (x) { return x * x; }).forEach(function (x) { return console.log(x); }); 3 | -------------------------------------------------------------------------------- /clase 14/ts3/index.js: -------------------------------------------------------------------------------- 1 | var lista = [2, 3, 5, 7]; 2 | lista.map(function (x) { return x * x; }).forEach(function (x) { return console.log(x); }); 3 | -------------------------------------------------------------------------------- /clase 27/twitter/config/.env: -------------------------------------------------------------------------------- 1 | PORT = 8080 2 | TWITTER_API_KEY = zP71mExolGqqGMH0wK3COr71T 3 | TWITTER_API_SECRET = 0vCrHtx1FY0OpuHDB7drXLhO0MJaynAKqbrqRovBx5CpR4K1c8 -------------------------------------------------------------------------------- /clase 10/cte1/plantilla1.cte: -------------------------------------------------------------------------------- 1 |

^^titulo$$

2 |

^^mensaje$$

3 | ^^autor$$ 4 |
5 | Versión: ^^version$$ 6 | a ver #!nombre#! 7 | -------------------------------------------------------------------------------- /clase 10/public/style.css: -------------------------------------------------------------------------------- 1 | h1 { 2 | color: blue; 3 | } 4 | 5 | h2 { 6 | color: red; 7 | } 8 | 9 | .toplaner { 10 | background-color: yellowgreen; 11 | } -------------------------------------------------------------------------------- /clase 2/09-bigint.js: -------------------------------------------------------------------------------- 1 | //BigInts 2 | // console.log(Number.MAX_SAFE_INTEGER); 3 | 4 | console.log(2 ** 64) 5 | console.log(BigInt(2) ** BigInt(64)); 6 | 7 | //console.log(2n ** 64n); -------------------------------------------------------------------------------- /clase 14/babel/salida.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var arr = [2, 5, 6, 10]; 4 | arr.map(function (x) { 5 | return x * x; 6 | }).forEach(function (x) { 7 | return console.log(x); 8 | }); 9 | -------------------------------------------------------------------------------- /clase 6/04-unlinksync.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | fs.unlinkSync('./archivos/prueba.txt'); 6 | 7 | console.log('final del programa'); 8 | -------------------------------------------------------------------------------- /clase 1/08-strict.js: -------------------------------------------------------------------------------- 1 | "use strict" 2 | // console.log(a); 3 | // var a = 10 4 | // console.log(a); 5 | 6 | function suma(a, a) { 7 | return a; 8 | } 9 | 10 | console.log(suma(5, 2)); -------------------------------------------------------------------------------- /clase 14/origen-es5.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var lista = [2, 3, 5, 7, 8]; 4 | lista.map(function (x) { 5 | return x * x; 6 | }).forEach(function (x) { 7 | return console.log(x); 8 | }); 9 | -------------------------------------------------------------------------------- /clase 10/cte1/plantilla2.cte: -------------------------------------------------------------------------------- 1 |

Nueva Info...

2 |

Datos importantes:

3 |

Nombre: #!nombre#!

4 |

Apellido: #!apellido#!

5 |

Fecha y Hora: #!fechahora#!

6 | -------------------------------------------------------------------------------- /clase 4/08-async.js: -------------------------------------------------------------------------------- 1 | async function funcionAsync(){ 2 | return 'Valor Devuelto'; 3 | } 4 | 5 | // console.log(funcionAsync()); 6 | 7 | funcionAsync() 8 | .then(resolve => console.log(resolve)); -------------------------------------------------------------------------------- /clase 2/12-flatMap.js: -------------------------------------------------------------------------------- 1 | const numeros = [1, 2, 3, 4, 5]; 2 | const cuadrado = (e) => [e, e ** 2]; 3 | 4 | console.log(numeros.map(cuadrado)); 5 | console.log(numeros.flatMap(cuadrado)); //sólo existe de orden 1 -------------------------------------------------------------------------------- /clase 25/redis-session/leer-me-windows.txt: -------------------------------------------------------------------------------- 1 | para evitar problemas desde node.js, instalar desde aquí redis server: 2 | 3 | https://github.com/ServiceStack/redis-windows/raw/master/downloads/redis-latest.zip -------------------------------------------------------------------------------- /clase 28/child.js: -------------------------------------------------------------------------------- 1 | let contador = 0; 2 | 3 | process.on('message', mensaje=>{ 4 | console.log('Mensaje del padre:', mensaje); 5 | setInterval(()=>process.send({contador: contador++}), 1000); 6 | }) -------------------------------------------------------------------------------- /clase 2/05-padding.js: -------------------------------------------------------------------------------- 1 | const pi = '3.14159' 2 | console.log(pi.padStart(3, '0')); 3 | console.log(pi.padEnd(10, '0')); 4 | 5 | let nombreCliente = 'Jorge Luis Borges'; 6 | console.log(nombreCliente.padStart(30)); -------------------------------------------------------------------------------- /clase 15/ts/src/lib/functions.js: -------------------------------------------------------------------------------- 1 | const getTime = () => { 2 | let fyh = new Date().toLocaleString; 3 | let timestamp = Date.now(); 4 | return {fyh, timestamp}; 5 | } 6 | 7 | module.exports = { 8 | getTime 9 | } -------------------------------------------------------------------------------- /clase 2/typescript/ejemplo/archivo.js: -------------------------------------------------------------------------------- 1 | var miBool = 'hola que tal'; 2 | var miNumero = 10; 3 | var miCadena = 'Probando'; 4 | // miBool = "hola"; 5 | console.log("probando... " + miCadena + " " + miNumero + " " + miBool); 6 | -------------------------------------------------------------------------------- /clase 28/07-stdout.js: -------------------------------------------------------------------------------- 1 | // const util = require('util'); 2 | // process.stdout.write('hola'); 3 | 4 | // Console.prototype.log = function() { 5 | // this._stdout.write(util.format.apply(this, arguments) + '\n'); 6 | // }; -------------------------------------------------------------------------------- /clase 6/03-appendsync.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | fs.appendFileSync('./archivos/prueba.txt', 'estoy agregando info...\n'); 6 | 7 | console.log('final del programa'); 8 | -------------------------------------------------------------------------------- /clase 2/18-nullish.js: -------------------------------------------------------------------------------- 1 | // const precioFinal = (precio, cantidad) => precio * cantidad; 2 | const precioFinal = (precio, cantidad) => precio * (cantidad ?? 1); 3 | 4 | console.log(precioFinal(200,2)); 5 | console.log(precioFinal(200)); -------------------------------------------------------------------------------- /clase 6/01-readsync.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | const data = fs.readFileSync('./archivos/prueba.txt', 'utf-8'); 6 | console.log(data); 7 | 8 | console.log('final del programa'); 9 | -------------------------------------------------------------------------------- /clase 28/03-uncaughtException.js: -------------------------------------------------------------------------------- 1 | // process.on('uncaughtException',(err)=>console.log('Error!!!', err)); 2 | 3 | setTimeout(()=>console.log('Fin!'), 1000); 4 | 5 | rutinaInexistente(); 6 | 7 | console.log('No se ejecutará nunca...'); 8 | -------------------------------------------------------------------------------- /clase 12/public/ej2/index.js: -------------------------------------------------------------------------------- 1 | const socket = io(); 2 | 3 | function ingresoTexto(texto) { 4 | socket.emit('texto', texto); 5 | } 6 | 7 | socket.on('broadcast', (data) => { 8 | document.getElementsByTagName('p')[0].innerHTML = data; 9 | }); -------------------------------------------------------------------------------- /clase 25/redis-session/cloud.txt: -------------------------------------------------------------------------------- 1 | zp2NQTYt9wSNeuwRGPQCySMe6Vl6HiQC 2 | 3 | redis-13928.c258.us-east-1-4.ec2.cloud.redislabs.com:13928 4 | 5 | redis-cli -h redis-13928.c258.us-east-1-4.ec2.cloud.redislabs.com -p 13928 -a zp2NQTYt9wSNeuwRGPQCySMe6Vl6HiQC -------------------------------------------------------------------------------- /clase 2/10-matchAll.js: -------------------------------------------------------------------------------- 1 | const miTexto = 'Me gustan Java y Javascript'; 2 | const buscar = /Java/g; 3 | 4 | console.log(miTexto.matchAll(buscar)); 5 | console.log([...miTexto.matchAll(buscar)]); 6 | console.log([...miTexto.matchAll(buscar)].map(e => e.index)); -------------------------------------------------------------------------------- /clase 2/typescript/ejemplo/archivo.ts: -------------------------------------------------------------------------------- 1 | const miBool: Boolean = 'hola que tal'; 2 | 3 | let miNumero: Number = 10; 4 | 5 | let miCadena: String = 'Probando'; 6 | 7 | // miBool = "hola"; 8 | 9 | console.log(`probando... ${miCadena} ${miNumero} ${miBool}`); -------------------------------------------------------------------------------- /clase 6/02-writesync.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | fs.writeFileSync('./archivos/prueba.txt', 'estoy sobreescribiendo el archivo...\n'); 6 | 7 | console.log('final del programa'); 8 | 9 | 10 | -------------------------------------------------------------------------------- /clase 0/valor.js: -------------------------------------------------------------------------------- 1 | //Pasaje de parámetros por valor: 2 | function probando(param) { 3 | param++; 4 | console.log('Adentro', param); 5 | } 6 | 7 | var miParam = 25 8 | console.log('Antes', miParam); 9 | probando(miParam); 10 | console.log('Después', miParam); -------------------------------------------------------------------------------- /npm/opera/operaciones.js: -------------------------------------------------------------------------------- 1 | const suma = (n1,n2) => n1 + n2; 2 | const resta = (n1,n2) => n1 - n2; 3 | const mult = (n1,n2) => n1 * n2; 4 | const divi = (n1,n2) => n1 / n2; 5 | const modu = (n1,n2) => n1 % n2; 6 | 7 | 8 | module.exports = {suma, resta, mult, divi, modu}; -------------------------------------------------------------------------------- /clase 2/02-expon.js: -------------------------------------------------------------------------------- 1 | // console.log(Math.pow(2, 4)); // Forma tradicional 2 | // console.log(2 ** 4); // Forma nueva más cómoda y que acepta BigInts 3 | console.log(2 ** 3 ** 2); // Es asociativo a la derecha, o sea, es lo mismo que 2 ** (3 ** 2) 4 | console.log((2 ** 3) ** 2); -------------------------------------------------------------------------------- /clase 5/02-aleatorios.js: -------------------------------------------------------------------------------- 1 | let numeros = {}; 2 | 3 | for (let i=0; i<20; i++){ 4 | numeros[i+1] = 0; 5 | } 6 | 7 | for (let i=0; i<10000; i++){ 8 | let azar = Math.floor(Math.random() * 20) + 1; 9 | numeros[azar]++; 10 | } 11 | 12 | console.log(numeros); -------------------------------------------------------------------------------- /clase 10/views/main2.hbs: -------------------------------------------------------------------------------- 1 |

Datos Personales

2 | 9 | -------------------------------------------------------------------------------- /clase 14/ts2/lib/operaciones.ts: -------------------------------------------------------------------------------- 1 | export const sumar = (a:number, b:number):number => a + b 2 | export const restar = (a:number, b:number):number => a - b 3 | export const multiplicar = (a:number, b:number):number => a * b 4 | export const dividir = (a:number, b:number):number => a / b -------------------------------------------------------------------------------- /clase 0/referencia.js: -------------------------------------------------------------------------------- 1 | //Pasaje de parámetros por referencia: 2 | function probando(param) { 3 | param[0]++; 4 | console.log('Adentro', param); 5 | } 6 | 7 | var miParam = [25] 8 | console.log('Antes', miParam); 9 | probando(miParam); 10 | console.log('Después', miParam); -------------------------------------------------------------------------------- /clase 1/04-const.js: -------------------------------------------------------------------------------- 1 | // const iva = 21.0; 2 | // console.log(iva); 3 | // iva = 25.0; 4 | 5 | const lista = [1, 2, 3, 4, 5]; 6 | console.log('antes: ', lista); 7 | // lista = [6, 7, 8]; 8 | lista.push(6); 9 | lista.push(7); 10 | lista.push(8); 11 | console.log('después: ', lista) -------------------------------------------------------------------------------- /clase 6/package.json.coder: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-6", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "01-readsync.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "Coderhouse", 10 | "license": "ISC" 11 | } -------------------------------------------------------------------------------- /clase 28/05-env.js: -------------------------------------------------------------------------------- 1 | // console.log(process.env); 2 | 3 | 4 | // Mediante dotenv podemos agregar variables a process.env 5 | require('dotenv').config({ path: './config/.env' }) 6 | console.log(process.env.DB_HOST); 7 | console.log(process.env.DB_USER); 8 | console.log(process.env.DB_PASS); -------------------------------------------------------------------------------- /clase 5/04-server.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | 3 | var server = http.createServer(function (peticion, respuesta) { 4 | respuesta.end("Hola como estas"); 5 | }); 6 | 7 | server.listen(8000, function() { 8 | console.log('Tu servidor está listo en', this.address().port); 9 | }); -------------------------------------------------------------------------------- /clase 6/14-promiseread.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | fs.promises.readFile('./info.txt', 'utf-8') 6 | .then(contenido=> console.log(contenido)) 7 | .catch(error=>console.log(error)); 8 | 9 | console.log('final del programa'); 10 | -------------------------------------------------------------------------------- /clase 2/15-optionalCatch.js: -------------------------------------------------------------------------------- 1 | // try { 2 | // throw "Error en tipo de datos" 3 | // } catch (e) { 4 | // console.log('Error en llamado: ', e); 5 | // } 6 | 7 | try { 8 | throw "Error en tipo de datos" 9 | } catch { 10 | console.log('Error en llamado a la rutina'); 11 | } -------------------------------------------------------------------------------- /clase 28/computo.js: -------------------------------------------------------------------------------- 1 | const calculo = () => { 2 | let sum = 0; 3 | for (let i=0; i<6e9; i++){ 4 | sum+=i; 5 | } 6 | return sum; 7 | } 8 | 9 | process.on("message", (mensaje)=>{ 10 | if (mensaje=='start'){ 11 | process.send(calculo()); 12 | } 13 | }); -------------------------------------------------------------------------------- /clase 10/views/partials/hatedChamps.hbs: -------------------------------------------------------------------------------- 1 |

List of my most hated League Champions

2 | -------------------------------------------------------------------------------- /clase 28/14-fork-padre.js: -------------------------------------------------------------------------------- 1 | const {fork} = require('child_process'); 2 | 3 | const forked = fork('./child.js'); 4 | 5 | forked.on('message', (mensaje)=>console.log('Mensaje del hijo:', mensaje)); 6 | 7 | console.log('Inicio del programa Padre'); 8 | 9 | setTimeout(()=>forked.send({mensaje: 'hola'}), 2000); -------------------------------------------------------------------------------- /clase 10/views/partials/lovedChamps.hbs: -------------------------------------------------------------------------------- 1 |

List of my most loved League Champions

2 | -------------------------------------------------------------------------------- /clase 17/sqlite/options/SQLite3.js: -------------------------------------------------------------------------------- 1 | const options = { 2 | client: 'sqlite3', 3 | connection: { 4 | filename: './db/mydb.sqlite' 5 | }, 6 | useNullAsDefault: true 7 | } 8 | 9 | console.log('Conectando a la base de datos...'); 10 | 11 | module.exports = { 12 | options 13 | } -------------------------------------------------------------------------------- /clase 6/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "name": "clase-6", 4 | "version": "1.0.0", 5 | "description": "", 6 | "main": "01-readsync.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC" 12 | } 13 | -------------------------------------------------------------------------------- /clase 4/03-promisea.js: -------------------------------------------------------------------------------- 1 | const miPromesa = new Promise ((resolve, reject)=>{ 2 | console.log('a ver...'); 3 | setTimeout(()=>resolve('Todo OK!!!'), 4 | 2000) 5 | }); 6 | 7 | console.log('iniciando...'); 8 | miPromesa 9 | .then(resultado => console.log(resultado)); 10 | console.log('finalizando...'); -------------------------------------------------------------------------------- /clase 2/11-flat.js: -------------------------------------------------------------------------------- 1 | const miLista = [ 2 | 1, 3 | 5, 4 | 25, 5 | 11, [3, 17], 6 | [6, 25, 46], 7 | [3, [1, 2, 67, 87]] 8 | ]; 9 | 10 | console.log(miLista); 11 | console.log(miLista.flat()); 12 | console.log(miLista.flat(1)); 13 | console.log(miLista.flat(2)); 14 | console.log(miLista.flat(3)); -------------------------------------------------------------------------------- /clase 3/05-timeout.js: -------------------------------------------------------------------------------- 1 | // console.log('empezando...'); 2 | // setTimeout( 3 | // ()=>console.log('hola!!'), 4 | // 3000 5 | // ); 6 | // console.log('finalizando...'); 7 | 8 | console.log('empezando...'); 9 | setInterval( 10 | ()=>console.log('hola!!'), 11 | 3000 12 | ); 13 | console.log('finalizando...'); -------------------------------------------------------------------------------- /clase 7/03-server.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | const server = app.listen(PORT, ()=>{ 7 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 8 | }); 9 | server.on('error', error=>console.log('Error en servidor', error)); 10 | -------------------------------------------------------------------------------- /clase 1/07-closure.js: -------------------------------------------------------------------------------- 1 | function creaFuncion() { 2 | var nombre = 'Juan'; 3 | 4 | function saludar() { 5 | console.log('Hola', nombre); 6 | } 7 | //saludar(); 8 | return saludar; 9 | } 10 | 11 | // creaFuncion(); 12 | // console.log('Afuera: ', nombre); 13 | 14 | creaFuncion(); 15 | //miFuncion(); -------------------------------------------------------------------------------- /clase 10/views/main.hbs: -------------------------------------------------------------------------------- 1 | {{> lovedChamps}} 2 |
3 | {{> hatedChamps}} 4 |
5 | 6 |

List of my most suggested League Champions

7 | {{#if listExists}} 8 | 13 | {{/if}} -------------------------------------------------------------------------------- /npm/prueba/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "name": "prueba", 4 | "version": "1.0.0", 5 | "description": "", 6 | "main": "prueba.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": {} 13 | } 14 | -------------------------------------------------------------------------------- /clase 22/01-tdd.js: -------------------------------------------------------------------------------- 1 | function suma(a, b) { 2 | c = a + b; 3 | return c; 4 | } 5 | 6 | 7 | const assert = require('assert').strict; 8 | 9 | try { 10 | assert.equal(9, suma(3,6), "Prueba fallida"); 11 | console.log('Prueba OK'); 12 | } catch(error) { 13 | console.log("Error: ", error) 14 | } 15 | 16 | -------------------------------------------------------------------------------- /clase 3/01-ejecutar.js: -------------------------------------------------------------------------------- 1 | // Las funciones son un objeto y se pueden asignar a una variable 2 | // const saludar = function () { 3 | // console.log('Hola a tod@s'); 4 | // } 5 | 6 | // saludar(); 7 | 8 | const saludarPersona = function (nombre) { 9 | console.log(`Hola ${nombre}!`); 10 | } 11 | 12 | saludarPersona('Pepe'); -------------------------------------------------------------------------------- /clase 11/views/partials/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | EJS Is Fun 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /clase 14/ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "typescript": "^4.4.3" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /clase 20/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-20", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "mongoose": "^6.0.10" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /clase 22/mocks/generador/usuarios.js: -------------------------------------------------------------------------------- 1 | const faker = require('faker'); 2 | 3 | faker.locale = 'es'; 4 | 5 | const get = () => ({ 6 | nombre: faker.name.findName(), 7 | email: faker.internet.email(), 8 | website: faker.internet.url(), 9 | image: faker.image.avatar() 10 | }); 11 | 12 | module.exports = { 13 | get 14 | } -------------------------------------------------------------------------------- /clase 28/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-28", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "dotenv": "^10.0.0" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /clase 6/05-unlinktry.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | try { 5 | fs.unlinkSync('./archivos/prueba.txt'); 6 | console.log('Se ha borrado el archivo'); 7 | } catch (e) { 8 | console.log('No se pudo borrar el archivo...', e); 9 | } 10 | 11 | console.log('final del programa'); 12 | -------------------------------------------------------------------------------- /clase 9/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-9", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "01-router.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "express": "^4.17.1" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /clase 23/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-23", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "01-empresa.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "normalizr": "^3.6.1" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /clase 2/07-dotall.js: -------------------------------------------------------------------------------- 1 | //para probar expresiones regulares: regex101.com 2 | console.log(/hola.es/.test('hola estoy probando')); 3 | console.log(/hola.es/.test('holapestoy probando')); 4 | console.log(/hola.es/.test('hola0estoy probando')); 5 | console.log(/hola.es/.test('hola\nestoy probando')); 6 | 7 | console.log(/hola.es/s.test('hola\nestoy probando')); -------------------------------------------------------------------------------- /clase 1/11-prototipos.js: -------------------------------------------------------------------------------- 1 | function Perro(nombre, raza, edad) { 2 | this.nombre = nombre; 3 | this.raza = raza; 4 | this.edad = edad; 5 | } 6 | 7 | Perro.prototype.ladrar = function() { 8 | console.log('Guau!!!, soy ', this.nombre) 9 | } 10 | 11 | let maxi = new Perro('Maxi', 'Caniche', 3); 12 | console.log(maxi); 13 | maxi.ladrar(); -------------------------------------------------------------------------------- /clase 2/13-fromEntries.js: -------------------------------------------------------------------------------- 1 | let miEquipo = { 2 | club: 'River Plate', 3 | apodo: 'Millonarios', 4 | libertadores: 4, 5 | idolos: ['Marcelo Gallardo', 'Ramón Diaz', 'Enzo Francesoli'], 6 | esGrande: true 7 | } 8 | 9 | console.log(Object.entries(miEquipo)); 10 | let prueba = ['hola','chau']; 11 | console.log(Object.fromEntries(prueba)); -------------------------------------------------------------------------------- /clase 2/14-trim.js: -------------------------------------------------------------------------------- 1 | const textoPrueba = ' Probando los distintos Trim '; 2 | console.log(textoPrueba.split('')); 3 | console.log(textoPrueba.split('').filter(e=>e != ' ').join('')); 4 | console.log(textoPrueba + 'f'); 5 | console.log(textoPrueba.trim() + 'f'); 6 | console.log(textoPrueba.trimStart() + 'f'); 7 | console.log(textoPrueba.trimEnd() + 'f'); -------------------------------------------------------------------------------- /clase 22/mocks/util.js: -------------------------------------------------------------------------------- 1 | const getIndex = (id, usuarios) => usuarios.findIndex(usuario => usuario.id == id); 2 | 3 | const getFecha = () => new Date().toLocaleString(); 4 | 5 | const nextId = (usuarios) => usuarios.length ? (usuarios[usuarios.length-1].id + 1) : 1; 6 | 7 | module.exports = { 8 | getIndex, 9 | getFecha, 10 | nextId 11 | } -------------------------------------------------------------------------------- /clase 9/public/prueba/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | probando 8 | 9 | 10 |

probando

11 | 12 | -------------------------------------------------------------------------------- /clase 1/03-let.js: -------------------------------------------------------------------------------- 1 | let impuesto = 0.03; 2 | console.log('antes: ', impuesto) 3 | 4 | if (true) { 5 | 6 | let impuesto = 0.05; 7 | // impuesto = 0.05; 8 | console.log('adentro: ', impuesto) 9 | 10 | } 11 | 12 | console.log('después: ', impuesto); 13 | 14 | 15 | //Let NO tiene hoisting: 16 | // console.log(impuesto); 17 | // let impuesto = 0.03; -------------------------------------------------------------------------------- /clase 14/ts3/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts3", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "typescript": "^4.4.3" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /clase 15/ts/src/lib/classes.ts: -------------------------------------------------------------------------------- 1 | export class Persona { 2 | 3 | private fname: string; 4 | private lname: string; 5 | 6 | constructor(fname: string, lname: string){ 7 | this.fname = fname; 8 | this.lname = lname; 9 | } 10 | 11 | getFullName():string { 12 | return `${this.fname} '-' ${this.lname}`; 13 | } 14 | } -------------------------------------------------------------------------------- /clase 17/options/mariaDB.js: -------------------------------------------------------------------------------- 1 | const options = { 2 | client: 'mysql', 3 | connection: { 4 | host: '127.0.0.1', 5 | port: 3306, 6 | user: 'root', 7 | password: '', 8 | database: 'coderhouse' 9 | } 10 | } 11 | 12 | console.log('Conectando a la base de datos...'); 13 | 14 | module.exports = { 15 | options 16 | } -------------------------------------------------------------------------------- /clase 17/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-17", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "knex": "^0.21.17", 13 | "mysql": "^2.18.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /clase 26/public/no-existe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login 8 | 9 | 10 |

Usuario no existe

11 | 12 | -------------------------------------------------------------------------------- /clase 4/05-ejemplos.js: -------------------------------------------------------------------------------- 1 | Promise.reject(30) 2 | .then(x => x + 1) 3 | .then(x => x * 2) 4 | .then(x => {if (x==22) throw 'Error' 5 | else return 80 6 | }) 7 | .then(x => x = 30) 8 | .then(x => x / 2) 9 | .then(console.log) 10 | .catch(console.log); 11 | 12 | //then(x=>console.log(x)); 13 | //catch(x=>console.log(x)); -------------------------------------------------------------------------------- /clase 8/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "name": "clase-8", 4 | "version": "1.0.0", 5 | "description": "", 6 | "main": "01-server.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.17.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /clase 12/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-12", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "express": "^4.17.1", 13 | "socket.io": "^4.2.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /clase 17/deleteRows.js: -------------------------------------------------------------------------------- 1 | const {options} = require('./options/mariaDB'); 2 | const knex = require('knex')(options); 3 | 4 | knex.from('cars').where('price', '>', 4500).del() 5 | .then(() => { 6 | console.log('Filas borradas!'); 7 | knex.destroy(); 8 | }) 9 | .catch(e=>{ 10 | console.log('Error en Delete:', e); 11 | knex.destroy(); 12 | }); 13 | 14 | -------------------------------------------------------------------------------- /clase 26/public/error-password.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login 8 | 9 | 10 |

Password errónea

11 | 12 | -------------------------------------------------------------------------------- /clase 6/11-mkdir.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | fs.mkdir('./mas-archivos', (error) => { 6 | if (error) { 7 | console.log('Hubo un error en la creación de la carpeta'); 8 | } else { 9 | console.log('Carpeta creada!'); 10 | } 11 | }); 12 | 13 | console.log('final del programa'); 14 | -------------------------------------------------------------------------------- /facebook/public/error-login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 |

Error en Login

11 | 12 | -------------------------------------------------------------------------------- /clase 10/01-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | app.use(express.static('public')); 7 | 8 | const server = app.listen(PORT, () => { 9 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 10 | }); 11 | server.on('error', error => console.log('Error en servidor', error)); -------------------------------------------------------------------------------- /clase 24/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-24", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "cookie-parser": "^1.4.5", 13 | "express": "^4.17.1" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /clase 26/public/ya-registrado.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login 8 | 9 | 10 |

Usuario ya registrado

11 | 12 | -------------------------------------------------------------------------------- /clase 27/facebook/public/error-login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login 8 | 9 | 10 |

Error en login

11 | 12 | -------------------------------------------------------------------------------- /clase 27/twitter/public/error-login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login 8 | 9 | 10 |

Error en login

11 | 12 | -------------------------------------------------------------------------------- /clase 24/session/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "session", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express-session": "^1.17.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /clase 26/aut-passport/public/error-login.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login 8 | 9 | 10 |

Error en login

11 | 12 | -------------------------------------------------------------------------------- /clase 26/aut-passport/public/error-signup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login 8 | 9 | 10 |

Error en registro

11 | 12 | -------------------------------------------------------------------------------- /clase 6/10-unlinkasync.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | fs.unlink('./archivos/prueba.txt', (error) => { 6 | if (error) { 7 | console.log('Hubo un error en el borrado del archivo'); 8 | } else { 9 | console.log('Archivo borrado!'); 10 | } 11 | }); 12 | 13 | console.log('final del programa'); 14 | -------------------------------------------------------------------------------- /clase 28/01-global.js: -------------------------------------------------------------------------------- 1 | // console.log(process); 2 | 3 | console.log(`Directorio actual: ${process.cwd()}`); 4 | console.log(`Id del proceso: ${process.pid}`); 5 | console.log(`Versión de Node: ${process.version}`); 6 | console.log(`Título del proceso: ${process.title}`); 7 | console.log(`Sistema Operativo: ${process.platform}`); 8 | console.log(process.memoryUsage()); 9 | 10 | -------------------------------------------------------------------------------- /clase 6/07-readasync.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | fs.readFile('./archivos/prueba.txt', 'utf-8', (error, data) => { 6 | if (error) { 7 | console.log('Hubo un error en la lectura del archivo'); 8 | } else { 9 | console.log(data); 10 | } 11 | }); 12 | 13 | console.log('final del programa'); 14 | -------------------------------------------------------------------------------- /facebook/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | Login con Facebook 11 | 12 | -------------------------------------------------------------------------------- /clase 17/updateRows.js: -------------------------------------------------------------------------------- 1 | const {options} = require('./options/mariaDB'); 2 | const knex = require('knex')(options); 3 | 4 | knex.from('cars').where('price', '=', 4500).update({price: 4700}) 5 | .then(() => { 6 | console.log('Filas actualizadas!') 7 | knex.destroy(); 8 | }) 9 | .catch(e=>{ 10 | console.log('Error en Update:', e); 11 | knex.destroy(); 12 | }); 13 | 14 | -------------------------------------------------------------------------------- /clase 6/12-readdir.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | fs.readdir('./archivos', (error, files) => { 6 | if (error) { 7 | console.log('Hubo un error en la lectura de la carpeta'); 8 | } else { 9 | console.log('Archivos en la carpeta:', files); 10 | } 11 | }); 12 | 13 | console.log('final del programa'); 14 | -------------------------------------------------------------------------------- /clase 1/05_template.js: -------------------------------------------------------------------------------- 1 | let nombre = 'Sergio' 2 | let edad = 44 3 | 4 | console.log('Hola, mi nombre es \n' + nombre + '\t y tengo ' + edad + ' años'); 5 | // console.log('Hola, mi nombre es', nombre, 'y tengo', edad, 'años'); 6 | // console.log(`Hola, mi nombre es ${nombre} y tengo ${edad} años`); 7 | 8 | console.log(`Hola! 9 | Mi ombre es ${nombre} 10 | y tengo ${edad} años 11 | `); -------------------------------------------------------------------------------- /clase 11/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-11", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "01-server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "ejs": "^3.1.6", 13 | "express": "^4.17.1", 14 | "pug": "^3.0.2" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clase 17/sqlite/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sqlite", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "knex": "^0.95.11", 14 | "sqlite3": "^5.0.2" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clase 2/04-values.js: -------------------------------------------------------------------------------- 1 | let miEquipo = { 2 | club: 'River Plate', 3 | apodo: 'Millonarios', 4 | libertadores: 4, 5 | idolos: ['Marcelo Gallardo', 'Ramón Diaz', 'Enzo Francesoli'], 6 | esGrande: true 7 | } 8 | 9 | // console.log(Object.values(miEquipo)); 10 | // console.log(Object.values(miEquipo).filter(e => typeof e == 'string')); 11 | console.log(Object.entries(miEquipo)); -------------------------------------------------------------------------------- /clase 22/mocks/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mocks", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.17.1", 14 | "faker": "^5.5.3" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clase 22/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-22", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "01-tdd.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "assert": "^2.0.0", 13 | "express": "^4.17.1", 14 | "faker": "^5.5.3" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clase 7/02-edad.js: -------------------------------------------------------------------------------- 1 | import moment from 'moment'; 2 | 3 | const hoy = moment(); 4 | const nacimiento = moment([1976,8,9]); 5 | console.log(`Hoy es ${hoy.format('DD/MM/YYYY')}`); 6 | console.log(`Naci el ${nacimiento.format('DD/MM/YYYY')}`); 7 | console.log(`Desde mi nacimiento han pasado ${hoy.diff(nacimiento,"y")} años`); 8 | console.log(`Desde mi nacimiento han pasado ${hoy.diff(nacimiento,"d")} días`); -------------------------------------------------------------------------------- /clase 14/babel/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "babel", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "babel-cli": "^6.26.0", 14 | "babel-preset-env": "^1.7.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clase 21/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "name": "clase-21", 4 | "version": "1.0.0", 5 | "description": "", 6 | "main": "01-index.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "firebase-admin": "^10.0.0", 14 | "mongoose": "^6.0.11" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clase 5/06-edad.js: -------------------------------------------------------------------------------- 1 | const moment = require('moment'); 2 | 3 | const hoy = moment(); 4 | const nacimiento = moment([1976,08,09]); 5 | console.log(`Hoy es ${hoy.format('DD/MM/YYYY')}`); 6 | console.log(`Naci el ${nacimiento.format('DD/MM/YYYY')}`); 7 | console.log(`Desde mi nacimiento han pasado ${hoy.diff(nacimiento,"y")} años`); 8 | console.log(`Desde mi nacimiento han pasado ${hoy.diff(nacimiento,"d")} días`); -------------------------------------------------------------------------------- /clase 7/01-edad.js: -------------------------------------------------------------------------------- 1 | const moment = require('moment'); 2 | 3 | const hoy = moment(); 4 | const nacimiento = moment([1976,8,9]); 5 | console.log(`Hoy es ${hoy.format('DD/MM/YYYY')}`); 6 | console.log(`Naci el ${nacimiento.format('DD/MM/YYYY')}`); 7 | console.log(`Desde mi nacimiento han pasado ${hoy.diff(nacimiento,"y")} años`); 8 | console.log(`Desde mi nacimiento han pasado ${hoy.diff(nacimiento,"d")} días`); -------------------------------------------------------------------------------- /clase 12/public/indexx.js: -------------------------------------------------------------------------------- 1 | const socket = io(); 2 | 3 | socket.on('mi mensaje', (data) => { 4 | alert(data); 5 | socket.emit('notificacion', 'mensaje recibido exitosamente'); 6 | }); 7 | 8 | socket.on('mensajes', (data) => { 9 | console.log('recibiendo mensajes!', data); 10 | }); 11 | 12 | 13 | function enviarMensaje() { 14 | socket.emit('mensaje', 'los saludo desde la página!'); 15 | } -------------------------------------------------------------------------------- /clase 13/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-13", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "nodemon server.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.17.1", 14 | "socket.io": "^4.2.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clase 10/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-10", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "01-server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "express": "^4.17.1", 13 | "express-handlebars": "^5.3.3", 14 | "moment": "^2.29.1" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clase 26/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-26", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "body-parser": "^1.19.0", 13 | "express": "^4.17.1", 14 | "express-session": "^1.17.2" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /clase 28/09-exec.js: -------------------------------------------------------------------------------- 1 | const {exec} = require('child_process'); 2 | 3 | exec('dir', (error, stdout, stderr)=>{ 4 | if (error) { 5 | console.error('Error', error.message); 6 | return; 7 | } 8 | if (stderr) { 9 | console.error('Stderr', stderr); 10 | return; 11 | } 12 | console.log('Stdout', stdout); 13 | }); 14 | 15 | console.log('El exec es no bloqueante...'); -------------------------------------------------------------------------------- /clase 4/01-generadora.js: -------------------------------------------------------------------------------- 1 | function *creaIds(){ 2 | let indice = 0; 3 | while (indice<3) { 4 | yield indice++; 5 | } 6 | return indice; 7 | } 8 | 9 | let creadorIds = creaIds(); 10 | 11 | // console.log(creadorIds); 12 | console.log(creadorIds.next().value); 13 | console.log(creadorIds.next()); 14 | console.log(creadorIds.next()); 15 | console.log(creadorIds.next()); 16 | 17 | 18 | -------------------------------------------------------------------------------- /clase 2/typescript/ejemplo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ejemplo", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "compile": ".\\node_modules\\.bin\\tsc archivo", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "typescript": "^4.3.5" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /clase 3/06-sincro.js: -------------------------------------------------------------------------------- 1 | const delay = ret => { 2 | for(let i=0; i { 6 | if (error) { 7 | console.log('Hubo un error en la escritura del archivo'); 8 | } else { 9 | console.log('Archivo grabado!'); 10 | } 11 | }); 12 | 13 | console.log('final del programa'); 14 | -------------------------------------------------------------------------------- /clase 2/typescript/ejemplo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs", 4 | "target": "es5", 5 | "lib":[ 6 | "ES2015", 7 | "DOM" 8 | ], 9 | "noImplicitAny": false, 10 | "outDir": "built", 11 | "rootDir": ".", 12 | "sourceMap": false 13 | }, 14 | "exclude": [ 15 | "node_modules" 16 | ] 17 | } -------------------------------------------------------------------------------- /clase 6/09-appendasync.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | fs.appendFile('./archivos/prueba.txt', 'Estoy agregando datos async...', (error) => { 6 | if (error) { 7 | console.log('Hubo un error en el append del archivo'); 8 | } else { 9 | console.log('Archivo con datos agregados!'); 10 | } 11 | }); 12 | 13 | console.log('final del programa'); 14 | -------------------------------------------------------------------------------- /after/sockets/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sockets", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "node server.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "express": "^4.17.1", 15 | "socket.io": "^4.2.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /clase 11/views/partials/header.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /clase 13/chat/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "chat", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "nodemon server.js", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "express": "^4.17.1", 15 | "socket.io": "^4.2.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /clase 27/twitter/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login Usuario 8 | 9 | 10 |

Pantalla de Login

11 | Login con Twitter 12 | 13 | -------------------------------------------------------------------------------- /clase 0/ej1.js: -------------------------------------------------------------------------------- 1 | var num1 = 5; 2 | var num2 = 8; 3 | if (num1 <= num2) { 4 | console.log('numero1 no es mayor que numero2'); 5 | } 6 | if (num2 > 0) { 7 | console.log('numero2 es positivo'); 8 | } 9 | if (num1 < 0 || num1 != 0) { 10 | console.log('numero1 es negativo o distinto de 0'); 11 | } 12 | if (num1 + 1 < num2) { 13 | console.log('incrementar en 1 el valor del numero1 no lo hace mayor o igual que numero2'); 14 | } -------------------------------------------------------------------------------- /clase 10/views/layouts/index.hbs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Mi aplicación fantástica 8 | 9 | 10 | 11 | {{{body}}} 12 | 13 | -------------------------------------------------------------------------------- /clase 13/colores/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "colores", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "paint.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "start": "nodemon server.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "express": "^4.17.1", 15 | "socket.io": "^4.2.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /clase 27/facebook/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login Usuario 8 | 9 | 10 |

Pantalla de Login

11 | Login con Facebook 12 | 13 | -------------------------------------------------------------------------------- /clase 6/15-awaitread.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | async function leerArchivo() { 6 | console.log('a ver'); 7 | try { 8 | const contenido = fs.promises.readFile('./info.txt', 'utf-8') 9 | console.log(contenido); 10 | } catch(err) { 11 | console.log(err); 12 | } 13 | } 14 | 15 | leerArchivo(); 16 | 17 | console.log('final del programa'); 18 | -------------------------------------------------------------------------------- /clase 7/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-7", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "01-edad.js", 6 | "dependencies": { 7 | "express": "^4.17.1", 8 | "moment": "~2.29.1" 9 | }, 10 | "devDependencies": { 11 | "nodemon": "^2.0.12" 12 | }, 13 | "scripts": { 14 | "test": "echo \"Error: no test specified\" && exit 1" 15 | }, 16 | "author": "", 17 | "license": "ISC" 18 | } 19 | -------------------------------------------------------------------------------- /clase 28/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-28", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "dotenv": { 8 | "version": "10.0.0", 9 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", 10 | "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /clase 3/07-asincro.js: -------------------------------------------------------------------------------- 1 | function hacerTarea(num, cb) { 2 | console.log('haciendo tarea' + num); 3 | setTimeout(cb,3000); 4 | } 5 | 6 | console.log('inicio de tareas'); 7 | hacerTarea(1, ()=> { 8 | hacerTarea(2, ()=> { 9 | hacerTarea(3,()=>{ 10 | hacerTarea(4,()=>{ 11 | console.log('fin de tareas'); 12 | }) 13 | }) 14 | }) 15 | }) 16 | console.log('otras tareas'); 17 | -------------------------------------------------------------------------------- /clase 4/04-promiseb.js: -------------------------------------------------------------------------------- 1 | const miPromesa = new Promise ((resolve, reject)=>{ 2 | let azar = Math.random(); 3 | console.log('Azar: ', azar); 4 | setTimeout(() => azar < 0.5 ? resolve(azar) : reject(azar), 5 | 2000) 6 | }); 7 | 8 | console.log('iniciando...'); 9 | miPromesa 10 | .then(resultado => console.log('Todo ok:', resultado)) 11 | .catch(error => console.log('Error:', error)); 12 | console.log('finalizando...'); -------------------------------------------------------------------------------- /clase 14/ts/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "4.4.3", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", 10 | "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /clase 14/ts2/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts2", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "4.4.3", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", 10 | "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /clase 14/ts3/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts3", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "4.4.3", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.3.tgz", 10 | "integrity": "sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /clase 17/selectRows.js: -------------------------------------------------------------------------------- 1 | const {options} = require('./options/mariaDB'); 2 | const knex = require('knex')(options); 3 | 4 | knex.from('cars').select('*') 5 | .then(autos => { 6 | for (auto of autos) { 7 | console.log(`${auto['id']}. Marca: ${auto['name']} - Precio $${auto['price']}`); 8 | } 9 | knex.destroy(); 10 | }) 11 | .catch(e=>{ 12 | console.log('Error en Select:', e); 13 | knex.destroy(); 14 | }); 15 | 16 | -------------------------------------------------------------------------------- /clase 23/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-23", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "normalizr": { 8 | "version": "3.6.1", 9 | "resolved": "https://registry.npmjs.org/normalizr/-/normalizr-3.6.1.tgz", 10 | "integrity": "sha512-8iEmqXmPtll8PwbEFrbPoDxVw7MKnNvt3PZzR2Xvq9nggEEOgBlNICPXYzyZ4w4AkHUzCU998mdatER3n2VaMA==" 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /clase 0/ej2b.js: -------------------------------------------------------------------------------- 1 | function dondeEstaElFalse(valores) { 2 | posicion = -1; 3 | for (i = 0; i < valores.length; i++) { 4 | if (typeof valores[i] == 'boolean') { 5 | if (!valores[i]) { 6 | return i; 7 | } 8 | } 9 | } 10 | return -1; 11 | } 12 | 13 | valores = [true, 5, "false", false, "hola", "adios", 2]; 14 | console.log('El primer false se encuenta en: ', dondeEstaElFalse(valores)); -------------------------------------------------------------------------------- /clase 11/views/barra-medicion.pug: -------------------------------------------------------------------------------- 1 | html 2 | head 3 | title="Mi página con un componente de barra de progreso" 4 | body 5 | h1( 6 | style={color: 'blue'} 7 | ) !{titulo} 8 | span=min 9 | meter( 10 | min=min 11 | max=max 12 | value=nivel 13 | style={'margin-left': '10px', 'margin-right': '10px', width: '200px'} 14 | ) 15 | span=max -------------------------------------------------------------------------------- /clase 27/jwt/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jwt", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "01-server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "bcrypt": "^5.0.1", 14 | "dotenv": "^10.0.0", 15 | "express": "^4.17.1", 16 | "jsonwebtoken": "^8.5.1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clase 3/02-flecha.js: -------------------------------------------------------------------------------- 1 | // Las funciones son un objeto y se pueden asignar a una variable 2 | // const saludar = () => { 3 | // console.log('Hola a tod@s'); 4 | // console.log('Hola a tod@s!!'); 5 | // return 25; 6 | // } 7 | // console.log(saludar()); 8 | 9 | // const saludarPersona = nombre => console.log(`Hola ${nombre}!`); 10 | // saludarPersona('Juan'); 11 | 12 | const obtener25 = () => 25; 13 | console.log(obtener25()); 14 | 15 | 16 | -------------------------------------------------------------------------------- /clase 1/12-clases.js: -------------------------------------------------------------------------------- 1 | class Perro { 2 | constructor(nombre, raza, edad) { 3 | this.nombre = nombre; 4 | this.raza = raza; 5 | this.edad = edad; 6 | } 7 | ladrar() { 8 | console.log('Guau!!!, soy ', this.nombre) 9 | } 10 | } 11 | 12 | 13 | let maxi = new Perro('Maxi', 'Caniche', 3); 14 | console.log(maxi); 15 | maxi.ladrar(); 16 | let pepe = new Perro('Pepe', 'Caniche', 3); 17 | console.log(pepe); 18 | pepe.ladrar(); -------------------------------------------------------------------------------- /clase 4/07-allSettled.js: -------------------------------------------------------------------------------- 1 | const miViaje1 = new Promise ((resolve, reject)=>{ 2 | setTimeout(()=>resolve('Todo OK Viaje 1!!!'), 3 | 2000) 4 | }); 5 | 6 | const miViaje2 = new Promise ((resolve, reject)=>{ 7 | setTimeout(()=>reject('Todo OK Viaje 2!!!'), 8 | 4000) 9 | }); 10 | 11 | console.log('iniciando...'); 12 | Promise.allSettled([miViaje1, miViaje2]) 13 | .then(x=>console.log('Terminé los dos viajes', x)); 14 | console.log('finalizando...'); -------------------------------------------------------------------------------- /clase 17/createTable.js: -------------------------------------------------------------------------------- 1 | const {options} = require('./options/mariaDB'); 2 | const knex = require('knex')(options); 3 | 4 | knex.schema.createTable('cars', table => { 5 | table.increments('id'), 6 | table.string('name'), 7 | table.integer('price') 8 | }) 9 | .then(()=>{ 10 | console.log('tabla creada!'); 11 | knex.destroy(); 12 | }) 13 | .catch(e=>{ 14 | console.log('Error en create de tabla:', e); 15 | knex.destroy(); 16 | }); 17 | 18 | -------------------------------------------------------------------------------- /clase 28/10-execFile.js: -------------------------------------------------------------------------------- 1 | const {execFile} = require('child_process'); 2 | 3 | execFile('C:\\robo3t-1.4.4-windows-x86_64-e6ac9ec5\\robo3t', (error, stdout, stderr)=>{ 4 | if (error) { 5 | console.error('Error', error.message); 6 | return; 7 | } 8 | if (stderr) { 9 | console.error('Stderr', stderr); 10 | return; 11 | } 12 | console.log('Stdout', stdout); 13 | }); 14 | 15 | console.log('El execFile es no bloqueante...'); -------------------------------------------------------------------------------- /facebook/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "facebook", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server-fb.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.17.1", 14 | "express-session": "^1.17.2", 15 | "passport": "^0.5.0", 16 | "passport-facebook": "^3.0.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clase 30/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Document 8 | 9 | 10 | 11 |

Mi Sitio Público

12 | 13 | 14 | -------------------------------------------------------------------------------- /npm/opera/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "module", 3 | "name": "operasiro", 4 | "version": "0.0.2", 5 | "description": "operaciones matemáticas para practicar npm", 6 | "main": "operaciones.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/ssirotinsky/operasiro.git" 13 | }, 14 | "author": "sergio siro", 15 | "license": "MIT" 16 | } 17 | -------------------------------------------------------------------------------- /clase 14/ts2/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts2", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": ".\\node_modules\\.bin\\tsc", 8 | "watch": ".\\node_modules\\.bin\\tsc -w", 9 | "start": "nodemon ./dist/index.js", 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "author": "SS", 13 | "license": "ISC", 14 | "dependencies": { 15 | "typescript": "^4.4.3" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /clase 25/mongo-session/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mongo-session", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "connect-mongo": "^4.6.0", 14 | "express": "^4.17.1", 15 | "express-session": "^1.17.2", 16 | "mongodb": "^4.1.3" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clase 25/redis-session/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "redis-session", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "connect-redis": "^6.0.0", 14 | "express": "^4.17.1", 15 | "express-session": "^1.17.2", 16 | "redis": "^3.1.2" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clase 26/aut-passport/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aut-passport", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "express": "^4.17.1", 14 | "express-session": "^1.17.2", 15 | "passport": "^0.5.0", 16 | "passport-local": "^1.0.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clase 27/facebook/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "facebook", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "dotenv": "^10.0.0", 13 | "express": "^4.17.1", 14 | "express-session": "^1.17.2", 15 | "passport": "^0.5.0", 16 | "passport-facebook": "^3.0.0" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clase 13/colores/public/css/estilos.css: -------------------------------------------------------------------------------- 1 | .mensaje-cyan { 2 | color:cyan 3 | } 4 | 5 | .mensaje-yellow { 6 | color:yellow 7 | } 8 | 9 | .bgcolor { 10 | background-color: black; 11 | } 12 | 13 | .subbg-color { 14 | background-color: rgb(29, 29, 29); 15 | color: rgb(255, 255, 255); 16 | margin: 16px; 17 | height: 2000px; 18 | } 19 | 20 | .canvas-color { 21 | background-color: rgb(255, 255, 255); 22 | } 23 | 24 | .button-pad { 25 | margin: 10pt; 26 | } -------------------------------------------------------------------------------- /clase 14/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-14", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "author": "", 9 | "license": "ISC", 10 | "dependencies": { 11 | "babel-cli": "^6.26.0", 12 | "babel-preset-env": "^1.7.0", 13 | "chalk": "^4.1.2", 14 | "typescript": "^4.4.3" 15 | }, 16 | "devDependencies": {}, 17 | "keywords": [], 18 | "description": "" 19 | } 20 | -------------------------------------------------------------------------------- /clase 17/selectWhere.js: -------------------------------------------------------------------------------- 1 | const {options} = require('./options/mariaDB'); 2 | const knex = require('knex')(options); 3 | 4 | knex.from('cars').select('id', 'name', 'price').where('price', '>', 4000) 5 | .then(autos => { 6 | for (auto of autos) { 7 | console.log(`${auto['id']}. Marca: ${auto['name']} - Precio $${auto['price']}`); 8 | } 9 | knex.destroy(); 10 | }) 11 | .catch(e=>{ 12 | console.log('Error en Select:', e); 13 | knex.destroy(); 14 | }); 15 | 16 | -------------------------------------------------------------------------------- /clase 2/typescript/ejemplo/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ejemplo", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "typescript": { 8 | "version": "4.3.5", 9 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", 10 | "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", 11 | "dev": true 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /clase 29/server-cluster/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server-cluster", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "01-server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "prod": "forever start 02-server.js" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "cluster": "^0.7.7", 15 | "express": "^4.17.1", 16 | "moment": "^2.29.1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clase 11/views/barra-medicion.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Mi componente de medición con EJS 7 | 8 | 9 | 10 |

11 | <%- titulo %> 12 |

13 | <%=min%> 14 | 15 | 16 | <%=max%> 17 | 18 | 19 | -------------------------------------------------------------------------------- /clase 14/ts2/lib/operaciones.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | exports.dividir = exports.multiplicar = exports.restar = exports.sumar = void 0; 4 | var sumar = function (a, b) { return a + b; }; 5 | exports.sumar = sumar; 6 | var restar = function (a, b) { return a - b; }; 7 | exports.restar = restar; 8 | var multiplicar = function (a, b) { return a * b; }; 9 | exports.multiplicar = multiplicar; 10 | var dividir = function (a, b) { return a / b; }; 11 | exports.dividir = dividir; 12 | -------------------------------------------------------------------------------- /clase 2/06-trailing.js: -------------------------------------------------------------------------------- 1 | //permite incorporar nuevos elementos sin modificar las filas anteriores 2 | 3 | let miEquipo = { 4 | club: 'River Plate', 5 | apodo: 'Millonarios', 6 | libertadores: 4, 7 | idolos: ['Marcelo Gallardo', 'Ramón Diaz', 'Enzo Francesoli'], 8 | esGrande: true, 9 | } 10 | 11 | paises = ['Argentina', 12 | 'Chile', 13 | 'Colombia', 14 | 'Ecuador', 15 | 'Paraguay', 16 | 'Perú', 17 | 'Venezuela', 18 | 'Uruguay', 19 | 'Bolivia', 20 | ] -------------------------------------------------------------------------------- /clase 1/09-this.js: -------------------------------------------------------------------------------- 1 | //console.log(this); 2 | 3 | // 'use strict' 4 | // function probandoThis(a, b) { 5 | // console.log(this, a, b); 6 | // } 7 | // probandoThis(1, 2); 8 | 9 | const persona = { 10 | nombre: 'Jorge', 11 | edad: 28, 12 | saludar() { 13 | console.log(`Hola! Soy ${this.nombre} y tengo ${this.edad} años`); 14 | console.log(this); 15 | console.log(this === persona) 16 | } 17 | } 18 | 19 | //persona.saludar(); 20 | let saludar = persona.saludar; 21 | saludar(); -------------------------------------------------------------------------------- /facebook/sslcert/req.cnf: -------------------------------------------------------------------------------- 1 | [req] 2 | distinguished_name = req_distinguished_name 3 | x509_extensions = v3_req 4 | prompt = no 5 | [req_distinguished_name] 6 | C = AR 7 | ST = State 8 | L = Location 9 | O = Organization Name 10 | OU = Organizational Unit 11 | CN = www.localhost.com 12 | [v3_req] 13 | keyUsage = critical, digitalSignature, keyAgreement 14 | extendedKeyUsage = serverAuth 15 | subjectAltName = @alt_names 16 | [alt_names] 17 | DNS.1 = www.localhost.com 18 | DNS.2 = localhost.com 19 | DNS.3 = localhost 20 | -------------------------------------------------------------------------------- /clase 27/facebook/sslcert/req.cnf: -------------------------------------------------------------------------------- 1 | [req] 2 | distinguished_name = req_distinguished_name 3 | x509_extensions = v3_req 4 | prompt = no 5 | [req_distinguished_name] 6 | C = AR 7 | ST = State 8 | L = Location 9 | O = Organization Name 10 | OU = Organizational Unit 11 | CN = www.localhost.com 12 | [v3_req] 13 | keyUsage = critical, digitalSignature, keyAgreement 14 | extendedKeyUsage = serverAuth 15 | subjectAltName = @alt_names 16 | [alt_names] 17 | DNS.1 = www.localhost.com 18 | DNS.2 = localhost.com 19 | DNS.3 = localhost -------------------------------------------------------------------------------- /clase 30/Server01-pm2.json: -------------------------------------------------------------------------------- 1 | { 2 | "script": "01-server.js", 3 | "name": "Server01", 4 | "filter_env": [], 5 | "namespace": "default", 6 | "args": [ 7 | "8081" 8 | ], 9 | "env": {}, 10 | "merge_logs": true, 11 | "vizion": true, 12 | "autorestart": true, 13 | "watch": false, 14 | "instance_var": "NODE_APP_INSTANCE", 15 | "pmx": true, 16 | "automation": true, 17 | "treekill": true, 18 | "username": "Siro", 19 | "windowsHide": true, 20 | "kill_retry_time": 100, 21 | "write": true 22 | } -------------------------------------------------------------------------------- /clase 27/jwt/public/datos.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Información del usuario 8 | 9 | 10 |

Datos del usuario

11 |
12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /clase 5/05-server.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | 3 | var server = http.createServer(function (peticion, respuesta) { 4 | var hora = new Date().getHours(); 5 | if (hora >= 6 && hora <= 12) { 6 | respuesta.end("Buenos dias!"); 7 | } else if (hora >= 13 && hora <= 19) { 8 | respuesta.end("Buenas tardes!"); 9 | } else { 10 | respuesta.end("Buenas noches!"); 11 | } 12 | }); 13 | 14 | server.listen(8080, function() { 15 | console.log('Tu servidor está listo en', this.address().port); 16 | }); -------------------------------------------------------------------------------- /clase 0/ej2a.js: -------------------------------------------------------------------------------- 1 | function textoConMasCaracteres(valores) { 2 | max = 0; 3 | devolver = ''; 4 | for (i = 0; i < valores.length; i++) { 5 | if (typeof valores[i] == 'string') { 6 | if (valores[i].length > max) { 7 | max = valores[i].length; 8 | devolver = valores[i]; 9 | } 10 | } 11 | } 12 | return devolver; 13 | } 14 | 15 | valores = [true, 5, false, "hola", "adios", 2]; 16 | console.log('El texto con más caracteres es: ', textoConMasCaracteres(valores)); -------------------------------------------------------------------------------- /clase 14/ts2/dist/lib/operaciones.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.dividir = exports.multiplicar = exports.restar = exports.sumar = void 0; 4 | var sumar = function (a, b) { return a + b; }; 5 | exports.sumar = sumar; 6 | var restar = function (a, b) { return a - b; }; 7 | exports.restar = restar; 8 | var multiplicar = function (a, b) { return a * b; }; 9 | exports.multiplicar = multiplicar; 10 | var dividir = function (a, b) { return a / b; }; 11 | exports.dividir = dividir; 12 | -------------------------------------------------------------------------------- /clase 27/twitter/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "facebook", 3 | "version": "1.0.0", 4 | "main": "index.js", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "author": "", 9 | "license": "ISC", 10 | "dependencies": { 11 | "dotenv": "^10.0.0", 12 | "express": "^4.17.1", 13 | "express-session": "^1.17.2", 14 | "passport": "^0.5.0", 15 | "passport-facebook": "^3.0.0", 16 | "passport-twitter": "^1.0.4" 17 | }, 18 | "keywords": [], 19 | "description": "" 20 | } 21 | -------------------------------------------------------------------------------- /clase 5/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-5", 3 | "version": "1.0.0", 4 | "description": "prueba de nuevo paquete", 5 | "main": "01-nodemon.js", 6 | "devDependencies": { 7 | "nodemon": "^2.0.12" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified!!!\" && exit 1" 11 | }, 12 | "keywords": [ 13 | "prueba", 14 | "nodejs", 15 | "npm", 16 | "paquete" 17 | ], 18 | "author": "sirotinsky", 19 | "license": "ISC", 20 | "dependencies": { 21 | "moment": "~2.29.1" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /clase 12/public/ej1/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Jugando con Sockets 9 | 10 | 11 | 12 | 13 | 14 | 15 |

EJERCICIO DE SOCKETS.IO

16 | 17 | 18 | -------------------------------------------------------------------------------- /clase 14/ts2/index.ts: -------------------------------------------------------------------------------- 1 | import * as operaciones from './lib/operaciones' 2 | 3 | const mensaje:string = 'Hola typescript!!!' 4 | console.log(mensaje); 5 | 6 | let num1:number = 10, num2:number = 4 7 | console.log(`La suma de ${num1} + ${num2} es ${operaciones.sumar(num1,num2)}`) 8 | console.log(`La resta de ${num1} - ${num2} es ${operaciones.restar(num1,num2)}`) 9 | console.log(`La multiplicación de ${num1} * ${num2} es ${operaciones.multiplicar(num1,num2)}`) 10 | console.log(`La división de ${num1} / ${num2} es ${operaciones.dividir(num1,num2)}`) 11 | -------------------------------------------------------------------------------- /clase 6/16-ejemplo.js: -------------------------------------------------------------------------------- 1 | import fs from 'fs'; 2 | 3 | console.log('inicio del programa'); 4 | 5 | fs.promises.readFile('./info.txt', 'utf-8') 6 | .then(contenido=>{ 7 | let info = JSON.parse(contenido); 8 | info.contenidoObj.author = 'Coderhouse'; 9 | let grabar = JSON.stringify(info.contenidoObj, null, '\t'); 10 | fs.promises.writeFile('./package.json.coder', grabar); 11 | }) 12 | .then(()=>console.log('Archivo guardado!')) 13 | .catch(error=>{ 14 | console.log('Error!', error); 15 | }); 16 | 17 | console.log('final del programa'); 18 | -------------------------------------------------------------------------------- /clase 15/ts/src/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import express from 'express'; 3 | import { Persona } from './lib/classes'; 4 | 5 | const operaciones = require('./lib/functions.js'); 6 | 7 | const person:Persona = new Persona ('coder', 'house'); 8 | 9 | const app = express(); 10 | 11 | app.get('/',(req,res)=>{ 12 | res.send({timeES6: operaciones.getTime(), fullNameTS: person.getFullName()}); 13 | }); 14 | 15 | const PORT:number = 8080; 16 | app.listen(PORT, () => { 17 | console.log(`Servidor expressss TypeScript/WebPack escuchando en el puerto ${PORT}`) 18 | }); 19 | -------------------------------------------------------------------------------- /clase 17/insertRows.js: -------------------------------------------------------------------------------- 1 | const {options} = require('./options/mariaDB'); 2 | const knex = require('knex')(options); 3 | 4 | const cars = [ 5 | {name: 'Audi', price: 12000}, 6 | {name: 'Ford', price: 3000}, 7 | {name: 'Fiat', price: 2000}, 8 | {name: 'Renault', price: 4500}, 9 | {name: 'Peugeot', price: 4500} 10 | ]; 11 | 12 | knex('cars').insert(cars) 13 | .then (()=>{ 14 | console.log('Filas insertadas!'); 15 | knex.destroy(); 16 | }) 17 | .catch(e=>{ 18 | console.log('Error en Insert:', e); 19 | knex.destroy(); 20 | }) 21 | -------------------------------------------------------------------------------- /clase 3/03-funcion-como-parametro.js: -------------------------------------------------------------------------------- 1 | // const hagoAlgo = (miFuncion) => { 2 | // console.log('Hago algo...'); 3 | // miFuncion(); 4 | // } 5 | 6 | // const soloSaludo = () => console.log('Sólo saludo'); 7 | // hagoAlgo(soloSaludo); 8 | // hagoAlgo(() => console.log('Sólo saludo')); 9 | 10 | 11 | const hagoAlgo = (miFuncion, param) => { 12 | console.log('Hago algo...'); 13 | miFuncion(param); 14 | } 15 | 16 | const saludoPersona = (nombre) => console.log(`Hola ${nombre}!`); 17 | // // saludoPersona('Juan'); 18 | hagoAlgo(saludoPersona, 'Pedro'); -------------------------------------------------------------------------------- /clase 9/01-router.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | const router = express.Router(); 6 | 7 | app.use('/', router); 8 | 9 | const server = app.listen(PORT, ()=>{ 10 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 11 | }); 12 | server.on('error', error=>console.log('Error en servidor', error)); 13 | 14 | router.get('/', (req,res)=>{ 15 | const objRes = { 16 | msg: 'Bienvenidos a mi Aplicación!', 17 | error: false 18 | }; 19 | res.json(objRes); 20 | }); -------------------------------------------------------------------------------- /after/sockets/public/goles.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Liga Argentina de Fútbol 8 | 9 | 10 | 11 | 12 | 13 |

Actualizar resultados on-line

14 |
15 | 16 | -------------------------------------------------------------------------------- /clase 15/ts/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | mode: 'production', 5 | entry: './src/index.ts', 6 | target: 'node', 7 | output: { 8 | path: path.resolve(__dirname, 'dist'), 9 | filename: 'main.js' 10 | }, 11 | resolve: { 12 | extensions: ['.ts', '.js'] 13 | }, 14 | module: { 15 | rules: [ 16 | { 17 | test: /\.tsx?/, 18 | use:'ts-loader', 19 | exclude: /node_modules/ 20 | } 21 | ] 22 | } 23 | }; -------------------------------------------------------------------------------- /clase 12/02-sockets.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const { Server: HttpServer } = require('http'); 3 | const { Server: IOServer } = require('socket.io'); 4 | 5 | const app = express(); 6 | const httpServer = new HttpServer(app); 7 | const io = new IOServer(httpServer); 8 | 9 | const PORT = 3030; 10 | 11 | app.use(express.static('./public')); 12 | 13 | httpServer.listen(PORT, () => { 14 | console.log('Servidor HTTP escuchando en el puerto', PORT); 15 | }); 16 | 17 | io.on('connection', (socket) => { 18 | 19 | console.log('Nuevo cliente conectado!'); 20 | 21 | }); -------------------------------------------------------------------------------- /clase 2/03-ejemplo.js: -------------------------------------------------------------------------------- 1 | let operaciones = ['6**2', '**', '3**3', '4**', '4**5', '8**2**', '4*=5']; 2 | 3 | const resultado = (e) => { 4 | let dividido = e.split(''); 5 | if (dividido.includes('*', 1) && dividido.includes('*', 2)) { 6 | if (dividido.length == 4) { 7 | let numA = Number(dividido[0]); 8 | let numB = Number(dividido[3]); 9 | if (!isNaN(numA) && !isNaN(numB)) { 10 | return numA ** numB 11 | } 12 | } 13 | } 14 | return null; 15 | } 16 | 17 | console.log(operaciones.map(resultado)); -------------------------------------------------------------------------------- /clase 3/04-ejemplo.js: -------------------------------------------------------------------------------- 1 | const operacion = (num1, num2, tipoOperacion) => tipoOperacion(num1, num2); 2 | 3 | const suma = (num1, num2) => num1 + num2; 4 | const resta = (num1, num2) => num1 - num2; 5 | const multiplicacion = (num1, num2) => num1 * num2; 6 | const division = (num1, num2) => num1 / num2; 7 | const modulo = (num1, num2) => num1 % num2; 8 | 9 | console.log(suma); 10 | console.log(operacion(3,5,suma)); 11 | console.log(operacion(9,5,resta)); 12 | console.log(operacion(2,9,multiplicacion)); 13 | console.log(operacion(18,3,division)); 14 | console.log(operacion(20,3,modulo)); -------------------------------------------------------------------------------- /clase 15/perimetro/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | module.exports = { 4 | mode: 'production', 5 | entry: './src/index.ts', 6 | target: 'node', 7 | output: { 8 | path: path.resolve(__dirname, 'dist'), 9 | filename: 'main.js' 10 | }, 11 | resolve: { 12 | extensions: ['.ts', '.js'] 13 | }, 14 | module: { 15 | rules: [ 16 | { 17 | test: /\.tsx?/, 18 | use:'ts-loader', 19 | exclude: /node_modules/ 20 | } 21 | ] 22 | } 23 | }; -------------------------------------------------------------------------------- /clase 2/01-include.js: -------------------------------------------------------------------------------- 1 | let miLista = [24, 36, 'jorge', 'pedro', 'casa']; 2 | 3 | console.log(miLista.includes('jorge')); // true 4 | console.log(miLista.includes('Jorge')); // false pues es case sensitive (distingue mayúsculas de minúsculas) 5 | console.log(miLista.includes('jorge', 1)); // true pues se encuentra en la posición 2 6 | console.log(miLista.includes('jorge', 3)); // false pues se encuentra en la posición 2 7 | console.log(miLista.includes('jorge', -1)); // false pues se encuentra en la posición -3 8 | console.log(miLista.includes('jorge', -3)); // true pues se encuentra en la posición -3 -------------------------------------------------------------------------------- /clase 6/info.txt: -------------------------------------------------------------------------------- 1 | { 2 | "contenidoStr": "{\n \"name\": \"clase-6\",\n \"version\": \"1.0.0\",\n \"description\": \"\",\n \"main\": \"01-readsync.js\",\n \"scripts\": {\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"author\": \"\",\n \"license\": \"ISC\"\n}\n", 3 | "contenidoObj": { 4 | "name": "clase-6", 5 | "version": "1.0.0", 6 | "description": "", 7 | "main": "01-readsync.js", 8 | "scripts": { 9 | "test": "echo \"Error: no test specified\" && exit 1" 10 | }, 11 | "author": "", 12 | "license": "ISC" 13 | }, 14 | "size": 209 15 | } -------------------------------------------------------------------------------- /clase 2/19-optionalChaining.js: -------------------------------------------------------------------------------- 1 | // let infoCliente = { 2 | // nombre: "Pedro", 3 | // edad: 25, 4 | // telefono: { 5 | // pais: 54, 6 | // prefijo: 11, 7 | // numero: 45287610 8 | // } 9 | // } 10 | 11 | // console.log(infoCliente.telefono.numero); 12 | 13 | let infoClienteNuevo = { 14 | nombre: "Pedro", 15 | edad: 25 16 | } 17 | 18 | // console.log(infoClienteNuevo.telefono.numero); 19 | console.log(infoClienteNuevo.telefono?.numero); 20 | 21 | //Antes: 22 | // console.log(infoClienteNuevo.telefono && infoClienteNuevo.telefono.numero); 23 | -------------------------------------------------------------------------------- /after/sockets/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Liga Argentina de Fútbol 8 | 9 | 10 | 11 | 12 | 13 |

Resultados on-line

14 |
15 |
16 | 17 | -------------------------------------------------------------------------------- /clase 12/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Jugando a los websockets 9 | 10 | 11 | 12 | 13 | 14 | Ingrese: 15 |

16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /clase 12/public/indexx.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Jugando con Sockets 9 | 10 | 11 | 12 | 13 | 14 | 15 |

TUTORIAL DE SOCKETS.IO

16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /clase 17/selectOrderBy.js: -------------------------------------------------------------------------------- 1 | const {options} = require('./options/mariaDB'); 2 | const knex = require('knex')(options); 3 | 4 | // knex.from('cars').select('id', 'name', 'price').where('price', '>', 4000).orderBy('price') 5 | knex.from('cars').select('id', 'name', 'price').where('price', '>', 4000).orderBy('price','desc') 6 | .then(autos => { 7 | for (auto of autos) { 8 | console.log(`${auto['id']}. Marca: ${auto['name']} - Precio $${auto['price']}`); 9 | } 10 | knex.destroy(); 11 | }) 12 | .catch(e=>{ 13 | console.log('Error en Select:', e); 14 | knex.destroy(); 15 | }); 16 | 17 | -------------------------------------------------------------------------------- /clase 11/01-pug.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | const server = app.listen(PORT, () => { 7 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 8 | }); 9 | server.on('error', error => console.log('Error en servidor', error)); 10 | 11 | app.set('views', './views'); 12 | app.set('view engine', 'pug'); 13 | 14 | 15 | app.get('/prueba', (req, res) => { 16 | res.send('probando'); 17 | }); 18 | 19 | app.get('/hello', (req, res) => { 20 | res.render('hello.pug', { mensaje: 'Bienvenidos a mi sitio!!!!' }); 21 | }); -------------------------------------------------------------------------------- /clase 22/03-faker.js: -------------------------------------------------------------------------------- 1 | const faker = require('faker'); 2 | const fs = require('fs'); 3 | 4 | let str = "NOMBRE,APELLIDO,EMAIL,TRABAJO,LUGAR\n"; 5 | 6 | for (let i=0;i<100;i++){ 7 | str += faker.name.firstName() + ',' + 8 | faker.name.lastName() + ',' + 9 | faker.internet.email() + ',' + 10 | faker.name.jobTitle() + ',' + 11 | faker.random.locale() + '\n' 12 | } 13 | 14 | fs.writeFile('./datosFake.csv', str, (err)=>{ 15 | if (err) { 16 | console.log('Error en la grabación'); 17 | } else { 18 | console.log('Archivo fake generado'); 19 | } 20 | }); -------------------------------------------------------------------------------- /clase 29/server-cluster/02-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const moment = require('moment'); 3 | 4 | const app = express(); 5 | const PORT = process.argv[2] || 8080; 6 | 7 | console.log(PORT); 8 | 9 | const server = app.listen(PORT, ()=>{ 10 | console.log('Servidor HTTP escuchando en el port!', server.address().port, '. Process ID: ', process.pid); 11 | }); 12 | server.on('error', error=>console.log('Error en servidor', error)); 13 | 14 | app.get('/', (req,res)=>{ 15 | res.send(`Servidor express en ${PORT} - PID ${process.pid} - ${moment().format('DD/MM/YYYY HH:mm')}`); 16 | }); 17 | 18 | -------------------------------------------------------------------------------- /clase 8/01-get.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | const server = app.listen(PORT, ()=>{ 7 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 8 | }); 9 | server.on('error', error=>console.log('Error en servidor', error)); 10 | 11 | //Incorporamos get a api/mensajes 12 | app.get('/api/mensajes', (req,res)=>{ 13 | console.log('get request a api/mensajes recibido'); 14 | const objRes = { 15 | msg: 'Hola Mundo!', 16 | saludos: 1000, 17 | error: false 18 | }; 19 | res.json(objRes); 20 | }); -------------------------------------------------------------------------------- /clase 3/08-mostrarLetras.js: -------------------------------------------------------------------------------- 1 | const mostrarLetras = (param, callback) => { 2 | let i = 0; 3 | let idInterval = setInterval( 4 | ()=>{ 5 | console.log(param[i++]); 6 | if (i == param.length) { 7 | clearInterval(idInterval); 8 | callback(); 9 | } 10 | }, 11 | 1000 12 | ) 13 | } 14 | 15 | const fin = () => console.log('terminé'); 16 | 17 | mostrarLetras('¡Hola!', fin); 18 | //Dos formas de utilizar la función del setTimeout: 19 | setTimeout(mostrarLetras, 250, 'Hola', fin); 20 | setTimeout(()=>mostrarLetras('¡Hola!', fin), 500); -------------------------------------------------------------------------------- /clase 14/ts2/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | var operaciones = require("./lib/operaciones"); 4 | var mensaje = 'Hola typescript!'; 5 | console.log(mensaje); 6 | var num1 = 10, num2 = 4; 7 | console.log("La sumaaaaa de " + num1 + " + " + num2 + " es " + operaciones.sumar(num1, num2)); 8 | console.log("La resta de " + num1 + " - " + num2 + " es " + operaciones.restar(num1, num2)); 9 | console.log("La multiplicaci\u00F3n de " + num1 + " * " + num2 + " es " + operaciones.multiplicar(num1, num2)); 10 | console.log("La divisi\u00F3n de " + num1 + " / " + num2 + " es " + operaciones.dividir(num1, num2)); 11 | -------------------------------------------------------------------------------- /clase 2/08-rest.js: -------------------------------------------------------------------------------- 1 | //Destructuración de objetos: 2 | let cliente = { 3 | nombres: 'Ariel Arnaldo', 4 | apellido: 'Ortega', 5 | edad: 47, 6 | goles: 140 7 | }; 8 | // let { nombres, edad, goles, noexiste } = cliente; 9 | // console.log(nombres, edad, goles, noexiste); 10 | //nombres = cliente.nombres 11 | //edad = cliente.edad 12 | //goles = cliente.goles 13 | 14 | // Propiedades rest: 15 | // let { apellido, ...info } = cliente; 16 | // console.log( info); 17 | 18 | //Propiedades spread: 19 | let nuevoCliente = { 20 | ...cliente, 21 | club: 'River Plate', 22 | esIdolo: true 23 | }; 24 | console.log(nuevoCliente); -------------------------------------------------------------------------------- /clase 12/public/ej2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Jugando con Sockets 9 | 10 | 11 | 12 | 13 | 14 | 15 |

EJERCICIO DE SOCKETS.IO

16 | Ingrese un texto: 17 |

18 | 19 | 20 | -------------------------------------------------------------------------------- /clase 15/ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ts", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "dist/main.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "build": ".\\node_modules\\.bin\\webpack -w", 9 | "start": "nodemon ." 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "devDependencies": { 15 | "ts-loader": "^8.2.0", 16 | "typescript": "^4.4.3", 17 | "webpack": "^4.46.0", 18 | "webpack-cli": "^3.3.12" 19 | }, 20 | "dependencies": { 21 | "@types/express": "^4.17.13", 22 | "express": "^4.17.1" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /clase 15/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "clase-15", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "mensajes.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "prod": ".\\node_modules\\.bin\\webpack ./index1.js ./index2.js ./index3.js -o mensajes.js --mode='production' -w", 9 | "dev": ".\\node_modules\\.bin\\webpack ./index1.js ./index2.js ./index3.js -o mensajes.js --mode='development' -w", 10 | "start": "nodemon ." 11 | }, 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "webpack": "^4.46.0", 16 | "webpack-cli": "^3.3.12" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /clase 15/perimetro/src/lib/perimetro.ts: -------------------------------------------------------------------------------- 1 | export class Perimetro { 2 | 3 | private lado1: number; 4 | private lado2: number; 5 | private radio: number; 6 | 7 | constructor(lado1: number, lado2: number, radio: number){ 8 | this.lado1 = lado1; 9 | this.lado2 = lado2; 10 | this.radio = radio; 11 | } 12 | 13 | cuadrado():number { 14 | return this.lado1 * 4; 15 | } 16 | 17 | rectangulo():number { 18 | return this.lado1 * 2 + this.lado2 * 2; 19 | } 20 | 21 | circulo():number { 22 | const PI = 3.14159; 23 | return 2 * PI * this.radio; 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /clase 2/17-privateClass.js: -------------------------------------------------------------------------------- 1 | class Persona { 2 | 3 | #cliente 4 | 5 | constructor(nombre, edad) { 6 | this.nombre = nombre; 7 | this.edad = edad; 8 | this.#cliente = true; 9 | } 10 | 11 | getCliente(){ 12 | return this.#cliente; 13 | } 14 | 15 | setCliente(cliente){ 16 | this.#cliente = cliente; 17 | } 18 | 19 | } 20 | 21 | let pedro = new Persona("pedro", 25); 22 | console.log(pedro); 23 | pedro.edad++; 24 | // pedro.#cliente = false; 25 | // console.log(pedro.#cliente); 26 | console.log(pedro.getCliente()); 27 | pedro.setCliente(false); 28 | console.log(pedro.getCliente()); 29 | 30 | -------------------------------------------------------------------------------- /clase 13/chat/public/js/index.js: -------------------------------------------------------------------------------- 1 | const socket = io(); 2 | 3 | socket.on('mensajes', (data)=>{ 4 | render(data); 5 | }); 6 | 7 | let render = (data) => { 8 | let html = 9 | data.map((m)=>` 10 |
11 | ${m.autor} 12 | ${m.texto} 13 |
14 | `).join(' '); 15 | document.getElementById('mensajes').innerHTML = html; 16 | } 17 | 18 | function envioMensaje(f){ 19 | let autor = document.getElementById('nombre').value; 20 | let texto = document.getElementById('mensaje').value; 21 | socket.emit('nuevo', {autor, texto}); 22 | return false; 23 | } -------------------------------------------------------------------------------- /clase 13/public/main.js: -------------------------------------------------------------------------------- 1 | let socket = io(); 2 | 3 | socket.on('mensajes', (data)=>{ 4 | render(data); 5 | }); 6 | 7 | let render = (data) => { 8 | let html = data.map((e,i)=>` 9 |
10 | ${e.autor} 11 | ${e.texto} 12 |
13 | `).join(' '); 14 | document.getElementById("mensajes").innerHTML = html; 15 | } 16 | 17 | function enviarMensaje(e){ 18 | let envio = { 19 | autor: document.getElementById('usuario').value, 20 | texto: document.getElementById('texto').value, 21 | } 22 | socket.emit('nuevo-mensaje', envio); 23 | return false; 24 | } -------------------------------------------------------------------------------- /clase 4/06-finally.js: -------------------------------------------------------------------------------- 1 | function yendoAConsultar(valor) { 2 | return new Promise ((resolve, reject)=>{ 3 | setTimeout(()=>{ 4 | if (valor == 'ok') { 5 | resolve('Este es el contenido de la consulta'); 6 | } else { 7 | reject ('Canceló la consulta sin valor'); 8 | } 9 | },2000) 10 | }); 11 | } 12 | 13 | console.log('Iniciando...'); 14 | yendoAConsultar('okss') 15 | .then(x=>console.log('Volvió la consulta', x)) 16 | .catch(x=>console.log('Canceló la consulta', x)) 17 | .finally(()=>console.log('Terminó la consulta')); 18 | console.log('Finalizando...'); 19 | -------------------------------------------------------------------------------- /clase 15/perimetro/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "perimetro", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "./dist/main.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "build": ".\\node_modules\\.bin\\webpack -w", 9 | "start": "nodemon ." 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "devDependencies": { 15 | "ts-loader": "^8.2.0", 16 | "typescript": "^4.4.3", 17 | "webpack": "^4.46.0", 18 | "webpack-cli": "^3.3.12" 19 | }, 20 | "dependencies": { 21 | "@types/express": "^4.17.13", 22 | "express": "^4.17.1" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /clase 27/twitter/routes.js: -------------------------------------------------------------------------------- 1 | 2 | function getLogout(req, res){ 3 | req.logout(); 4 | res.redirect('/'); 5 | } 6 | 7 | function failRoute(req, res){ 8 | res.status(404).send('Ruta no encontrada'); 9 | } 10 | 11 | function getRutaProtegida(req, res){ 12 | res.send('

Pude ingresar a la ruta protegida

'); 13 | } 14 | 15 | function getDatos(req,res){ 16 | if (req.isAuthenticated()) { 17 | let user = req.user; 18 | res.json({user}); 19 | } else { 20 | res.redirect('/index.html'); 21 | } 22 | } 23 | 24 | module.exports = { 25 | getLogout, 26 | getRutaProtegida, 27 | getDatos, 28 | failRoute 29 | } -------------------------------------------------------------------------------- /clase 15/perimetro/src/lib/superficie.ts: -------------------------------------------------------------------------------- 1 | export class Superficie { 2 | 3 | private lado1: number; 4 | private lado2: number; 5 | private radio: number; 6 | 7 | constructor(lado1: number, lado2: number, radio: number){ 8 | this.lado1 = lado1; 9 | this.lado2 = lado2; 10 | this.radio = radio; 11 | } 12 | 13 | cuadrado():number { 14 | return this.lado1 * this.lado1; 15 | } 16 | 17 | rectangulo():number { 18 | return this.lado1 * this.lado2; 19 | } 20 | 21 | circulo():number { 22 | const PI = 3.14159; 23 | return PI * this.radio * this.radio; 24 | } 25 | 26 | } -------------------------------------------------------------------------------- /clase 27/facebook/routes.js: -------------------------------------------------------------------------------- 1 | 2 | function getLogout(req, res){ 3 | req.logout(); 4 | res.redirect('/'); 5 | } 6 | 7 | function failRoute(req, res){ 8 | res.status(404).send('Ruta no encontrada'); 9 | } 10 | 11 | function getRutaProtegida(req, res){ 12 | res.send('

Pude ingresar a la ruta protegida

'); 13 | } 14 | 15 | function getDatos(req,res){ 16 | if (req.isAuthenticated()) { 17 | let user = req.user; 18 | res.json({user}); 19 | } else { 20 | res.redirect('/index.html'); 21 | } 22 | } 23 | 24 | module.exports = { 25 | getLogout, 26 | getRutaProtegida, 27 | getDatos, 28 | failRoute 29 | } -------------------------------------------------------------------------------- /clase 12/public/ej3/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Jugando con Sockets 9 | 10 | 11 | 12 | 13 | 14 | 15 |

EJERCICIO DE SOCKETS.IO

16 | Ingrese un texto: 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /clase 22/mocks/router/usuarios.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = express.Router(); 3 | const api = require('../api/usuarios'); 4 | 5 | const notFound = (req, res) => { 6 | let {url, method} = req; 7 | res.send(`La ruta ${method}${url} no fue definida`); 8 | } 9 | 10 | function set(){ 11 | router.get('/generar/:cant?', api.generar); 12 | router.get('/:id?', api.get); 13 | router.post('/', api.post); 14 | router.put('/:id', api.put); 15 | router.delete('/:id', api.del); 16 | return router; 17 | } 18 | 19 | module.exports = { 20 | set, 21 | notFound 22 | } -------------------------------------------------------------------------------- /clase 4/09-await.js: -------------------------------------------------------------------------------- 1 | function resolverDespuesDe2Segundos() { 2 | return new Promise(resolve => { 3 | setTimeout(() => { 4 | resolve('Todo Ok!!!'); 5 | }, 2000); 6 | }); 7 | } 8 | 9 | async function asyncCall() { 10 | console.log('iniciando...'); 11 | // await resolverDespuesDe2Segundos(); 12 | // console.log(await resolverDespuesDe2Segundos()); 13 | console.log('esperando...') 14 | const resultado = await resolverDespuesDe2Segundos(); 15 | console.log('resultado:', resultado); 16 | console.log('finalizando...'); 17 | return 25; 18 | } 19 | 20 | console.log('Inicio del PGM'); 21 | asyncCall().then(x=>console.log(x)); 22 | -------------------------------------------------------------------------------- /clase 12/03-sockets.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const { Server: HttpServer } = require('http'); 3 | const { Server: IOServer } = require('socket.io'); 4 | 5 | const app = express(); 6 | const httpServer = new HttpServer(app); 7 | const io = new IOServer(httpServer); 8 | 9 | const PORT = 3030; 10 | 11 | app.use(express.static('./public')); 12 | 13 | httpServer.listen(PORT, () => { 14 | console.log('Servidor HTTP escuchando en el puerto', PORT); 15 | }); 16 | 17 | io.on('connection', (socket) => { 18 | 19 | console.log('Nuevo cliente conectado!'); 20 | 21 | socket.on('texto', (data) => { 22 | io.sockets.emit('broadcast', data); 23 | }); 24 | 25 | }); -------------------------------------------------------------------------------- /after/callbacks/00-filter.js: -------------------------------------------------------------------------------- 1 | const misNumeros = [0,1,2,3,4,5,6,7,8,9,10]; 2 | const misNumerosPares = misNumeros.filter(e=>e%2==0); 3 | // const misNumerosParesMenoresA5 = misNumerosPares.filter(e=>e<5); 4 | const misNumerosParesMenoresA5 = misNumeros.filter(e=>e%2==0).filter(e=>e<5); 5 | console.log(misNumerosParesMenoresA5); 6 | 7 | // const filtrar = (miArray, miFuncion) => { 8 | // let result = []; 9 | // for (let elemento in miArray) { 10 | // if (miFuncion(elemento)) { 11 | // result.push(elemento); 12 | // } 13 | // } 14 | // return result; 15 | // } 16 | 17 | // const esPar = (e) => e%2==0; 18 | 19 | // console.log(filtrar(misNumeros, esPar)); -------------------------------------------------------------------------------- /clase 21/models/estudiantes.js: -------------------------------------------------------------------------------- 1 | let mongoose = require('mongoose'); 2 | const estudiantesCollection = 'estudiantes'; 3 | 4 | const EstudianteEsquema = mongoose.Schema({ 5 | nombre: {type: String, require: true, minLength: 3, maxLenghth: 20}, 6 | apellido: {type: String, require: true, minLength: 3, maxLenghth: 25}, 7 | edad: {type: Number, require: true, min: 18, max: 99}, 8 | dni: {type: String, require: true, unique: true, minLength: 6, maxLenghth: 8}, 9 | curso: {type: String, require: true}, 10 | nota: {type: Number, require: true, min: 0, max: 10}, 11 | }); 12 | 13 | module.exports = { 14 | Estudiante: mongoose.model(estudiantesCollection, EstudianteEsquema) 15 | } -------------------------------------------------------------------------------- /clase 20/models/estudiantes.js: -------------------------------------------------------------------------------- 1 | let mongoose = require('mongoose'); 2 | const estudiantesCollection = 'estudiantes'; 3 | 4 | const EstudianteEsquema = mongoose.Schema({ 5 | nombre: {type: String, required: true, minLength: 3, maxLenghth: 20}, 6 | apellido: {type: String, required: true, minLength: 3, maxLenghth: 25}, 7 | edad: {type: Number, required: false, min: 18, max: 99}, 8 | dni: {type: String, required: true, unique: true, minLength: 6, maxLenghth: 8}, 9 | curso: {type: String, required: true}, 10 | nota: {type: Number, required: true, min: 0, max: 10}, 11 | }); 12 | 13 | module.exports = { 14 | Estudiante: mongoose.model(estudiantesCollection, EstudianteEsquema) 15 | } -------------------------------------------------------------------------------- /clase 0/ej2c.js: -------------------------------------------------------------------------------- 1 | function operarSobreArray(valores, tipoOperacion) { 2 | numeros = valores.filter(function(e) { 3 | if (typeof e == 'number') { 4 | return e; 5 | } 6 | }) 7 | switch (tipoOperacion) { 8 | case "suma": 9 | return numeros[0] + numeros[1]; 10 | case "resta": 11 | return numeros[0] - numeros[1]; 12 | case "mult": 13 | return numeros[0] * numeros[1]; 14 | case "div": 15 | return numeros[0] / numeros[1]; 16 | } 17 | } 18 | 19 | valores = [true, 5, "false", false, "hola", "adios", 2]; 20 | console.log('La suma entre los valores numéricos es: ', operarSobreArray(valores, "suma")) -------------------------------------------------------------------------------- /clase 22/mocks/server-fake.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const router = require('./router/usuarios'); 3 | 4 | const app = express(); 5 | app.use(express.json()); 6 | app.use('/api', router.set()); 7 | 8 | const PORT = 8080; 9 | 10 | const server = app.listen(PORT, ()=>{ 11 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 12 | }); 13 | server.on('error', error=>console.log('Error en servidor', error)); 14 | 15 | app.get('/test', (req,res)=>{ 16 | res.send("Soy el server fake y estoy levantado..."); 17 | }); 18 | 19 | app.get('*', router.notFound); 20 | app.post('*', router.notFound); 21 | app.put('*', router.notFound); 22 | app.delete('*', router.notFound); -------------------------------------------------------------------------------- /clase 28/11-spawn.js: -------------------------------------------------------------------------------- 1 | const {spawn} = require('child_process'); 2 | 3 | const child = spawn('dir', ['/s'], {shell: true}); 4 | 5 | child.stdout.on('data', data => console.log('data', data.toString())); 6 | 7 | child.stderr.on('data', data => console.error('error', data.toString())); 8 | 9 | console.log('El spawn es no bloqueante...'); 10 | 11 | 12 | //Diferencias entre spawn y exec: 13 | // Usa spawn cuando quieras que el proceso hijo devuelva datos binarios enormes a Node. 14 | // Usa exec cuando quieras que el proceso hijo devuelva mensajes de estado simples. 15 | // Usa spawn cuando quieras recibir datos desde que el proceso arranca. 16 | // Usa exec cuando solo quieras recibir datos al final de la ejecución. -------------------------------------------------------------------------------- /clase 26/aut-passport/utils/util.js: -------------------------------------------------------------------------------- 1 | function obtenerUsuario(usuarios, username){ 2 | let indice = usuarios.findIndex(e=>e.username == username); 3 | if (indice == -1) { 4 | return undefined; 5 | } else { 6 | return usuarios[indice]; 7 | } 8 | } 9 | 10 | function obtenerUsuarioId(usuarios, id){ 11 | let indice = usuarios.findIndex(e=>e._id == id); 12 | if (indice == -1) { 13 | return undefined; 14 | } else { 15 | return usuarios[indice]; 16 | } 17 | } 18 | 19 | function passwordValida(usuario, password){ 20 | return usuario.password == password; 21 | } 22 | 23 | module.exports = { 24 | obtenerUsuario, 25 | obtenerUsuarioId, 26 | passwordValida 27 | } -------------------------------------------------------------------------------- /clase 20/models/estudiantes2.js: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | const estudiantesCollection = 'estudiantes'; 3 | 4 | const EstudianteEsquema = mongoose.Schema({ 5 | nombre: {type: String, require: true, minLength: 3, maxLenghth: 20}, 6 | apellido: {type: String, require: true, minLength: 3, maxLenghth: 25}, 7 | edad: {type: Number, require: true, min: 18, max: 99}, 8 | dni: {type: String, require: true, unique: true, minLength: 6, maxLenghth: 8}, 9 | curso: {type: String, require: true}, 10 | nota: {type: Number, require: true, min: 0, max: 10}, 11 | ingreso: {type: Boolean, require: false}, 12 | }); 13 | 14 | export const Estudiante = mongoose.model(estudiantesCollection, EstudianteEsquema); 15 | -------------------------------------------------------------------------------- /clase 21/models/estudiantes2.js: -------------------------------------------------------------------------------- 1 | import mongoose from 'mongoose'; 2 | const estudiantesCollection = 'estudiantes'; 3 | 4 | const EstudianteEsquema = mongoose.Schema({ 5 | nombre: {type: String, require: true, minLength: 3, maxLenghth: 20}, 6 | apellido: {type: String, require: true, minLength: 3, maxLenghth: 25}, 7 | edad: {type: Number, require: true, min: 18, max: 99}, 8 | dni: {type: String, require: true, unique: true, minLength: 6, maxLenghth: 8}, 9 | curso: {type: String, require: true}, 10 | nota: {type: Number, require: true, min: 0, max: 10}, 11 | ingreso: {type: Boolean, require: false}, 12 | }); 13 | 14 | export const Estudiante = mongoose.model(estudiantesCollection, EstudianteEsquema); 15 | -------------------------------------------------------------------------------- /clase 11/04-ejercicio-ejs.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | app.use(express.urlencoded({ extended: true })); 7 | 8 | app.set('view engine', 'ejs'); 9 | 10 | const server = app.listen(PORT, () => { 11 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 12 | }); 13 | server.on('error', error => console.log('Error en servidor', error)); 14 | 15 | app.get('/prueba', (req, res) => { 16 | res.send('probando!'); 17 | }); 18 | 19 | app.get('/datos', (req, res) => { 20 | let { min, nivel, max, titulo } = req.query; 21 | res.render('barra-medicion', { min, nivel, max, titulo }); 22 | }); 23 | //?min=10&nivel=15&max=20&titulo=Medidor -------------------------------------------------------------------------------- /clase 22/mocks/ejercicio-faker.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const generador = require('./generador/usuarios'); 3 | 4 | const app = express(); 5 | app.use(express.json()); 6 | 7 | const PORT = 8080; 8 | 9 | const server = app.listen(PORT, ()=>{ 10 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 11 | }); 12 | server.on('error', error=>console.log('Error en servidor', error)); 13 | 14 | app.get('/test', (req,res)=>{ 15 | let usuarios = []; 16 | let cant = req.query.cant || 10; 17 | for (let i=0; i{ 8 | setTimeout(()=>resolve('Todo OK Viaje 1!!!'), 9 | 2000) 10 | }); 11 | 12 | const miViaje2 = new Promise ((resolve, reject)=>{ 13 | setTimeout(()=>resolve('Todo OK Viaje 2!!!'), 14 | 2000) 15 | }); 16 | 17 | async function misViajes() { 18 | 19 | const misViajes = [miViaje1, miViaje2]; 20 | 21 | // for (const viaje of misViajes) { 22 | // console.log(viaje); 23 | // } 24 | 25 | for await (const viaje of misViajes) { 26 | console.log(viaje); 27 | } 28 | 29 | } 30 | 31 | misViajes(); 32 | -------------------------------------------------------------------------------- /clase 30/03-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const moment = require('moment'); 3 | 4 | const app = express(); 5 | const PORT = parseInt(process.argv[2]) || 8080; 6 | 7 | app.use(express.static('public')); 8 | 9 | const server = app.listen(PORT, ()=>{ 10 | console.log('Servidor HTTP escuchando en el port', server.address().port, '. Process ID: ', process.pid); 11 | }); 12 | server.on('error', error=>console.log('Error en servidor', error)); 13 | 14 | app.get('/datos', (req,res)=>{ 15 | console.log(`Port: ${PORT} -> Fyh: ${moment().format('DD/MM/YYYY HH:mm')}`); 16 | res.send(`Servidor express (Nginx) en ${PORT} - PID ${process.pid} - ${moment().format('DD/MM/YYYY HH:mm')}`); 17 | }); -------------------------------------------------------------------------------- /clase 7/05-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const moment = require('moment'); 3 | 4 | const app = express(); 5 | const PORT = 8080; 6 | let visitas = 0; 7 | 8 | const server = app.listen(PORT, ()=>{ 9 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 10 | }); 11 | server.on('error', error=>console.log('Error en servidor', error)); 12 | 13 | app.get('/', (req,res)=>{ 14 | res.send('

Bienvenidos al Servidor Express

'); 15 | }); 16 | 17 | app.get('/visitas', (req,res)=>{ 18 | res.send(`La cantidad de visitas es ${++visitas}`); 19 | }); 20 | 21 | app.get('/fyh', (req,res)=>{ 22 | let fyh = moment().format("DD/M/YYYY hh:mm:ss"); 23 | res.json({fyh}); 24 | }); -------------------------------------------------------------------------------- /clase 7/04-server.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | const server = app.listen(PORT, ()=>{ 7 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 8 | }); 9 | server.on('error', error=>console.log('Error en servidor', error)); 10 | 11 | app.get('/', (req,res)=>{ 12 | console.log('request a get recibido!'); 13 | // res.send('Vamos River!'); 14 | res.json({ msg: 'Ahora si funciona!' }); 15 | }); 16 | 17 | app.get('/api/mensajes', (req,res)=>{ 18 | console.log('request a api/mensajes recibido!'); 19 | const objRes = { 20 | msg: 'Hola Mundo!', 21 | saludos: 1000, 22 | error: false 23 | }; 24 | res.json(objRes); 25 | }); -------------------------------------------------------------------------------- /clase 13/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | App de Chat Coder 8 | 9 | 10 | 11 | 12 |

Chat en línea

13 |
14 |
15 |
16 | 17 | 18 | 19 |
20 | 21 | -------------------------------------------------------------------------------- /clase 11/02-ejercicio-pug.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | app.use(express.urlencoded({ extended: true })); 7 | 8 | const server = app.listen(PORT, () => { 9 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 10 | }); 11 | server.on('error', error => console.log('Error en servidor', error)); 12 | 13 | app.set('views', './views'); 14 | app.set('view engine', 'pug'); 15 | 16 | app.get('/prueba', (req, res) => { 17 | res.send('probando'); 18 | }); 19 | 20 | app.get('/datos', (req, res) => { 21 | let { min, nivel, max, titulo } = req.query; 22 | res.render('barra-medicion.pug', { min, nivel, max, titulo }); 23 | }); 24 | //?min=10&nivel=15&max=20&titulo=Medidor -------------------------------------------------------------------------------- /clase 13/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const app = express(); 3 | const http = require('http').Server(app); 4 | const io = require('socket.io')(http); 5 | 6 | app.use(express.static('./public')); 7 | 8 | http.listen(8080, 9 | () => console.log('Servidor corriendo en puerto 8080...')); 10 | 11 | let mensajes = [ 12 | {autor: "Mariano", texto: "Hola a tod@s!"}, 13 | {autor: "Romina", texto: "Buenísimo!!!"}, 14 | {autor: "Dario", texto: "Hay alguien ahi?"} 15 | ]; 16 | 17 | io.on('connection', (socket) => { 18 | console.log('Cliente conectado!'); 19 | socket.emit('mensajes', mensajes); 20 | socket.on('nuevo-mensaje', (data)=>{ 21 | mensajes.push(data); 22 | io.sockets.emit('mensajes', mensajes); 23 | }); 24 | }); -------------------------------------------------------------------------------- /clase 30/01-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const moment = require('moment'); 3 | 4 | const app = express(); 5 | const PORT = parseInt(process.argv[2]) || 8080; 6 | 7 | const server = app.listen(PORT, ()=>{ 8 | console.log('Servidor HTTP escuchando en el port', server.address().port, '. Process ID: ', process.pid); 9 | }); 10 | server.on('error', error=>console.log('Error en servidor', error)); 11 | 12 | app.get('/datos', (req,res)=>{ 13 | console.log(`Port: ${PORT} -> Fyh: ${moment().format('DD/MM/YYYY HH:mm')}`); 14 | res.send(`Servidor express (Nginx) en ${PORT} - PID ${process.pid} - ${moment().format('DD/MM/YYYY HH:mm')}`); 15 | }); 16 | 17 | //tasklist /FI "IMAGENAME eq ng*" 18 | //taskkill /PID #pid /F -------------------------------------------------------------------------------- /clase 1/01-variable.js: -------------------------------------------------------------------------------- 1 | // var cantidad = 10; 2 | 3 | // function mostrarCantidad() { 4 | // var cantidad = 20; 5 | // console.log('adentro ', cantidad); 6 | // } 7 | 8 | // console.log('afuera ', cantidad); 9 | // mostrarCantidad(); 10 | // console.log('afuera ', cantidad); 11 | 12 | 13 | // cantidad = 10; 14 | 15 | // function mostrarCantidad() { 16 | // var cantidad = 20; 17 | // console.log('adentro ', cantidad); 18 | // } 19 | 20 | // console.log('afuera ', cantidad) 21 | // mostrarCantidad(); 22 | // console.log('afuera ', cantidad) 23 | 24 | 25 | function mostrarCantidad() { 26 | var cantidad = 20; 27 | console.log('adentro ', cantidad); 28 | } 29 | 30 | console.log('afuera ', cantidad) 31 | mostrarCantidad(); 32 | console.log('afuera ', cantidad) -------------------------------------------------------------------------------- /clase 12/public/index.js: -------------------------------------------------------------------------------- 1 | const socket = io(); 2 | 3 | socket.on('atodos', (data) => { 4 | let ul = document.getElementsByTagName('ul')[0]; 5 | ul.innerHTML = ''; 6 | for (mensaje of data) { 7 | let ul = document.getElementsByTagName('ul')[0]; 8 | let li = document.createElement('li'); 9 | ul.appendChild(li); 10 | li.innerHTML = `SocketId: ${mensaje.socketId} - Mensaje: ${mensaje.mensaje}`; 11 | } 12 | }) 13 | 14 | socket.on('devuelvo', (data) => { 15 | let p = document.getElementsByTagName('p')[0]; 16 | p.innerHTML = data; 17 | }) 18 | 19 | function enviar() { 20 | socket.emit('notificacion', document.getElementsByTagName('input')[0].value); 21 | }; 22 | 23 | function cambio(valor) { 24 | socket.emit('mitexto', valor); 25 | } -------------------------------------------------------------------------------- /clase 13/chat/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Mi Chat de Grupo en Coder 8 | 9 | 10 | 11 | 12 |

Chat de la Sala Copada

13 |
14 |
15 |
16 | 17 | 18 | 19 |
20 | 21 | -------------------------------------------------------------------------------- /clase 13/chat/server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const app = express(); 3 | const server = require('http').Server(app); 4 | const io = require('socket.io')(server); 5 | 6 | server.listen(8080,()=>{ 7 | console.log('escuchando en 8080...'); 8 | }); 9 | 10 | const mensajes = [ 11 | {autor: 'Pablo', texto: 'Me gusta el live coding (?)'}, 12 | {autor: 'Diego', texto: 'Me gusta el cobol...'}, 13 | {autor: 'Sergio', texto: 'Vengan a los after!!'} 14 | ] 15 | 16 | app.use(express.static('./public')); 17 | 18 | io.on('connection',(socket)=>{ 19 | console.log('cliente conectado!!!'); 20 | socket.emit('mensajes', mensajes); 21 | socket.on('nuevo',(data)=>{ 22 | mensajes.push(data); 23 | io.sockets.emit('mensajes',mensajes); 24 | }); 25 | }); -------------------------------------------------------------------------------- /clase 28/02-exit.js: -------------------------------------------------------------------------------- 1 | process.on('beforeExit', (code)=>{ 2 | console.log('Antes de salir del proceso con código:', code); 3 | const fs = require('fs') 4 | fs.readFile('./nada.txt', 'utf8' , (err, data) => { 5 | if (err) { 6 | console.error('Error!', err); 7 | } else { 8 | console.log('Data', data); 9 | process.exit(0); 10 | } 11 | }); 12 | 13 | }); 14 | 15 | process.on('exit', (code)=>{ 16 | console.log('Valor de i:', i); 17 | console.log('Saliendo del proceso con código:', code); 18 | }); 19 | 20 | 21 | let i; 22 | for (i=0; i<1000; i++){ 23 | // if (i==500) { 24 | // console.log('saliendo...'); 25 | // // process.exit(3); 26 | // } 27 | } 28 | console.log('Llegué al final...'); 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /clase 9/public2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Probando Multer 8 | 9 | 10 |

Bienvenidos a la prueba de Multer

11 |
12 | Seleccione archivo 13 | 14 |
15 |
16 | Seleccione archivos 17 | 18 |
19 | 20 | -------------------------------------------------------------------------------- /clase 26/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login Usuario 8 | 9 | 10 |
11 |

Login

12 |
13 | 14 |

15 | 16 |

17 | 18 |
19 |
20 | Registrarse 21 |
22 | 23 | -------------------------------------------------------------------------------- /clase 28/13-fork-no-bloqueante.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | const {fork} = require('child_process'); 3 | 4 | let visitas = 0; 5 | 6 | const server = http.createServer(); 7 | server.on('request', (req, res)=>{ 8 | let {url} = req; 9 | if (url == '/calcular'){ 10 | const computo = fork('./computo.js'); 11 | computo.send('start'); 12 | computo.on('message', sum=>res.end(`La suma es ${sum}`)); 13 | console.log('Es no bloqueante!'); 14 | } else if (url == '/') { 15 | res.end(`Ok ${++visitas}`); 16 | } else { 17 | res.end('Ruta no valida'); 18 | } 19 | }); 20 | 21 | const PORT = 8080; 22 | server.listen(PORT, err=>{ 23 | if (err){ 24 | throw new Error('Error en servidor' + err); 25 | } 26 | console.log('Servidor http escuchando en puerto', PORT); 27 | }); -------------------------------------------------------------------------------- /clase 12/04-sockets.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const { Server: HttpServer } = require('http'); 3 | const { Server: IOServer } = require('socket.io'); 4 | 5 | const app = express(); 6 | const httpServer = new HttpServer(app); 7 | const io = new IOServer(httpServer); 8 | 9 | const PORT = 3030; 10 | const mensajes = []; 11 | 12 | app.use(express.static('./public')); 13 | 14 | httpServer.listen(PORT, () => { 15 | console.log('Servidor HTTP escuchando en el puerto', PORT); 16 | }); 17 | 18 | io.on('connection', (socket) => { 19 | 20 | console.log('Nuevo cliente conectado!'); 21 | socket.emit('lista', mensajes); 22 | 23 | socket.on('mensaje', (data) => { 24 | mensajes.push({ socketid: socket.id, mensaje: data }); 25 | io.sockets.emit('nuevo', { socketid: socket.id, mensaje: data }); 26 | }); 27 | 28 | }); -------------------------------------------------------------------------------- /clase 26/aut-passport/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login Usuario 8 | 9 | 10 |
11 |

Login

12 |
13 | 14 |

15 | 16 |

17 | 18 |
19 |
20 | Registrarse 21 |
22 | 23 | -------------------------------------------------------------------------------- /clase 28/12-bloqueante.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | 3 | const calculo = () => { 4 | let sum = 0; 5 | for (let i=0; i<6e9; i++){ 6 | sum+=i; 7 | } 8 | return sum; 9 | } 10 | 11 | let visitas = 0; 12 | 13 | const server = http.createServer(); 14 | server.on('request', (req, res)=>{ 15 | let {url} = req; 16 | if (url == '/calcular'){ 17 | const sum = calculo(); 18 | console.log('Es Bloqueante!'); 19 | res.end(`La suma es ${sum}`); 20 | } else if (url == '/') { 21 | res.end(`Ok ${++visitas}`); 22 | } else { 23 | res.end('Ruta no valida'); 24 | } 25 | }); 26 | 27 | const PORT = 8081; 28 | server.listen(PORT, err=>{ 29 | if (err){ 30 | throw new Error('Error en servidor' + err); 31 | } 32 | console.log('Servidor http escuchando en puerto', PORT); 33 | }); -------------------------------------------------------------------------------- /clase 12/public/ej3/index.js: -------------------------------------------------------------------------------- 1 | const socket = io(); 2 | 3 | function enviarMensaje() { 4 | let data = document.getElementsByTagName('input')[0].value; 5 | socket.emit('mensaje', data); 6 | document.getElementsByTagName('input')[0].value = ''; 7 | } 8 | 9 | socket.on('lista', (data) => { 10 | for (mensaje of data) { 11 | let ul = document.getElementsByTagName('ul')[0]; 12 | let li = document.createElement('li'); 13 | ul.appendChild(li); 14 | li.innerHTML = `SocketId: ${mensaje.socketid} - Mensaje: ${mensaje.mensaje}`; 15 | } 16 | }); 17 | 18 | socket.on('nuevo', (data) => { 19 | console.log(data); 20 | let ul = document.getElementsByTagName('ul')[0]; 21 | let li = document.createElement('li'); 22 | ul.appendChild(li); 23 | li.innerHTML = `SocketId: ${data.socketid} - Mensaje: ${data.mensaje}`; 24 | }); -------------------------------------------------------------------------------- /clase 13/colores/paint.js: -------------------------------------------------------------------------------- 1 | class Paint { 2 | constructor(){ 3 | this.rectangleMap = new Array(1280); 4 | this.iniMap(this.rectangleMap); 5 | } 6 | 7 | iniMap(){ 8 | for (let i=0; i<1280; i++){ 9 | this.rectangleMap[i] = new Array(1280); 10 | } 11 | } 12 | 13 | mapToArray(map){ 14 | let array = []; 15 | for (let x=0; x console.log('escuchando...')); 12 | 13 | let mensajes = []; 14 | 15 | io.on('connection', (socket) => { 16 | console.log('alguien se está conectado...'); 17 | io.sockets.emit('atodos', mensajes); 18 | socket.emit('mensajex', 'hola!! este es un mensaje desde el servidor!'); 19 | socket.on('notificacion', (data) => { 20 | mensajes.push({ socketId: socket.id, mensaje: data }); 21 | io.sockets.emit('atodos', mensajes); 22 | }) 23 | socket.on('mitexto', (data) => { 24 | io.sockets.emit('devuelvo', data); 25 | }) 26 | }); -------------------------------------------------------------------------------- /clase 6/13-ejemplo.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | 3 | console.log('inicio del programa'); 4 | 5 | const data = fs.readFile('./package.json', 'utf-8', (error, data) => { 6 | if (error) { 7 | throw new Error(`Hubo un error en la lectura del archivo: ${error}`); 8 | } else { 9 | let info = { 10 | contenidoStr: data, 11 | contenidoObj: JSON.parse(data), 12 | size: data.length 13 | } 14 | console.log(info); 15 | fs.writeFile('./info.txt', JSON.stringify(info, null, '\t'), (error) => { 16 | if (error) { 17 | throw new Error(`Hubo un error en la escritura del archivo: ${error}`); 18 | } else { 19 | console.log('Archivo grabado!'); 20 | } 21 | }); 22 | } 23 | }); 24 | 25 | console.log('final del programa'); 26 | -------------------------------------------------------------------------------- /clase 27/jwt/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Login Usuario 8 | 9 | 10 |
11 |

Login

12 |
13 | 14 |

15 | 16 |

17 | 18 |
19 |
20 | Registrarse 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /clase 5/03-array.js: -------------------------------------------------------------------------------- 1 | let productos = [ 2 | { id: 1, nombre: 'Escuadra', precio: 323.45 }, 3 | { id: 2, nombre: 'Calculadora', precio: 234.56 }, 4 | { id: 3, nombre: 'Globo Terráqueo', precio: 45.67 }, 5 | { id: 4, nombre: 'Paleta Pintura', precio: 456.78 }, 6 | { id: 5, nombre: 'Reloj', precio: 1167.89 }, 7 | { id: 6, nombre: 'Agenda', precio: 8.90 } 8 | ]; 9 | 10 | let nombres = productos.map(e=>e.nombre).join(','); 11 | let suma = productos.reduce((acu,act)=>acu + act.precio,0).toFixed(2); 12 | let promedio = (productos.reduce((acu,act)=>acu + act.precio,0) / productos.length).toFixed(2); 13 | let minimo = productos.find(e=>e.precio == Math.min(...productos.map(e=>e.precio))); 14 | let maximo = productos.find(e=>e.precio == Math.max(...productos.map(e=>e.precio))); 15 | 16 | let miObjeto = { nombres, suma, promedio, minimo, maximo }; 17 | console.log(miObjeto); -------------------------------------------------------------------------------- /after/sockets/public/main.js: -------------------------------------------------------------------------------- 1 | let socket = io(); 2 | 3 | socket.on('partidos', (data)=>{ 4 | render(data); 5 | }); 6 | 7 | let render = (data) => { 8 | let html = data.map((e,i)=>` 9 |
10 | ${e.local.goles} 11 | ${e.local.equipo} 12 | vs. 13 | ${e.visitante.equipo} 14 | ${e.visitante.goles} 15 |
16 | `).join(' '); 17 | document.getElementById("partidos").innerHTML = html; 18 | } 19 | 20 | socket.on('gol', (data) => { 21 | let noticia = document.getElementById('noticia'); 22 | noticia.style.display = 'block'; 23 | noticia.innerHTML = `Gol de ${data.equipo}!!!` 24 | setTimeout(()=>noticia.style.display='none',1000); 25 | }) 26 | 27 | -------------------------------------------------------------------------------- /clase 29/server-cluster/01-server.js: -------------------------------------------------------------------------------- 1 | const cluster = require('cluster'); 2 | const http = require('http'); 3 | const numCPUs = require('os').cpus().length; 4 | 5 | if (cluster.isMaster){ 6 | console.log(`Cantidad de CPUs: ${numCPUs}`); 7 | console.log(`Master PID ${process.pid} is running`); 8 | for (let i=0; i console.log(`Worker ${worker.process.pid} died`)); 12 | } else { 13 | const PORT = 8080; 14 | http.createServer((req, res)=>{ 15 | res.writeHead(200); 16 | res.end('Finalizando...\n'); 17 | }).listen(PORT); 18 | console.log(`Worker ${process.pid} started`); 19 | } 20 | 21 | //en windows, para ver lista de procesos node corriendo: 22 | //tasklist /FI "IMAGENAME eq node*" 23 | 24 | //en windows, para matar un proceso: 25 | //taskkill /PID #pid /F 26 | -------------------------------------------------------------------------------- /clase 4/02-ejemplo.js: -------------------------------------------------------------------------------- 1 | function *numerosAleatorios(minimo, maximo) { 2 | let cantidad = 1; 3 | while (true) { 4 | let actual = new Date(); 5 | mes = ('0' + (actual.getMonth() + 1)).slice(-2); 6 | yield { 7 | orden: cantidad++, 8 | numero: Math.floor((Math.random() * (maximo - minimo + 1 )) + minimo), 9 | fyh: actual.getDate() + '/' + 10 | mes + '/' + 11 | ('' + actual.getFullYear()).slice(-2) + ' ' + 12 | ('0' + actual.getHours()).slice(-2) + ':' + 13 | ('0' + actual.getMinutes()).slice(-2) + ':' + 14 | ('0' + actual.getSeconds()).slice(-2) 15 | } 16 | } 17 | } 18 | 19 | let generadora = numerosAleatorios(3,7); 20 | console.log(generadora.next().value); 21 | setInterval( 22 | ()=>console.log(generadora.next().value), 23 | 1000 24 | ); -------------------------------------------------------------------------------- /clase 11/05-ejercicio.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | let personas = []; 6 | 7 | app.use(express.json()); 8 | app.use(express.urlencoded({ extended: true })); 9 | 10 | app.set('view engine', 'ejs'); 11 | 12 | const server = app.listen(PORT, () => { 13 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 14 | }); 15 | server.on('error', error => console.log('Error en servidor', error)); 16 | 17 | app.get('/prueba', (req, res) => { 18 | res.send('probandoss'); 19 | }); 20 | 21 | app.post('/personas', (req, res) => { 22 | personas.push(req.body); 23 | res.json({ persona: req.body, err: '' }) 24 | }); 25 | 26 | app.post('/personas/limpiar', (req, res) => { 27 | personas = []; 28 | res.json({ err: '' }) 29 | }); 30 | 31 | app.get('/personas', (req, res) => { 32 | res.render('personas', { personas }); 33 | }); -------------------------------------------------------------------------------- /clase 14/ts/03-color.ts: -------------------------------------------------------------------------------- 1 | import chalk = require('chalk'); 2 | 3 | class Color { 4 | 5 | red: number; 6 | green: number; 7 | blue: number; 8 | 9 | constructor(red, green, blue) { 10 | this.red = red; 11 | this.green = green; 12 | this.blue = blue; 13 | } 14 | 15 | regenerar(){ 16 | this.red = Math.floor(Math.random() * 256); 17 | this.green = Math.floor(Math.random() * 256); 18 | this.blue = Math.floor(Math.random() * 256); 19 | } 20 | }; 21 | 22 | const saludoColor = (color) => console.log(chalk.rgb(color.red, color.green, color.blue).bold('Hola a tod@s!!!')); 23 | 24 | let rojo = new Color(255,0,0); 25 | let verde = new Color(0,255,0); 26 | let azul = new Color(0,0,255); 27 | 28 | saludoColor(rojo); 29 | saludoColor(verde); 30 | saludoColor(azul); 31 | 32 | const aleatorio = new Color(0,0,0); 33 | aleatorio.regenerar(); 34 | saludoColor(aleatorio); 35 | -------------------------------------------------------------------------------- /after/callbacks/02-request.js: -------------------------------------------------------------------------------- 1 | const request = require("request"); 2 | 3 | const llamadaAPI = (callback) => { 4 | let numero = Math.floor(Math.random()*10 + 1); 5 | const url = `https://jsonplaceholder.typicode.com/posts/${numero}`; 6 | request.get(url, (error, response, body) => { 7 | // console.log(error); 8 | // console.log(response.body); 9 | // console.log(body); 10 | let json = JSON.parse(body); 11 | callback(error, json); 12 | }); 13 | } 14 | 15 | console.log('Inicio del Progama'); 16 | 17 | llamadaAPI((err,resp) => { 18 | if (err) { 19 | console.log('lamentablemente hubo un error en el llamado a la API!! Intente nuevamente...', err); 20 | } else { 21 | console.log('Recibi esta info: ', resp); 22 | console.log('y ahora me voy a grabarla a la base de datos...'); 23 | } 24 | }); 25 | 26 | console.log('Final del Progama'); 27 | 28 | -------------------------------------------------------------------------------- /clase 26/public/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Registrar Usuario 8 | 9 | 10 |
11 |

Registrar Usuario

12 |
13 | 14 |

15 | 16 |

17 | 18 |

19 | 20 |
21 |
22 | 23 | -------------------------------------------------------------------------------- /clase 26/aut-passport/public/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Registrar Usuario 8 | 9 | 10 |
11 |

Registrar Usuario

12 |
13 | 14 |

15 | 16 |

17 | 18 |

19 | 20 |
21 |
22 | 23 | -------------------------------------------------------------------------------- /clase 4/10-ejemplo.js: -------------------------------------------------------------------------------- 1 | function resolverLuegoDe2Segundos(x) { 2 | return new Promise(resolve => { 3 | setTimeout(() => { 4 | resolve(x); 5 | }, 2000); 6 | }); 7 | } 8 | 9 | function resolverLuegoDe5Segundos(x) { 10 | return new Promise(resolve => { 11 | setTimeout(() => { 12 | resolve(x); 13 | }, 5000); 14 | }); 15 | } 16 | 17 | 18 | async function AgregarA(x) { 19 | const a = await resolverLuegoDe2Segundos(20); 20 | const b = await resolverLuegoDe2Segundos(30); 21 | return x + a + b; 22 | } 23 | 24 | AgregarA(10).then(v => { 25 | console.log('En AgregarA:', v); 26 | }); 27 | 28 | 29 | async function AgregarB(x) { 30 | const p_a = resolverLuegoDe2Segundos(50); 31 | const p_b = resolverLuegoDe5Segundos(20); 32 | return x + await p_a + await p_b; 33 | } 34 | 35 | AgregarB(100).then(v => { 36 | console.log('En AgregarB:', v); 37 | }); 38 | -------------------------------------------------------------------------------- /clase 12/01-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const { Server: HttpServer } = require('http'); 3 | const { Server: IOServer } = require('socket.io'); 4 | 5 | const app = express(); 6 | const httpServer = new HttpServer(app); 7 | const io = new IOServer(httpServer); 8 | 9 | const PORT = 3030; 10 | const mensajes = []; 11 | 12 | app.use(express.static('./public')); 13 | 14 | httpServer.listen(PORT, () => { 15 | console.log('Servidor HTTP escuchando en el puerto', PORT); 16 | }); 17 | 18 | io.on('connection', (socket) => { 19 | 20 | console.log('Usuario conectado'); 21 | 22 | socket.emit('mi mensaje', 'Este HOLA es mi mensaje desde el servidor'); 23 | 24 | socket.on('notificacion', (data) => { 25 | console.log(data); 26 | }); 27 | 28 | socket.on('mensaje', (data) => { 29 | mensajes.push({ socketid: socket.id, mensaje: data }); 30 | io.sockets.emit('mensajes', mensajes); 31 | }); 32 | 33 | }); -------------------------------------------------------------------------------- /clase 14/ts3/03-color.ts: -------------------------------------------------------------------------------- 1 | import chalk = require('chalk'); 2 | // const chalk = require('chalk'); 3 | 4 | class Color { 5 | 6 | red: number; 7 | green: number; 8 | blue: number; 9 | 10 | constructor(red, green, blue) { 11 | this.red = red; 12 | this.green = green; 13 | this.blue = blue; 14 | } 15 | 16 | regenerar(){ 17 | this.red = Math.floor(Math.random() * 256); 18 | this.green = Math.floor(Math.random() * 256); 19 | this.blue = Math.floor(Math.random() * 256); 20 | } 21 | }; 22 | 23 | const saludoColor = (color) => console.log(chalk.rgb(color.red, color.green, color.blue).bold('Hola a tod@s!!!')); 24 | 25 | let rojo = new Color(255,0,0); 26 | let verde = new Color(0,255,0); 27 | let azul = new Color(0,0,255); 28 | 29 | saludoColor(rojo); 30 | saludoColor(verde); 31 | saludoColor(azul); 32 | 33 | const aleatorio = new Color(0,0,0); 34 | aleatorio.regenerar(); 35 | saludoColor(aleatorio); 36 | -------------------------------------------------------------------------------- /clase 27/jwt/public/register.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Registrar Usuario 8 | 9 | 10 |
11 |

Registrar Usuario

12 |
13 | 14 |

15 | 16 |

17 | 18 |

19 | 20 |
21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /clase 14/ts/03-color.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | var chalk = require("chalk"); 4 | var Color = /** @class */ (function () { 5 | function Color(red, green, blue) { 6 | this.red = red; 7 | this.green = green; 8 | this.blue = blue; 9 | } 10 | Color.prototype.regenerar = function () { 11 | this.red = Math.floor(Math.random() * 256); 12 | this.green = Math.floor(Math.random() * 256); 13 | this.blue = Math.floor(Math.random() * 256); 14 | }; 15 | return Color; 16 | }()); 17 | ; 18 | var saludoColor = function (color) { return console.log(chalk.rgb(color.red, color.green, color.blue).bold('Hola a tod@s!!!')); }; 19 | var rojo = new Color(255, 0, 0); 20 | var verde = new Color(0, 255, 0); 21 | var azul = new Color(0, 0, 255); 22 | saludoColor(rojo); 23 | saludoColor(verde); 24 | saludoColor(azul); 25 | var aleatorio = new Color(0, 0, 0); 26 | aleatorio.regenerar(); 27 | saludoColor(aleatorio); 28 | -------------------------------------------------------------------------------- /clase 10/public/indexx.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Probando Handlebars... 9 | 10 | 11 | 12 | 13 | 14 | 15 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /clase 9/02-router.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | const router = express.Router(); 6 | 7 | app.use('/api', router); 8 | 9 | const server = app.listen(PORT, ()=>{ 10 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 11 | }); 12 | server.on('error', error=>console.log('Error en servidor', error)); 13 | 14 | router.get('/', (req,res)=>{ 15 | const objRes = { 16 | msg: 'Bienvenidos a mi sitio Principal de la ruta!', 17 | error: false 18 | }; 19 | res.json(objRes); 20 | }); 21 | 22 | router.get('/mensajes', (req,res)=>{ 23 | const objRes = { 24 | msg: 'Bienvenidos a mi sitio de mensajes!', 25 | error: false 26 | }; 27 | res.json(objRes); 28 | }); 29 | 30 | router.get('/saludos', (req,res)=>{ 31 | const objRes = { 32 | msg: 'Bienvenidos a mi sitio de saludos!', 33 | error: false 34 | }; 35 | res.json(objRes); 36 | }); -------------------------------------------------------------------------------- /clase 27/jwt/public/js/login.js: -------------------------------------------------------------------------------- 1 | function btnAcceder(){ 2 | const url = 'http://localhost:8080/login'; 3 | const data = { 4 | username: document.getElementById('usuario').value, 5 | password: document.getElementById('password').value, 6 | }; 7 | const options = { 8 | method: 'POST', 9 | body: JSON.stringify(data), 10 | headers:{ 11 | 'Content-Type': 'application/json' 12 | } 13 | } 14 | fetch(url, options) 15 | .then(res => res.json()) 16 | .then(response => { 17 | if (response.error == '') { 18 | sessionStorage.setItem('token', response.token); 19 | window.location="http://localhost:8080/datos.html"; 20 | } else { 21 | console.error('Error:', response.error); 22 | alert('Error en login!'); 23 | } 24 | }) 25 | .catch(error => { 26 | console.error('Error:', error); 27 | alert('Error en login!'); 28 | }); 29 | } -------------------------------------------------------------------------------- /clase 14/ts3/03-color.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | exports.__esModule = true; 3 | var chalk = require("chalk"); 4 | // const chalk = require('chalk'); 5 | var Color = /** @class */ (function () { 6 | function Color(red, green, blue) { 7 | this.red = red; 8 | this.green = green; 9 | this.blue = blue; 10 | } 11 | Color.prototype.regenerar = function () { 12 | this.red = Math.floor(Math.random() * 256); 13 | this.green = Math.floor(Math.random() * 256); 14 | this.blue = Math.floor(Math.random() * 256); 15 | }; 16 | return Color; 17 | }()); 18 | ; 19 | var saludoColor = function (color) { return console.log(chalk.rgb(color.red, color.green, color.blue).bold('Hola a tod@s!!!')); }; 20 | var rojo = new Color(255, 0, 0); 21 | var verde = new Color(0, 255, 0); 22 | var azul = new Color(0, 0, 255); 23 | saludoColor(rojo); 24 | saludoColor(verde); 25 | saludoColor(azul); 26 | var aleatorio = new Color(0, 0, 0); 27 | aleatorio.regenerar(); 28 | saludoColor(aleatorio); 29 | -------------------------------------------------------------------------------- /clase 2/20-ejemplo.js: -------------------------------------------------------------------------------- 1 | class Mensaje { 2 | constructor (mensaje, retardo){ 3 | this.mensaje = mensaje; 4 | this.retardo = retardo ?? 1; 5 | } 6 | 7 | mostrar(){ 8 | 9 | if (this.mensaje == undefined) { 10 | console.log('Defina mensaje'); 11 | } else { 12 | try { 13 | let mostrarMensaje = this.mensaje.trimEnd(); 14 | setTimeout(()=>console.log(mostrarMensaje), this.retardo * 1000); 15 | } catch { 16 | console.log('error'); 17 | } 18 | } 19 | } 20 | } 21 | 22 | let saludar = new Mensaje('Hola a tod@s!', 2); 23 | saludar.mostrar(); 24 | let saludar2 = new Mensaje('Hola a todas!'); 25 | saludar2.mostrar(); 26 | let saludar3 = new Mensaje('Hola a todos!', 0); 27 | saludar3.mostrar(); 28 | let saludar4 = new Mensaje(); 29 | saludar4.mostrar(); 30 | let saludar5 = new Mensaje(0, 500); 31 | saludar5.mostrar(); 32 | 33 | // let soyFalso = new Mensaje(false,1000); 34 | // soyFalso.mostrar(); -------------------------------------------------------------------------------- /clase 22/02-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | const server = app.listen(PORT, ()=>{ 7 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 8 | }); 9 | server.on('error', error=>console.log('Error en servidor', error)); 10 | 11 | app.get('/test', (req,res)=>{ 12 | 13 | const nombres = ['Luis', 'Lucía', 'Juan', 'Augusto', 'Ana'] 14 | const apellidos = ['Pieres', 'Cacurri', 'Bezzola', 'Alberca', 'Mei'] 15 | const colores = ['rojo', 'verde', 'azul', 'amarillo', 'magenta'] 16 | 17 | const arrSalida = Array(); 18 | for (let i=0;i<10;i++){ 19 | arrSalida.push( 20 | { 21 | nombre: nombres[Math.floor(Math.random() * (nombres.length - 1))], 22 | apellido: apellidos[Math.floor(Math.random() * (apellidos.length - 1))], 23 | color: colores[Math.floor(Math.random() * (colores.length - 1))] 24 | } 25 | ); 26 | } 27 | res.json({salida: arrSalida}); 28 | }); -------------------------------------------------------------------------------- /after/callbacks/01-simulo.js: -------------------------------------------------------------------------------- 1 | const llamadaAPI = (callback) => { 2 | let misBandas = ['Europe', 'Motley Crue', 'Poison', 'Skid Row', 'Helloween']; 3 | setTimeout(()=>{ 4 | let status = Math.random(); 5 | let respuesta = {}; 6 | let error = null; 7 | if (status > 0.80) { 8 | error = "Veo un Error en el llamado"; 9 | } else { 10 | respuesta = { 11 | id: Math.floor(Math.random() * 10 + 1), 12 | banda: misBandas[Math.floor(Math.random() * 5)] 13 | } 14 | } 15 | callback(error, respuesta); 16 | },3000); 17 | } 18 | 19 | console.log('Inicio del Progama'); 20 | 21 | llamadaAPI((err,resp) => { 22 | if (err) { 23 | console.log('lamentablemente hubo un error en el llamado a la API!! Intente nuevamente...', err); 24 | } else { 25 | console.log('Recibi esta info: ', resp); 26 | console.log('y ahora me voy a grabarla a la base de datos...'); 27 | } 28 | }); 29 | 30 | console.log('Final del Progama'); 31 | 32 | -------------------------------------------------------------------------------- /clase 11/03-ejs.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | app.use(express.urlencoded({ extended: true })); 7 | 8 | app.set('view engine', 'ejs'); 9 | 10 | const server = app.listen(PORT, () => { 11 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 12 | }); 13 | server.on('error', error => console.log('Error en servidor', error)); 14 | 15 | app.get('/prueba', (req, res) => { 16 | res.send('probando'); 17 | }); 18 | 19 | app.get('/', (req, res) => { 20 | let mascots = [ 21 | { name: 'Sammy', organization: 'DigitalOcean', birth_year: 2012 }, 22 | { name: 'Tux', organization: 'Linux', birth_year: 1996 }, 23 | { name: 'Moby Dock', organization: 'Docker', birth_year: 2013 } 24 | ]; 25 | let tagline = 'SiroNo programming concept is complete without a cute animal mascot'; 26 | res.render('pages/index', { mascots, tagline }); 27 | }); 28 | 29 | app.get('/about', (req, res) => { 30 | res.render('pages/about', { about: 'Prueba EJS!!!!' }); 31 | }); -------------------------------------------------------------------------------- /clase 11/views/pages/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%- include('../partials/head'); %> 6 | 7 | 8 | 9 | 10 |
11 | <%- include('../partials/header'); %> 12 |
13 | 14 |
15 |
16 |

This is great

17 |

Welcome to templating using EJS

18 |

Variable

19 |

20 | <%= tagline %> 21 |

22 |
    23 | <% mascots.forEach(function(mascot) { %> 24 |
  • 25 | <%= mascot.name %> representing 26 | <%= mascot.organization %>, born 27 | <%= mascot.birth_year %> 28 |
  • 29 | <% }); %> 30 |
31 |
32 |
33 | 34 |
35 | <%- include('../partials/footer'); %> 36 |
37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /clase 28/15-ejercicio.js: -------------------------------------------------------------------------------- 1 | const http = require('http'); 2 | const {fork} = require('child_process'); 3 | 4 | const sumar = () => { 5 | let suma = 0; 6 | for (let i=0; i<5e9; i++){ 7 | suma+=i; 8 | } 9 | return suma; 10 | } 11 | 12 | let visitas = 0; 13 | 14 | const server = http.createServer(); 15 | server.on('request', (req, res)=>{ 16 | let {url} = req; 17 | if (url == '/calculo-bloq'){ 18 | const sum = sumar(); 19 | res.end(`La suma es ${sum}`); 20 | } else if (url == '/calculo-nobloq'){ 21 | const computo = fork('./computo.js'); 22 | computo.send('start'); 23 | computo.on('message', sum=>res.end(`La suma es ${sum}`)); 24 | } else if (url == '/') { 25 | res.end(`Contador de visitas: ${++visitas}`); 26 | } else { 27 | res.end('Ruta no valida'); 28 | } 29 | }); 30 | 31 | const PORT = 8080; 32 | server.listen(PORT, err=>{ 33 | if (err){ 34 | throw new Error('Error en servidor' + err); 35 | } 36 | console.log('Servidor http escuchando en puerto', PORT); 37 | }); -------------------------------------------------------------------------------- /clase 27/jwt/public/js/registrar.js: -------------------------------------------------------------------------------- 1 | function btnRegistrar(){ 2 | const url = 'http://localhost:8080/register'; 3 | const data = { 4 | username: document.getElementById('usuario').value, 5 | password: document.getElementById('password').value, 6 | direccion: document.getElementById('direccion').value 7 | }; 8 | const options = { 9 | method: 'POST', 10 | body: JSON.stringify(data), 11 | headers:{ 12 | 'Content-Type': 'application/json' 13 | } 14 | } 15 | fetch(url, options) 16 | .then(res => res.json()) 17 | .then(response => { 18 | if (response.error == '') { 19 | sessionStorage.setItem('token', response.token); 20 | window.location="http://localhost:8080/datos.html"; 21 | } else { 22 | console.error('Error:', response.error); 23 | alert('Error en registro!'); 24 | } 25 | }) 26 | .catch(error => { 27 | console.error('Error:', error); 28 | alert('Error en registro!'); 29 | }); 30 | } -------------------------------------------------------------------------------- /clase 29/server-cluster/03-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const cluster = require('cluster'); 3 | const moment = require('moment'); 4 | const numCPUs = require('os').cpus().length; 5 | 6 | const app = express(); 7 | 8 | 9 | if (cluster.isMaster){ 10 | console.log(`Cantidad de CPUs: ${numCPUs}`); 11 | console.log(`Master PID ${process.pid} is running`); 12 | for (let i=0; i { 16 | console.log(`Worker ${worker.process.pid} died`) 17 | cluster.fork(); 18 | }); 19 | } else { 20 | const PORT = process.argv[2] || 8080; 21 | const server = app.listen(PORT, ()=>{ 22 | console.log('Servidor worker HTTP escuchando en el puerto', server.address().port, '. Process ID: ', process.pid); 23 | }); 24 | server.on('error', error=>console.log('Error en servidor', error)); 25 | app.get('/', (req,res)=>{ 26 | res.send(`Servidor express en ${PORT} - PID ${process.pid} - ${moment().format('DD/MM/YYYY HH:mm')}`); 27 | }); 28 | } 29 | -------------------------------------------------------------------------------- /after/sockets/public/estilos.css: -------------------------------------------------------------------------------- 1 | #noticia { 2 | background-color: lightblue; 3 | font-size: large; 4 | padding: 10px; 5 | border-radius: 10px; 6 | text-align: center; 7 | width: 300px; 8 | margin-left: 150px; 9 | display: none; 10 | } 11 | 12 | #partidos { 13 | font-size:x-large; 14 | border-radius: 30px; 15 | margin: 20px; 16 | width: 600px; 17 | background-color: #d8d8d8; 18 | } 19 | 20 | .fila { 21 | display: flex; 22 | flex-direction: row; 23 | flex-wrap: nowrap; 24 | padding: 10px; 25 | } 26 | 27 | .goles { 28 | width: 80px; 29 | text-align: center; 30 | margin: 5px; 31 | } 32 | 33 | .equipo { 34 | width: 200px; 35 | text-align: center; 36 | margin: 5px; 37 | } 38 | 39 | .vs { 40 | width: 30px; 41 | text-align: center; 42 | margin: 5px; 43 | } 44 | 45 | .mas, .menos { 46 | width: 20px; 47 | margin: 5px; 48 | background-color: gray; 49 | border-radius: 5px; 50 | text-align: center; 51 | } 52 | 53 | .mas:hover, .menos:hover { 54 | cursor: pointer; 55 | background-color:blue; 56 | } 57 | 58 | -------------------------------------------------------------------------------- /clase 8/02-get.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | const server = app.listen(PORT, ()=>{ 7 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 8 | }); 9 | server.on('error', error=>console.log('Error en servidor', error)); 10 | 11 | //Incorporamos query parameters al get 12 | app.get('/api/mensajes', (req,res)=>{ 13 | console.log('get request con query parameters a api/mensajes recibido'); 14 | let query = req.query; 15 | let cantidad = Object.entries(query).length; 16 | console.log(Object.entries(query)); 17 | console.log(query); 18 | if (cantidad > 0) { 19 | const objRes = { 20 | msg: 'Hola Mundo con query parameters!', 21 | parametros: cantidad, 22 | query, 23 | error: false 24 | }; 25 | res.json(objRes); 26 | } else { 27 | const objRes = { 28 | msg: 'Hola Mundo sin query parameters!', 29 | parametros: 0, 30 | error: false 31 | }; 32 | res.json(objRes); 33 | } 34 | }); 35 | -------------------------------------------------------------------------------- /clase 14/02-color.js: -------------------------------------------------------------------------------- 1 | const util = require('util'); 2 | const chalk = require('chalk'); 3 | 4 | class Color { 5 | constructor(red, green, blue) { 6 | this.red = red; 7 | this.green = green; 8 | this.blue = blue; 9 | } 10 | 11 | [util.inspect.custom](depth, opts) { 12 | return `R: ${this.red} - G: ${this.green} - B: ${this.blue}`; 13 | } 14 | 15 | regenerar(){ 16 | this.red = Math.floor(Math.random() * 256); 17 | this.green = Math.floor(Math.random() * 256); 18 | this.blue = Math.floor(Math.random() * 256); 19 | } 20 | }; 21 | 22 | const saludoColor = (color) => console.log(chalk.rgb(color.red, color.green, color.blue).bold('Hola a tod@s!!!')); 23 | 24 | let rojo = new Color(255,0,0); 25 | let verde = new Color(0,255,0); 26 | let azul = new Color(0,0,255); 27 | const blanco = new Color(255,255,255); 28 | const negro = new Color(0,0,0); 29 | 30 | console.log('Negro: ', negro); 31 | console.log('Blanco: ', blanco); 32 | saludoColor(rojo); 33 | saludoColor(verde); 34 | saludoColor(azul); 35 | 36 | const aleatorio = new Color(0,0,0); 37 | aleatorio.regenerar(); 38 | saludoColor(aleatorio); 39 | -------------------------------------------------------------------------------- /clase 27/jwt/public/js/datos.js: -------------------------------------------------------------------------------- 1 | const url = 'http://localhost:8080/datos'; 2 | 3 | const myHeaders = new Headers(); 4 | myHeaders.append('Content-Type', 'application/json'); 5 | myHeaders.append('Authorization', sessionStorage.getItem('token')); 6 | 7 | const options = { 8 | method: 'GET', 9 | headers: myHeaders 10 | } 11 | 12 | fetch(url, options) 13 | .then(res => res.json()) 14 | .then(response => { 15 | if (response.error == '') { 16 | document.getElementById('datos').innerHTML = ` 17 |
    18 |
  • Usuario: ${response.username}
  • 19 |
  • Direccion: ${response.direccion}
  • 20 |
  • Visitas: ${response.visitas}
  • 21 |
22 | ` 23 | } else { 24 | console.error('Error:', response.error); 25 | window.location="http://localhost:8080"; 26 | } 27 | }) 28 | .catch(error => { 29 | console.error('Error:', error); 30 | alert('Error en visualización de datos'); 31 | }); 32 | 33 | function btnLogout(){ 34 | sessionStorage.removeItem('token'); 35 | window.location="http://localhost:8080"; 36 | } 37 | -------------------------------------------------------------------------------- /clase 8/08-app.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | const server = app.listen(PORT, ()=>{ 7 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 8 | }); 9 | server.on('error', error=>console.log('Error en servidor', error)); 10 | 11 | app.use(express.json()); 12 | app.use(express.urlencoded({extended: true})); 13 | 14 | app.get('/api/sumar', (req,res)=>{ 15 | let query = req.query; 16 | res.json({resultado: parseInt(query.num1)+parseInt(query.num2)}); 17 | }); 18 | 19 | app.get('/api/sumar/:n1/:n2', (req,res)=>{ 20 | let params = req.params; 21 | res.json({resultado: parseInt(params.n1)+parseInt(params.n2)}); 22 | }); 23 | 24 | app.get('/api/operacion/:expresion', (req,res)=>{ 25 | let params = req.params; 26 | res.json({resultado: eval(params.expresion)}); 27 | }); 28 | 29 | app.post('/api', (req,res)=>{ 30 | res.json({resultado: 'okpost'}); 31 | }); 32 | 33 | app.put('/api', (req,res)=>{ 34 | res.json({resultado: 'okput'}); 35 | }); 36 | 37 | app.delete('/api', (req,res)=>{ 38 | res.json({resultado: 'okdelete'}); 39 | }); 40 | 41 | -------------------------------------------------------------------------------- /clase 8/04-server-get.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | const frase = 'Hola mundo como están'; 6 | 7 | const server = app.listen(PORT, ()=>{ 8 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 9 | }); 10 | server.on('error', error=>console.log('Error en servidor', error)); 11 | 12 | app.get('/api/getFrase', (req,res)=>{ 13 | res.json({frase, 14 | error:''}); 15 | }); 16 | 17 | app.get('/api/getFrase/:num', (req,res)=>{ 18 | let params = req.params; 19 | if (params.num > 0 && params.num <= frase.length) { 20 | res.json({orden: frase[params.num - 1], 21 | error: ''}); 22 | } else { 23 | res.json({error: 'Parámetro inválido'}); 24 | } 25 | }); 26 | 27 | app.get('/api/getPalabra/:num', (req,res)=>{ 28 | let params = req.params; 29 | let arr = frase.split(' '); 30 | if (params.num > 0 && params.num <= arr.length) { 31 | res.json({orden: arr[params.num - 1], 32 | error: ''}); 33 | } else { 34 | res.json({error: 'Parámetro inválido'}); 35 | } 36 | }); 37 | 38 | -------------------------------------------------------------------------------- /clase 9/03-router.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | const routerMascotas = express.Router(); 6 | const routerPersonas = express.Router(); 7 | 8 | const personas = []; 9 | const mascotas = []; 10 | 11 | app.use(express.json()); 12 | app.use(express.urlencoded({extended: true})); 13 | 14 | app.use('/mascotas', routerMascotas); 15 | app.use('/personas', routerPersonas); 16 | 17 | const server = app.listen(PORT, ()=>{ 18 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 19 | }); 20 | server.on('error', error=>console.log('Error en servidor', error)); 21 | 22 | routerPersonas.get('/listar', (req,res)=>{ 23 | res.json({personas, error:false}); 24 | }); 25 | 26 | routerPersonas.post('/guardar', (req,res)=>{ 27 | personas.push(req.body); 28 | res.json({operacion:'persona grabada', error:''}) 29 | }); 30 | 31 | routerMascotas.get('/listar', (req,res)=>{ 32 | res.json({mascotas, error:false}); 33 | }); 34 | 35 | routerMascotas.post('/guardar', (req,res)=>{ 36 | mascotas.push(req.body); 37 | res.json({operacion:'mascota grabada', error:''}) 38 | }); 39 | 40 | -------------------------------------------------------------------------------- /clase 10/05-ejercicio-handlebars.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const handlebars = require('express-handlebars'); 3 | 4 | const app = express(); 5 | const PORT = 8080; 6 | 7 | app.use(express.static('public')); 8 | 9 | const server = app.listen(PORT, () => { 10 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 11 | }); 12 | server.on('error', error => console.log('Error en servidor', error)); 13 | 14 | app.engine( 15 | "hbs", 16 | handlebars({ 17 | extname: ".hbs", 18 | defaultLayout: "index.hbs", 19 | layoutsDir: __dirname + "/views/layouts", 20 | partialsDir: __dirname + "/views/partials" 21 | }) 22 | ); 23 | 24 | app.set('views', './views'); // especifica el directorio de vistas 25 | app.set('view engine', 'hbs'); // registra el motor de plantillas 26 | 27 | 28 | let fakeAPI = () => 29 | ({ 30 | nombre: "Sergio", 31 | apellido: "Sirotinsky", 32 | edad: 44, 33 | mail: "sergio.sirotinsky@bbva.com", 34 | telefono: "1145283867" 35 | }); 36 | 37 | app.get('/', function(req, res) { 38 | res.render('main2', { datos: fakeAPI() }); 39 | }); -------------------------------------------------------------------------------- /clase 10/02-motor.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | const server = app.listen(PORT, () => { 7 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 8 | }); 9 | server.on('error', error => console.log('Error en servidor', error)); 10 | 11 | const fs = require('fs'); 12 | // defino el motor de plantilla 13 | app.engine('ntp', function(filePath, options, callback) { 14 | fs.readFile(filePath, function(err, content) { 15 | if (err) { 16 | return callback(new Error(err)); 17 | } 18 | const rendered = content.toString() 19 | .replace('#title#', '' + options.title + '') 20 | .replace('#message#', '' + options.message + '') 21 | .replace('$$aaa//', '' + options.a + ''); 22 | return callback(null, rendered); 23 | }); 24 | }); 25 | app.set('views', './views'); // especifica el directorio de vistas 26 | app.set('view engine', 'ntp'); // registra el motor de plantillas 27 | 28 | app.get('/', function(req, res) { 29 | res.render('index', { title: 'Hola', a: 'pepe', message: 'Bienvenidos a tod@s!!', 'aaa': 'holaaa' }); 30 | }); -------------------------------------------------------------------------------- /clase 15/bundle.js: -------------------------------------------------------------------------------- 1 | !function(e){var n={};function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:o})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)t.d(o,r,function(n){return e[n]}.bind(null,r));return o},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){t(1),t(2),e.exports=t(3)},function(e,n){mensaje1="Soy el mensaje 1",setTimeout(()=>console.log(mensaje1),1e3)},function(e,n){mensaje2="Soy el mensaje 2",setTimeout(()=>console.log(mensaje2),2e3)},function(e,n){mensaje3="Soy el mensaje 3",setTimeout(()=>console.log(mensaje3),6e3)}]); -------------------------------------------------------------------------------- /clase 10/public/personales.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Probando Handlebars... 9 | 10 | 11 | 12 |

Datos Personales

13 |
    14 | 15 |
16 | 17 | 18 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /clase 9/04-static.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | const routerMascotas = express.Router(); 6 | const routerPersonas = express.Router(); 7 | 8 | const personas = []; 9 | const mascotas = []; 10 | 11 | app.use(express.json()); 12 | app.use(express.urlencoded({extended: true})); 13 | 14 | app.use('/mascotas', routerMascotas); 15 | app.use('/personas', routerPersonas); 16 | 17 | app.use(express.static('public')); 18 | 19 | const server = app.listen(PORT, ()=>{ 20 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 21 | }); 22 | server.on('error', error=>console.log('Error en servidor', error)); 23 | 24 | routerPersonas.get('/listar', (req,res)=>{ 25 | res.json({personas, error:false}); 26 | }); 27 | 28 | routerPersonas.post('/guardar', (req,res)=>{ 29 | personas.push(req.body); 30 | res.json({operacion:'persona grabada', error:''}) 31 | }); 32 | 33 | routerMascotas.get('/listar', (req,res)=>{ 34 | res.json({mascotas, error:false}); 35 | }); 36 | 37 | routerMascotas.post('/guardar', (req,res)=>{ 38 | mascotas.push(req.body); 39 | res.json({operacion:'mascota grabada', error:''}) 40 | }); 41 | 42 | -------------------------------------------------------------------------------- /clase 10/04-handlebars.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const handlebars = require('express-handlebars'); 3 | 4 | const app = express(); 5 | const PORT = 8080; 6 | 7 | app.use(express.static('public')); 8 | 9 | const server = app.listen(PORT, () => { 10 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 11 | }); 12 | server.on('error', error => console.log('Error en servidor', error)); 13 | 14 | app.engine( 15 | "hbs", 16 | handlebars({ 17 | extname: ".hbs", 18 | defaultLayout: "index.hbs", 19 | layoutsDir: __dirname + "/views/layouts", 20 | partialsDir: __dirname + "/views/partials" 21 | }) 22 | ); 23 | 24 | app.set('views', './views'); // especifica el directorio de vistas 25 | app.set('view engine', 'hbs'); // registra el motor de plantillas 26 | 27 | 28 | let fakeAPI = () => [ 29 | { name: 'Katarina', lane: 'midlaner' }, 30 | { name: 'Jayce', lane: 'toplaner' }, 31 | { name: 'Heimerdinger', lane: 'toplaner' }, 32 | { name: 'Jayce', lane: 'midlaner' }, 33 | { name: 'Azir', lane: 'midlaner' } 34 | ] 35 | 36 | app.get('/', function(req, res) { 37 | res.render('main', { suggestedChamps: fakeAPI(), listExists: true }); 38 | }); -------------------------------------------------------------------------------- /clase 24/01-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const cookieParser = require('cookie-parser'); 3 | 4 | const app = express(); 5 | const PORT = 8080; 6 | 7 | // app.use(cookieParser()); 8 | app.use(cookieParser('123456')); 9 | 10 | const server = app.listen(PORT, ()=>{ 11 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 12 | }); 13 | server.on('error', error=>console.log('Error en servidor', error)); 14 | 15 | 16 | app.get('/test', (req,res)=>{ 17 | res.send('Server levantado...'); 18 | }); 19 | 20 | app.get('/set', (req,res)=>{ 21 | // res.cookie('server', 'express').send('Cookie set'); 22 | res.cookie('server', 'express', { signed: true } ).send('Cookie set'); 23 | }); 24 | 25 | app.get('/setEX', (req,res)=>{ 26 | res.cookie('server2', 'express2',{maxAge: 60000}).send('Cookie setEX'); 27 | }); 28 | 29 | app.get('/get', (req,res)=>{ 30 | // console.log('Unsigned.:', req.cookies); 31 | // console.log('Valor de mi cookie:', req.cookies.server); 32 | console.log('Signed:', req.signedCookies); 33 | console.log('Mi cookie:', req.signedCookies.server); 34 | res.send({}); 35 | }); 36 | 37 | app.get('/clr', (req,res)=>{ 38 | res.clearCookie('server').send('Cookie clear'); 39 | }); -------------------------------------------------------------------------------- /clase 9/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Mi página estática 8 | 9 | 10 | 11 |

Bienvenidos a mi página estática

12 | 13 |
14 |
15 | Datos de la Persona 16 | Nombre: 17 | Apellido: 18 | Edad 19 |
20 | 21 |
22 | 23 |
24 | 25 |
26 |
27 | Datos de la Mascota 28 | Nombre: 29 | Raza: 30 | Edad 31 |
32 | 33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /clase 9/06-multer.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const multer = require('multer'); 3 | 4 | const app = express(); 5 | const PORT = 8080; 6 | 7 | const storage = multer.diskStorage({ 8 | destination: (req,file,cb)=>{ 9 | cb(null,'uploads') 10 | }, 11 | filename: (req,file,cb)=>{ 12 | cb(null,file.fieldname + '-' + Date.now()) 13 | } 14 | }); 15 | 16 | const upload = multer({storage}); 17 | 18 | app.use(express.urlencoded({extended: true})); 19 | app.use(express.static('public2')); 20 | 21 | const server = app.listen(PORT, ()=>{ 22 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 23 | }); 24 | server.on('error', error=>console.log('Error en servidor', error)); 25 | 26 | app.post('/uploadfile',upload.single('myFile'),(req,res)=>{ 27 | console.log('no les miento'); 28 | const file = req.file; 29 | if (!file){ 30 | res.status(400).send('No envío ningún archivo'); 31 | } else { 32 | res.send(file); 33 | } 34 | }); 35 | 36 | app.post('/uploadmultiple',upload.array('myFiles', 12),(req,res)=>{ 37 | const files = req.files; 38 | if (!files){ 39 | res.status(400).send('No envío ningún archivo'); 40 | } else { 41 | res.send(files); 42 | } 43 | }); 44 | 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | clase 2/typescript/ejemplo/node_modules 2 | clase 5/node_modules 3 | clase 7/node_modules 4 | clase 8/node_modules 5 | clase 9/node_modules 6 | clase 10/node_modules 7 | clase 11/node_modules 8 | clase 12/node_modules 9 | clase 13/node_modules 10 | clase 13/colores/node_modules 11 | clase 13/chat/node_modules 12 | clase 14/node_modules 13 | clase 14/ts/node_modules 14 | clase 14/ts2/node_modules 15 | clase 14/ts3/node_modules 16 | clase 14/babel/node_modules 17 | clase 15/node_modules 18 | clase 15/ts/node_modules 19 | clase 15/perimetro/node_modules 20 | clase 17/node_modules 21 | clase 17/sqlite/node_modules 22 | clase 20/node_modules 23 | clase 21/node_modules 24 | clase 22/node_modules 25 | clase 22/mocks/node_modules 26 | clase 23/node_modules 27 | clase 24/node_modules 28 | clase 24/session/node_modules 29 | clase 25/node_modules 30 | clase 25/mongo-session/node_modules 31 | clase 25/redis-session/node_modules 32 | clase 26/node_modules 33 | clase 26/aut-passport/node_modules 34 | clase 27/facebook/node_modules 35 | clase 27/twitter/node_modules 36 | clase 27/jwt/node_modules 37 | clase 28/node_modules 38 | clase 29/server-cluster/node_modules 39 | clase 30/node_modules 40 | clase 31 41 | after/sockets/node_modules 42 | facebook/node_modules 43 | mongo 44 | mongo1 45 | mongoDB 46 | javascript 47 | nosubir 48 | -------------------------------------------------------------------------------- /clase 27/jwt/utils/utils.js: -------------------------------------------------------------------------------- 1 | require('dotenv').config({path: './config/.env'}); 2 | const jwt = require('jsonwebtoken'); 3 | const bcrypt = require('bcrypt'); 4 | 5 | const tokenSecretJWT = process.env.SECRET_JWT; 6 | function generateToken(user) { 7 | let expireTime = process.env.EXP_JWT || '24h'; 8 | let token = jwt.sign({data: user}, tokenSecretJWT, {expiresIn: expireTime}); 9 | return token; 10 | } 11 | 12 | function encryptPassword(pass) { 13 | const saltRounds = 10; 14 | const hash = bcrypt.hashSync(pass, saltRounds); 15 | return hash; 16 | } 17 | 18 | function verifyToken(req, res, next){ 19 | const token = req.headers.authorization; 20 | if (token){ 21 | jwt.verify(token, tokenSecretJWT, (err, value)=>{ 22 | if (err){ 23 | res.status(401).json({error: 'Token inválido'}); 24 | } else { 25 | req.user = value.data; 26 | next(); 27 | } 28 | }) 29 | } else { 30 | res.status(403).json({error: 'Debe proveer un token'}); 31 | } 32 | } 33 | 34 | function validPassword(passwordUser, password){ 35 | return bcrypt.compareSync(password , passwordUser); 36 | } 37 | 38 | module.exports = { 39 | generateToken, 40 | verifyToken, 41 | encryptPassword, 42 | validPassword 43 | } -------------------------------------------------------------------------------- /clase 25/01-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const session = require('express-session'); 3 | const FileStore = require('session-file-store')(session); 4 | 5 | const app = express(); 6 | const PORT = 8080; 7 | 8 | app.use(session({ 9 | store: new FileStore({path: './sesiones', ttl: 50, retries: 0}), 10 | secret: 'secreto', 11 | resave: false, 12 | saveUninitialized: false, 13 | cookie: { maxAge: 50000 } 14 | })); 15 | 16 | const server = app.listen(PORT, ()=>{ 17 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 18 | }); 19 | server.on('error', error=>console.log('Error en servidor', error)); 20 | 21 | 22 | app.get('/test', (req,res)=>{ 23 | res.send('Server levantado...'); 24 | }); 25 | 26 | app.get('/con-session', (req,res)=>{ 27 | if (req.session.contador) { 28 | req.session.contador++; 29 | res.send(`Ud. ha visitado el sitio ${req.session.contador} veces`); 30 | } else { 31 | req.session.contador = 1; 32 | res.send('Bienvenido!'); 33 | } 34 | }); 35 | 36 | app.get('/logout', (req,res)=>{ 37 | req.session.destroy(err=>{ 38 | if (err){ 39 | res.json({status: 'Logout error', body: err}); 40 | } else { 41 | res.send('Logout ok!'); 42 | } 43 | }); 44 | }); 45 | 46 | -------------------------------------------------------------------------------- /clase 25/mongo-session/03-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const session = require('express-session'); 3 | const MongoStore = require('connect-mongo'); 4 | 5 | const app = express(); 6 | const PORT = 8080; 7 | 8 | app.use(session({ 9 | store: MongoStore.create({ 10 | mongoUrl: 'mongodb://localhost/sesiones' 11 | }), 12 | secret: 'secreto', 13 | resave: false, 14 | saveUninitialized: false, 15 | // cookie: { maxAge: 5000 } 16 | })); 17 | 18 | const server = app.listen(PORT, ()=>{ 19 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 20 | }); 21 | server.on('error', error=>console.log('Error en servidor', error)); 22 | 23 | 24 | app.get('/test', (req,res)=>{ 25 | res.send('Server levantado...'); 26 | }); 27 | 28 | app.get('/con-session', (req,res)=>{ 29 | if (req.session.contador) { 30 | req.session.contador++; 31 | res.send(`Ud. ha visitado el sitio ${req.session.contador} veces`); 32 | } else { 33 | req.session.contador = 1; 34 | res.send('Bienvenido!'); 35 | } 36 | }); 37 | 38 | app.get('/logout', (req,res)=>{ 39 | req.session.destroy(err=>{ 40 | if (err){ 41 | res.json({status: 'Logout error', body: err}); 42 | } else { 43 | res.send('Logout ok!'); 44 | } 45 | }); 46 | }); 47 | 48 | -------------------------------------------------------------------------------- /clase 24/02-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const cookieParser = require('cookie-parser'); 3 | 4 | const app = express(); 5 | const PORT = 8080; 6 | 7 | app.use(cookieParser()); 8 | 9 | const server = app.listen(PORT, ()=>{ 10 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 11 | }); 12 | server.on('error', error=>console.log('Error en servidor', error)); 13 | 14 | 15 | app.get('/test', (req,res)=>{ 16 | res.send('Server levantado...'); 17 | }); 18 | 19 | app.get('/set-cookie', (req,res)=>{ 20 | let {nombre,valor,duracion} = req.query; 21 | 22 | if ((nombre == undefined) || (valor == undefined) || (nombre.trim() == '') || (valor.trim() == '')) { 23 | res.json({ error: 'set-cookie: falta nombre ó valor' }); 24 | } 25 | 26 | if (duracion == undefined) { 27 | res.cookie(nombre, valor).json({ proceso: 'ok'}); 28 | } else { 29 | res.cookie(nombre, valor, {maxAge: duracion}).json({ proceso: 'ok'}); 30 | } 31 | }); 32 | 33 | app.get('/clear-cookie', (req,res)=>{ 34 | let {nombre} = req.query; 35 | if ((nombre == undefined) || (nombre.trim() == '')) { 36 | res.json({ error: 'clear-cookie: falta nombre' }); 37 | } 38 | res.clearCookie(nombre).json({ proceso: 'ok'}); 39 | }); 40 | 41 | app.get('/get-cookies', (req,res)=>{ 42 | res.send(req.cookies); 43 | }); -------------------------------------------------------------------------------- /after/sockets/public/goles.js: -------------------------------------------------------------------------------- 1 | let socket = io(); 2 | 3 | socket.on('partidos', (data)=>{ 4 | render(data); 5 | }); 6 | 7 | let render = (data) => { 8 | let html = data.map((e,i)=>` 9 |
10 |
+
11 |
-
12 | ${e.local.goles} 13 | ${e.local.equipo} 14 | vs. 15 | ${e.visitante.equipo} 16 | ${e.visitante.goles} 17 |
+
18 |
-
19 |
20 | `).join(' '); 21 | document.getElementById("partidos").innerHTML = html; 22 | } 23 | 24 | let sumaGolLocal = (n) => { 25 | socket.emit('suma-gol', {tipo: 'local', id: n.id}) 26 | } 27 | 28 | let restaGolLocal = (n) => { 29 | socket.emit('resta-gol', {tipo: 'local', id: n.id}) 30 | } 31 | 32 | let sumaGolVisitante = (n) => { 33 | socket.emit('suma-gol', {tipo: 'visitante', id: n.id}) 34 | } 35 | 36 | let restaGolVisitante = (n) => { 37 | socket.emit('resta-gol', {tipo: 'visitante', id: n.id}) 38 | } 39 | -------------------------------------------------------------------------------- /clase 11/views/personas.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Mi plantilla de ingreso de datos 7 | 8 | 9 | 10 |

Ingrese Datos

11 |
12 | Nombre: Apellido: Edad: 13 | 14 |
15 |
16 | 17 |
18 |

Historial

19 | 20 | 22 | 23 | 24 | 25 | <% personas.forEach(function(persona) { %> 26 | 27 | 30 | 33 | 36 | 37 | <% }); %> 38 |
21 | NombreApellidoEdad
28 | <%= persona.nombre %> 29 | 31 | <%= persona.apellido %> 32 | 34 | <%= persona.edad %> 35 |
39 | <%if (personas.length == 0) { %> 40 |

No existe información

41 | <%} %> 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /clase 1/10-flecha.js: -------------------------------------------------------------------------------- 1 | // Sin Parámetros: 2 | // function noFlecha() { 3 | // console.log('NO Flecha!') 4 | // return 'Vuelvo de NO flecha'; 5 | // } 6 | 7 | // let siFlecha = () => { 8 | // console.log('Si Flecha!'); 9 | // return 'Vuelvo de SI flecha' 10 | // } 11 | 12 | // // console.log(noFlecha()); 13 | // console.log(siFlecha()); 14 | 15 | 16 | // Con Parámetros: 17 | // function noFlecha(a, b) { 18 | // console.log('NO Flecha!', a, b) 19 | // return 'Vuelvo de NO flecha'; 20 | // } 21 | 22 | // let siFlecha = (a, b) => { 23 | // console.log('Si Flecha!', a, b); 24 | // return 'Vuelvo de SI flecha' 25 | // } 26 | 27 | // console.log(noFlecha(1, 2)); 28 | // console.log(siFlecha(1, 2)); 29 | 30 | 31 | 32 | // Si sólo ejecuta un 33 | // return : 34 | // function noFlecha(a, b) { 35 | // return 'Vuelvo de NO flecha ' + a + b; 36 | // } 37 | 38 | // let siFlecha = (a, b) => 'Vuelvo de SI flecha ' + a + b; 39 | 40 | // console.log(noFlecha(1, 2)); 41 | // console.log(siFlecha(1, 2)); 42 | 43 | // Ejemplo práctico: 44 | // lista = [1, 2, 3, 4, 5, 6] 45 | // console.log(lista.filter(e => e > 2)); 46 | 47 | //Uso de this: 48 | function Probando() { 49 | this.prueba = 50; 50 | setTimeout(function() { 51 | console.log(this); 52 | }) 53 | setTimeout(() => console.log(this), 1000); 54 | } 55 | prueba = 10; 56 | var prueba = new Probando(); -------------------------------------------------------------------------------- /clase 28/08-ejercicio.js: -------------------------------------------------------------------------------- 1 | let salida; 2 | 3 | process.on('exit',(code)=>{ 4 | console.log(salida); 5 | if (code != 0) { 6 | console.log('Saliendo con error:', code); 7 | } 8 | }); 9 | 10 | const tipoDato = (e)=> { 11 | e = e.toLowerCase(); 12 | if (!isNaN(e)) { 13 | return 'number'; 14 | } else if (e=='true' || e=='false'){ 15 | return 'boolean'; 16 | } else { 17 | return 'string'; 18 | } 19 | } 20 | 21 | let numeros = process.argv.slice(2); 22 | let tipos = numeros.map(e=>tipoDato(e)); 23 | 24 | if (numeros.length == 0) { 25 | salida = { 26 | error: { 27 | descripcion: 'entrada vacía' 28 | } 29 | }; 30 | process.exit(-4); 31 | } else { 32 | if (tipos.some(e=>e=='string' || e=='boolean')) { 33 | salida = { 34 | error: { 35 | descripcion: 'error de tipo', 36 | numeros, 37 | tipos 38 | } 39 | }; 40 | process.exit(-5); 41 | } else { 42 | let numerosN = numeros.map(e=>Number(e)); 43 | salida = { 44 | numeros, 45 | promedio: numerosN.reduce((a, b) => a + b, 0) / numerosN.length, 46 | max: Math.max(...numerosN), 47 | min: Math.min(...numerosN), 48 | ejecutable: process.argv[0], 49 | pid: process.pid 50 | } 51 | } 52 | } 53 | 54 | 55 | -------------------------------------------------------------------------------- /clase 8/03-get.js: -------------------------------------------------------------------------------- 1 | import express from 'express'; 2 | 3 | const app = express(); 4 | const PORT = 8080; 5 | 6 | const server = app.listen(PORT, ()=>{ 7 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 8 | }); 9 | server.on('error', error=>console.log('Error en servidor', error)); 10 | 11 | app.get('/api/mensajes', (req,res)=>{ 12 | console.log('get request con query parameters a api/mensajes recibido'); 13 | let query = req.query; 14 | let cantidad = Object.entries(req.query).length; 15 | console.log(query); 16 | if (cantidad > 0) { 17 | const objRes = { 18 | msg: 'Hola Mundo con query parameters!', 19 | parametros: cantidad, 20 | query: query, 21 | error: false 22 | }; 23 | res.json(objRes); 24 | } else { 25 | const objRes = { 26 | msg: 'Hola Mundo sin query parameters!', 27 | parametros: 0, 28 | error: false 29 | }; 30 | res.json(objRes); 31 | } 32 | }); 33 | 34 | //Incorporamos get con identificador 35 | app.get('/api/mensajes/:id', (req,res)=>{ 36 | console.log('get request con identificador a api/mensajes recibido'); 37 | console.log(req.params); 38 | let params = req.params; 39 | const objRes = { 40 | msg: 'Hola Mundo con identificador!', 41 | id: params.id, 42 | error: false 43 | }; 44 | res.json(objRes); 45 | }); 46 | -------------------------------------------------------------------------------- /clase 25/redis-session/02-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const session = require('express-session'); 3 | const redis = require('redis'); 4 | const client = redis.createClient(); 5 | const RedisStore = require('connect-redis')(session); 6 | 7 | const app = express(); 8 | const PORT = 8080; 9 | 10 | app.use(session({ 11 | store: new RedisStore({ 12 | host: 'localhost', 13 | port: 6379, 14 | client: client, 15 | ttl: 5 16 | }), 17 | secret: 'secreto', 18 | resave: false, 19 | saveUninitialized: false, 20 | // cookie: { maxAge: 5000 } 21 | })); 22 | 23 | const server = app.listen(PORT, ()=>{ 24 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 25 | }); 26 | server.on('error', error=>console.log('Error en servidor', error)); 27 | 28 | 29 | app.get('/test', (req,res)=>{ 30 | res.send('Server levantado...'); 31 | }); 32 | 33 | app.get('/con-session', (req,res)=>{ 34 | if (req.session.contador) { 35 | req.session.contador++; 36 | res.send(`Ud. ha visitado el sitio ${req.session.contador} veces`); 37 | } else { 38 | req.session.contador = 1; 39 | res.send('Bienvenido!'); 40 | } 41 | }); 42 | 43 | app.get('/logout', (req,res)=>{ 44 | req.session.destroy(err=>{ 45 | if (err){ 46 | res.json({status: 'Logout error', body: err}); 47 | } else { 48 | res.send('Logout ok!'); 49 | } 50 | }); 51 | }); 52 | 53 | -------------------------------------------------------------------------------- /clase 25/mongo-session/04-server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const session = require('express-session'); 3 | const MongoStore = require('connect-mongo'); 4 | const advancedOptions = {useNewUrlParser: true, useUnifiedTopology: true}; 5 | 6 | const app = express(); 7 | const PORT = 8080; 8 | 9 | app.use(session({ 10 | store: MongoStore.create({ 11 | mongoUrl: 'mongodb+srv://sergiosiro:ko7YMDi8zZ2PfNrL@cluster0.8vpxz.mongodb.net/myFirstDatabase?retryWrites=true&w=majority', 12 | mongoOptions: advancedOptions 13 | }), 14 | secret: 'secreto', 15 | resave: false, 16 | saveUninitialized: false, 17 | // cookie: { maxAge: 5000 } 18 | })); 19 | 20 | const server = app.listen(PORT, ()=>{ 21 | console.log('Servidor HTTP escuchando en el puerto', server.address().port); 22 | }); 23 | server.on('error', error=>console.log('Error en servidor', error)); 24 | 25 | 26 | app.get('/test', (req,res)=>{ 27 | res.send('Server levantado...'); 28 | }); 29 | 30 | app.get('/con-session', (req,res)=>{ 31 | if (req.session.contador) { 32 | req.session.contador++; 33 | res.send(`Ud. ha visitado el sitio ${req.session.contador} veces`); 34 | } else { 35 | req.session.contador = 1; 36 | res.send('Bienvenido!'); 37 | } 38 | }); 39 | 40 | app.get('/logout', (req,res)=>{ 41 | req.session.destroy(err=>{ 42 | if (err){ 43 | res.json({status: 'Logout error', body: err}); 44 | } else { 45 | res.send('Logout ok!'); 46 | } 47 | }); 48 | }); 49 | 50 | -------------------------------------------------------------------------------- /facebook/sslcert/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIEGjCCAwKgAwIBAgIULlyPMzdeDBepR21QuIzQrKhQYeMwDQYJKoZIhvcNAQEL 3 | BQAwgYYxCzAJBgNVBAYTAkFSMQ4wDAYDVQQIDAVTdGF0ZTERMA8GA1UEBwwITG9j 4 | YXRpb24xGjAYBgNVBAoMEU9yZ2FuaXphdGlvbiBOYW1lMRwwGgYDVQQLDBNPcmdh 5 | bml6YXRpb25hbCBVbml0MRowGAYDVQQDDBF3d3cubG9jYWxob3N0LmNvbTAeFw0y 6 | MTExMTAyMzU3MjRaFw0yMjExMTAyMzU3MjRaMIGGMQswCQYDVQQGEwJBUjEOMAwG 7 | A1UECAwFU3RhdGUxETAPBgNVBAcMCExvY2F0aW9uMRowGAYDVQQKDBFPcmdhbml6 8 | YXRpb24gTmFtZTEcMBoGA1UECwwTT3JnYW5pemF0aW9uYWwgVW5pdDEaMBgGA1UE 9 | AwwRd3d3LmxvY2FsaG9zdC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK 10 | AoIBAQC4nLDsyJ+OyojZoZ3mQ1u+Mxt6yZW+N+eewXCvPdEahy8GVWWIUHD6pzJy 11 | IhX/zo8f4esZ5m6YhEgvS5nrFhi1fUMvGnS1sXJ92Kh62+dhVU4toXPrNVKIIsLO 12 | bu5qWU3GdT9EfSdCTNH9y55xmfYWmeZKo27VYSgzfKIud7YTb95Sop4w3WLJyvOU 13 | EZvK1v9tLmgsVhgZ2gaPPNfPEL3k+yTJvNsNopvKaV1jfw0NSS5R6IhW1iEvYsFQ 14 | z2xpc0NM2xzOJRTI6QrR6O53MbBnQSWN5hztsBo4lDaU4KN9/6kNRsxyFesUoVnE 15 | l7jMR+l8bNiiPvTUQC4NxUJUl0CpAgMBAAGjfjB8MA4GA1UdDwEB/wQEAwIDiDAT 16 | BgNVHSUEDDAKBggrBgEFBQcDATA2BgNVHREELzAtghF3d3cubG9jYWxob3N0LmNv 17 | bYINbG9jYWxob3N0LmNvbYIJbG9jYWxob3N0MB0GA1UdDgQWBBQW+Lc/Ktp+gH6E 18 | u4Yt9xhkxdd4UTANBgkqhkiG9w0BAQsFAAOCAQEARNuUqT9DW+LpMRjDFZz2cVcZ 19 | ecev6Dv+/BpvgcE9YXL3RvlOriPW7nYQJiBFFM/vbmeB1kf7THURhdriFE4w4PS5 20 | IIjmfD7whtx02HpCZw/KEnpK06ZMeP8OOFLKuOSu3p2+7l29WYPtO5rAQ6kCyzZi 21 | Gd/MWoU+6sWjHrGaNmip2kYni3gzAMD3oQIisZ2Ws/6Y/OLQKK8VXQfYFTZIMeoa 22 | s3jBu8DDTjojxDyK31SOORr3U1RXzLeNJ6mZt5wjhyw2gPE46j4f64e1jbkbsgjd 23 | srFV9TGiM7B7ik6uj26yTQTkpfOn02lmJGqsxVJB8qcFZUTs2BwtvEodYHeIqg== 24 | -----END CERTIFICATE----- 25 | --------------------------------------------------------------------------------