From 8ad8a420fb007b164f6f39225d326ff4b58b581b Mon Sep 17 00:00:00 2001 From: Aditya Ashok Date: Fri, 30 Jan 2026 19:34:42 +0530 Subject: [PATCH] Added 404 error handler --- index.js | 1 - templates/src/app.js | 1 - templates/src/index.js | 4 ++-- templates/src/middlewares/notfound.js | 7 +++++++ 4 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 templates/src/middlewares/notfound.js diff --git a/index.js b/index.js index 273b715..eeaea6a 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,6 @@ import chalk from 'chalk'; import ora from 'ora'; // Import the ora package import inquirer from 'inquirer'; // Import the inquirer package import { exec } from 'child_process' - import { dependencies } from './snippetdependencies.js'; diff --git a/templates/src/app.js b/templates/src/app.js index 98b61e7..4bd9400 100644 --- a/templates/src/app.js +++ b/templates/src/app.js @@ -1,5 +1,4 @@ // src/app.js - const express = require("express"); const constants = require("./constants"); diff --git a/templates/src/index.js b/templates/src/index.js index e6a83ec..7fd5f5f 100644 --- a/templates/src/index.js +++ b/templates/src/index.js @@ -1,8 +1,8 @@ // src/index.js - +const notfound=require('./middlewares/notfound') const app = require('./app'); const { PORT } = require('./constants'); - +app.use(notfound) // Start the server app.listen(PORT, () => { console.log(`Server is running on http://localhost:${PORT}`); diff --git a/templates/src/middlewares/notfound.js b/templates/src/middlewares/notfound.js new file mode 100644 index 0000000..a5100cc --- /dev/null +++ b/templates/src/middlewares/notfound.js @@ -0,0 +1,7 @@ +const notfound=((req,res)=>{ + res.status(404).json({ + success: false, + message: "Route not Found" + }) +}) +module.exports= notfound \ No newline at end of file