Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: dev-reetik/Data-Structures-and-Algorithms-Python
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 06a3a78
Choose a base ref
...
head repository: shushrutsharma/Data-Structures-and-Algorithms-Python
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: da9bc1e
Choose a head ref
  • 5 commits
  • 3 files changed
  • 3 contributors

Commits on Mar 30, 2024

  1. Add logger Middleware

    Jackyrd3 committed Mar 30, 2024
    Copy the full SHA
    0ee2da7 View commit details
  2. Add logger

    Jackyrd3 committed Mar 30, 2024
    Copy the full SHA
    a009945 View commit details

Commits on Jan 25, 2025

  1. Create LEARN

    I have to learn this
    Agamergen authored Jan 25, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    1990335 View commit details

Commits on Jan 30, 2025

  1. Merge pull request shushrutsharma#26 from Agamergen/patch-1

    Creating the pull
    shushrutsharma authored Jan 30, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    567e13d View commit details
  2. Merge pull request shushrutsharma#25 from Jackyrd3/middleware-impleme…

    …ntation
    
    Middleware implementation
    shushrutsharma authored Jan 30, 2025

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    da9bc1e View commit details
Showing with 62 additions and 0 deletions.
  1. +1 −0 03. Data Structures/Queues/LEARN
  2. +29 −0 loggerMiddleware.js
  3. +32 −0 server.js
1 change: 1 addition & 0 deletions 03. Data Structures/Queues/LEARN
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

29 changes: 29 additions & 0 deletions loggerMiddleware.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const express = require('express');
const app = express();

// Middleware function to log requests
app.use((req, res, next) => {
console.log(`Received a ${req.method} request to ${req.url}`);
next(); // Call next() to move to the next middleware or route handler
});

// Middleware function to check if the request contains a specific header
app.use((req, res, next) => {
if (req.headers.authorization) {
console.log('Authorization header present');
} else {
console.log('Authorization header not present');
}
next();
});

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

// Starting the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
32 changes: 32 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Import required modules
const express = require('express');

// Create an Express application
const app = express();

// Middleware function to log requests
app.use((req, res, next) => {
console.log(`Received a ${req.method} request to ${req.url}`);
next(); // Call next() to move to the next middleware or route handler
});

// Middleware function to check if the request contains a specific header
app.use((req, res, next) => {
if (req.headers.authorization) {
console.log('Authorization header present');
} else {
console.log('Authorization header not present');
}
next();
});

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

// Starting the server
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});