Shoulder.dev Logo Shoulder.dev

Node.js - benhall/express-demo

Node.js is a JavaScript runtime that allows you to run JavaScript code outside of a web browser. It is built on Chrome’s V8 JavaScript engine and is used to build scalable and high-performance applications.

Here are some key features and options of Node.js:

  1. Non-blocking, event-driven architecture: Node.js uses an event-driven, non-blocking I/O model, which makes it lightweight and efficient for data-intensive real-time applications.
  2. NPM (Node Package Manager): NPM is a package manager for Node.js that provides access to a vast repository of open-source libraries and tools. It makes it easy to install, share, and manage dependencies for Node.js applications.
  3. Express.js: Express.js is a popular web application framework for Node.js that simplifies the process of building web applications and APIs. It provides a set of middleware functions that can be used to handle HTTP requests and responses.
  4. Handlebars: Handlebars is a popular templating engine for Node.js that allows you to build dynamic HTML pages. It provides a simple and intuitive syntax for defining templates and rendering data.
  5. Cookie-parser: Cookie-parser is a middleware function for Express.js that parses incoming cookies and makes them available as a property on the request object.
  6. Morgan: Morgan is a middleware function for Express.js that logs HTTP requests and responses. It provides a simple and flexible way to track and debug application activity.
  7. Debug: Debug is a module for Node.js that provides a simple and powerful debugging tool for Node.js applications. It allows you to set breakpoints, inspect variables, and step through code.
  8. Http-errors: Http-errors is a module for Node.js that provides a simple and consistent way to handle HTTP errors in Express.js applications. It provides a set of middleware functions that can be used to handle common HTTP errors.
  9. Docker: Docker is a platform for building, shipping, and running applications. It provides a simple and consistent way to package and deploy Node.js applications.
  10. Nodemon: Nodemon is a utility for Node.js that watches for changes in your code and automatically restarts the server. It makes it easy to test and debug Node.js applications.

To get started with Node.js and Express.js, you can follow these steps:

  1. Create a new directory for your project:
mkdir express-example
  1. Navigate to the newly created directory:
cd express-example
  1. Initialize a new npm project:
npm init -y
  1. Install the Express.js package:
npm install express @4.17.1
  1. Create a new server.js file and add the following lines of code:
const express = require('express');
const app = express();

app.get('/', (req, res) => {
res.send('Hello, World!');
});

app.listen(3000, () => {
console.log('Express server currently running on port 3000');
});
  1. Start the server:
npm start

Sources: