A backend framework for NodeJS backends. Used to make http endpoints.

Installation

npm install express you will see express dependency in package.json and a express folder in node-modules.

Importing

import express from 'express'

Boilerplate

const express = require('express')
const app = express()
 
app.listen(3000, () => {
    console.log("server is running");
});
 
app.get('/', (req, res) => {
    res.send("Hello From node API")
});

Concepts

App Anatomy

Drawing 2024-10-28 00.26.43.excalidraw

⚠ Switch to EXCALIDRAW VIEW in the MORE OPTIONS menu of this document. ⚠

Text Elements

index.js

index.js

routes

models

api1.route.js

api2.route.js

/

  • Functions for what to do for certain requests at certain endpoints
  • Exports route middleware

Frontend

Various Route js files

  • Adds middleware

Models

Database

  • Json object formats to follow when doing CRUD operations
  • exports model middleware
Link to original