---
# System prepended metadata

title: SOFTWARE ENGINEERING AT BLOCKFUSE LABS (Backend)

---

# SOFTWARE ENGINEERING AT BLOCKFUSE LABS (Backend)

## Server
server is a program that runs on a computer and listens for incoming requests from other computers (clients) over a network. When a request is received, the server processes it and sends a response back to the client.

#### Key Components of a Node.js Server

- http module: The built-in http module is the foundation for creating web servers in Node.js. It provides functionalities for handling Hypertext Transfer Protocol (HTTP) requests and responses. You use this module to create a server instance and define how it should behave when a request comes in.

- createServer() method: This method from the http module is used to create a new HTTP server object. It takes a callback function as an argument, which is executed every time a request is made to the server.

- Request and Response Objects: The callback function in createServer() receives two main arguments: (req, res)

- request (or req) object: This object contains all the information about the incoming request, such as the URL, headers, and request body.

- response (or res) object: This object is used to send data back to the client. You can set headers, status codes, and write the response body using methods on this object.

- listen() method: After creating the server, you use the listen() method to bind it to a specific port on your computer. This makes the server start listening for incoming requests on that port. For example, a web server might listen on port 3000 or 5000

EXAMPLE:
Here is a simple example of a Node.js server that listens on port 3000 and responds with "Hello World!"

```
const http = require('http');

const port = 3000;

const server = http.createServer((req, res) => {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World!');
});

server.listen(port, () => {
  console.log(`Server running at http://localhost:${port}/`);
});
```

## Express
express is a lightweight and flexible Node.js web application framework. It simplifies the process of building web servers, APIs, and web applications in Node.js.

#### Key Features of Express

- Routing: Express provides a powerful routing system that allows you to define how an application's endpoints (URLs) respond to client requests. Instead of manually checking the request URL and method, you can use methods like app.get(), app.post(), etc., to handle specific routes.

- HTTP Utilities: Express includes a variety of helper methods for dealing with HTTP requests and responses, such as res.send(), res.json(), which are much simpler to use than the native Node.js methods


CONCLUSION:
Express make you create you server easy and stress free not starting from begining. and it helps in simplicity and flexibility it also makes common tasks much easier and more organized.