Building Web Servers with Node.js and Express
Node.js allows you to execute JavaScript on the server. Powered by Google Chrome's V8 engine, Node.js uses an asynchronous, single-threaded, non-blocking I/O model that makes it lightweight and efficient.
Express.js Framework
Express is the de-facto standard web framework for Node.js. It simplifies routing, middleware integration, error handling, and JSON API generation.
javascript Example
const express = require('express');
const app = express();
const PORT = 3000;
app.use(express.json());
app.get('/api/health', (req, res) => {
res.json({ status: 'ok', timestamp: new Date() });
});
app.listen(PORT, () => {
console.log('Server running at http://localhost:' + PORT);
});