BUG: upload.js imports from non-existent ../middleware/requireAuth.js — server crashes on startup if rebuilt #88

Closed
opened 2026-05-25 19:26:29 -04:00 by zgaetano · 0 comments
Owner

Description

services/mam-api/src/routes/upload.js line 1 contains:

import requireAuth from '../middleware/requireAuth.js';

The file services/mam-api/src/middleware/requireAuth.js does not exist. The middleware file is auth.js with a named export:

// middleware/auth.js
export const requireAuth = async (req, res, next) => { ... };

The correct import (used by every other route file — cluster.js, jobs.js, metrics.js, etc.) is:

import { requireAuth } from '../middleware/auth.js';

Impact: Node.js ES module static imports fail eagerly. If the Docker image is rebuilt from the current repo, mam-api will crash on startup with:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../middleware/requireAuth.js'

The current live deployment is unaffected only because the running image was compiled before this regression was introduced.

Compounding issue: Even if requireAuth.js existed, requireAuth is imported but never used in upload.js — no route handler passes it as middleware. See related issue #86 for the auth gap.

Fix:

// Change:
import requireAuth from '../middleware/requireAuth.js';

// To:
import { requireAuth } from '../middleware/auth.js';

Then apply it to the upload routes (see #86).

## Description `services/mam-api/src/routes/upload.js` line 1 contains: ```js import requireAuth from '../middleware/requireAuth.js'; ``` The file `services/mam-api/src/middleware/requireAuth.js` **does not exist**. The middleware file is `auth.js` with a **named** export: ```js // middleware/auth.js export const requireAuth = async (req, res, next) => { ... }; ``` The correct import (used by every other route file — `cluster.js`, `jobs.js`, `metrics.js`, etc.) is: ```js import { requireAuth } from '../middleware/auth.js'; ``` **Impact:** Node.js ES module static imports fail eagerly. If the Docker image is rebuilt from the current repo, `mam-api` will **crash on startup** with: ``` Error [ERR_MODULE_NOT_FOUND]: Cannot find module '.../middleware/requireAuth.js' ``` The current live deployment is unaffected only because the running image was compiled before this regression was introduced. **Compounding issue:** Even if `requireAuth.js` existed, `requireAuth` is imported but **never used** in `upload.js` — no route handler passes it as middleware. See related issue #86 for the auth gap. **Fix:** ```js // Change: import requireAuth from '../middleware/requireAuth.js'; // To: import { requireAuth } from '../middleware/auth.js'; ``` Then apply it to the upload routes (see #86).
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: WildDragonLLC/dragonflight#88
No description provided.