throw new TypeError(`Missing parameter name at ${i}: ${DEBUG_URL}`);
Full error message
Gadget Controller Ts Code :
import { Request, Response, NextFunction } from 'express';
import { Status } from '@prisma/client'
import prisma from '../utils/prisma.client';
import { AppError } from '../utils/error.handler';
// Generate random codename for gadgets
const generateCodename = (): string => {
const adjectives = ['Mighty', 'Silent', 'Phantom', 'Shadow', 'Stealth', 'Covert', 'Invisible', 'Deadly', 'Rapid', 'Quantum'];
const nouns = ['Eagle', 'Panther', 'Cobra', 'Viper', 'Falcon', 'Wolf', 'Hawk', 'Tiger', 'Raven', 'Phoenix'];
const randomAdjective = adjectives[Math.floor(Math.random() * adjectives.length)];
const randomNoun = nouns[Math.floor(Math.random() * nouns.length)];
return `The ${randomAdjective} ${randomNoun}`;
};
// Generate random mission success probability
const generateMissionProbability = (): number => {
return Math.floor(Math.random() * 100);
};
// Get all gadgets with optional status filter
export const getAllGadgets = async (req: Request, res: Response, next: NextFunction) => {
try {
const { status } = req.query;
const whereClause = status ? { status: status as Status } : {};
const gadgets = await prisma.gadget.findMany({
where: whereClause
});
const gadgetsWithProbability = gadgets.map(gadget => ({
...gadget,
missionSuccessProbability: generateMissionProbability()
}));
res.status(200).json({
status: 'success',
results: gadgetsWithProbability.length,
data: {
gadgets: gadgetsWithProbability
}
});
} catch (error) {
next(error);
}
};
// Create a new gadget
export const createGadget = async (req: Request, res: Response, next: NextFunction) => {
try {
const { status } = req.body;
const gadget = await prisma.gadget.create({
data: {
name: generateCodename(),
status: status || 'Available'
}
});
res.status(201).json({
status: 'success',
data: {
gadget
}
});
} catch (error) {
next(error);
}
};
// Update a gadget
export const updateGadget = async (req: Request, res: Response, next: NextFunction) => {
try {
const { id } = req.params;
const { name, status } = req.body;
const gadget = await prisma.gadget.findUnique({
where: { id }
});
if (!gadget) {
return next(new AppError('No gadget found with that ID', 404));
}
const updatedGadget = await prisma.gadget.update({
where: { id },
data: {
name,
status
}
});
res.status(200).json({
status: 'success',
data: {
gadget: updatedGadget
}
});
} catch (error) {
next(error);
}
};
// Decommission a gadget (soft delete)
export const decommissionGadget = async (req: Request, res: Response, next: NextFunction) => {
try {
const { id } = req.params;
const gadget = await prisma.gadget.findUnique({
where: { id }
});
if (!gadget) {
return next(new AppError('No gadget found with that ID', 404));
}
const decommissionedGadget = await prisma.gadget.update({
where: { id },
data: {
status: 'Decommissioned',
decomissionedAt: new Date()
}
});
res.status(200).json({
status: 'success',
data: {
gadget: decommissionedGadget
}
});
} catch (error) {
next(error);
}
};
// Trigger self-destruct sequence for a gadget
export const selfDestructGadget = async (req: Request, res: Response, next: NextFunction) => {
try {
const { id } = req.params;
const gadget = await prisma.gadget.findUnique({
where: { id }
});
if (!gadget) {
return next(new AppError('No gadget found with that ID', 404));
}
// Generate confirmation code
const confirmationCode = Math.floor(100000 + Math.random() * 900000);
const updatedGadget = await prisma.gadget.update({
where: { id },
data: {
status: 'Destroyed',
selfDestruct: new Date()
}
});
res.status(200).json({
status: 'success',
confirmationCode,
message: 'Self-destruct sequence initiated',
data: {
gadget: updatedGadget
}
});
} catch (error) {
next(error);
}
};
The Gadgets Routes :
router.get('/', getAllGadgets);
router.post('/', createGadget);
router.patch('/:id', updateGadget);
router.delete('/:id', decommissionGadget);
router.post('/:id/self-destruct', selfDestructGadget);
Even though i have no error in the routing , still i am getting the error :
throw new TypeError(Missing parameter name at ${i}: ${DEBUG_URL});
^
TypeError: Missing parameter name at 1: https://git.new/pathToRegexpError
I possibly tried everything , GPT , V0 , StackOverFlow but the solutions didn't work.
Here is the package.json :
{
"name": "pg_imp",
"version": "1.0.0",
"main": "dist/index.js",
"scripts": {
"start": "node dist/index.js",
"dev": "ts-node-dev --respawn --transpile-only src/index.ts",
"build": "tsc",
"prisma:generate": "prisma generate",
"prisma:migrate": "prisma migrate dev --name init"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@types/bcrypt": "^5.0.2",
"@types/cors": "^2.8.17",
"@types/express": "^5.0.1",
"@types/jsonwebtoken": "^9.0.9",
"@types/uuid": "^10.0.0",
"prisma": "^6.5.0",
"ts-node-dev": "^2.0.0",
"typescript": "^5.8.2"
},
"dependencies": {
"@prisma/client": "^6.5.0",
"bcrypt": "^5.1.1",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
"express": "^5.1.0",
"express-validator": "^7.2.1",
"helmet": "^8.1.0",
"jsonwebtoken": "^9.0.2",
"pg": "^8.14.1",
"uuid": "^11.1.0"
}
}
Can somebody please tell , how to fix the bug ! i am unable to fix this since 48Hrs (Skill Issue)
I have tried downgrading the Express version to 4 because Solutionsource: stackoverflow \u2197
Change the fallback router from app.all('*', (req, res, next) => {}) to app.all('/{*any}', (req, res, next) => {}) You can find related resources at Moving to Express 5 The wildcard * must have a name, matching the behavior of parameters :, use /*splat instead of /* *splat matches any path without the root path. If you need to match the root path as well /, you can use /{*splat}, wrapping the wildcard in braces.
API access
Get this solution programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/error/f79e9445f4627ea094b1f2320f26f3b7196c46f9fb3ba63ff98fbe7ea0861b7ahash \u00b7 f79e9445f4627ea094b1f2320f26f3b7196c46f9fb3ba63ff98fbe7ea0861b7a