Node router returning response by itself

This is probably extremely simple but I am really confused by it.
When I hit my node /verify endpoint either via postman or the frontend, a 200 response from the backend is being sent back automatically when non ‘response’ values/functions are in the /verify endpoint.

For example, if I make the function extremely simple:

This will send a 200 response back, even though I don’t appear to be setting ‘response’ anywhere.'/verify', (request, response, next) => {
  code = code.toUpperCase();

This won’t send a 200 response back (and I don’t think it should, as I’m not setting response to anything)'/verify', (request, response, next) => {
  const { code } = request.body;

Can anyone explain to me what is going on? I expect to need to reference response like the examples below to push a response back

response.status(401).send("Lorem ipsum");




Whole page (excluding other API calls which shouldn’t affect this)

const poolArray = require('../../db');
const { Router } = require('express');
const router = Router();
const bcrypt = require('bcryptjs');
const jwt = require('jsonwebtoken');'/verify', (request, response, next) => {
  // let { code } = request.body; //if commented out will send 200 back automatically, if not commented out won't pass 200 back automatically
  code = code.toUpperCase();

module.exports = router;

My index.js:

const { Pool } = require('pg');
const oracledb = require('oracledb');
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;

const { langleyUser, langleyHost, langleyDatabase, langleyPassword, langleyPort, onboardingUser, onboardingHost, onboardingDatabase, onboardingPassword, onboardingPort } = require('../secrets/db_configuration');

const langley = new Pool({ user: langleyUser, host: langleyHost, database: langleyDatabase, password: langleyPassword, port: langleyPort });
const onboarding = new Pool({ user: onboardingUser, host: onboardingHost, database: onboardingDatabase, password: onboardingPassword, port: onboardingPort });

const poolArray = {

module.exports = poolArray;


const jwt = require('jsonwebtoken');

module.exports = (request, response, next) => {
  try {
    console.log(' in check auth request');
    const decoded = jwt.verify(request.headers.authorization, 'bFm3Vp4Ga@cG6W');
    request.userData = decoded;
  } catch (error) {
    return response.status(404).json({
      message: 'Authentication failed'


119 thoughts on “Node router returning response by itself”