- Conceptos básicos
- Instalación
- Real-time chats
- Internet of Things
- Complex SPAs (Single-Page Applications)
- Real-time collaboration tools
- Streaming applications
- Microservices architecture
import { createServer } from 'node:http';
// Definición de constantes `const`
const portNumber = 3000;
// Términos: Callback y Arrow Functions
const createServerCallback = (req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello World!\n');
};
const onListenCallback = () => {
// Console log
// Template literals
console.log(`Listening on 127.0.0.1:${portNumber}`);
};
const server = createServer(createServerCallback);
// starts a simple http server locally on port 3000
server.listen(portNumber, '127.0.0.1', onListenCallback);