Go back

Node.js and basics of backend

What is MVC?

We learnt about the most common MVC pattern in the backend MVC stands for - Model, View and Controller. Model is the data model, or how the data looks. View is how data is represented, controller is how model is linked to view.

Different backend frameworks

We can make backends with different languages -

Monolith server and microarchitectural server

Monolith servers

Monolith servers are servers where all the functionalities required for the application run on the same server and they don’t rely on any external server for any functionality.

Microarchitectural server

Microarchitectural servers have different parts of the server running on different servers.

What is node.js

Node.js is a javascript based runtime which can be used to run js backend. Node.js uses v8 engine used by chrome as the backend to run javascript on bare metal.

To make a node.js based project after installing node.js we need to -

Making a base node.js based server

node.js

const express = require("express")

const app = express();

app.use(express.json());

app.get("/", (req, res) => {
    res.json({message: "Hello from CSE 3rd year"})
})

app.post("/", (req, res) => {

    res.json({message: req.body})
})

app.listen(4000, () => {
    console.log("server listening on port 4000")
})

package.json

{
  "name": "day_10",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "dev": "nodemon index.js",
    "start": "node index.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "dependencies": {
    "express": "^4.21.0"
  },
  "devDependencies": {
    "nodemon": "^3.1.7"
  }
}