Skip to content
Merged

Test #71

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 10 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ const __dirname = path.dirname(__filename);

const router = app;

router.use(express.json()); // <--- Move express.json() to be first
router.use(mbkAuthRouter); // <--- Keep mbkAuthRouter after express.json()
router.use(express.json());
router.use(mbkAuthRouter);

router.use(compression());
router.use(minify());
Expand All @@ -37,7 +37,6 @@ router.use(
);
// Configure Handlebars
router.engine("handlebars", engine({
defaultLayout: false,
partialsDir: [
path.join(__dirname, "views/templates"),
path.join(__dirname, "views/notice"),
Expand Down Expand Up @@ -92,7 +91,7 @@ router.engine("handlebars", engine({
// Remove the options object that is provided by Handlebars
const options = args.pop();
return args.every(Boolean);
},
},
neq: function (a, b, options) {
if (options && typeof options.fn === 'function') {
return a !== b ? options.fn(this) : options.inverse(this);
Expand Down Expand Up @@ -144,46 +143,37 @@ router.use('/Assets/Images', express.static(path.join(__dirname, 'Assets'), {


router.get(["/", "/info/main"], (req, res) => {
return res.render("staticPage/index.handlebars");
return res.render("staticPage/index.handlebars", { layout: false });
});

router.get(["/home", "/dashboard"], (req, res) => {
return res.redirect("/chatbot");
});

router.get("/info/Terms&Conditions", (req, res) => {
return res.render("staticPage/Terms&Conditions");
return res.render("staticPage/Terms&Conditions.handlebars", { layout: false });
});

router.get("/info/FAQs", async (req, res) => {
res.render("staticPage/FAQs");
res.render("staticPage/FAQs.handlebars", { layout: false });
});

router.get("/info/Credits", async (req, res) => {
res.render("staticPage/Credits");
res.render("staticPage/Credits.handlebars"), { layout: false };
});

router.use(mbkAuthRouter);

router.use("/", mainRoutes);
router.use("/", dashboardRoutes);

router.get("/admin/*", async (req, res) => {
router.get("/admin*", async (req, res) => {
res.redirect("/admin/dashboard");
});

router.get('/simulate-error', (req, res, next) => {
next(new Error('Simulated router error'));
});
/*
router.get("/custom/C", (req, res) => {
return nextApp.render(req, res, "/Custom", req.query);
});
//It Render React Page, /pages
router.get("*", (req, res) => {
return handleNext(req, res);
});
*/

router.use((req, res) => {
console.log(`Path not found: ${req.url}`);
Expand All @@ -202,7 +192,5 @@ const port = 3030;
router.listen(port, () => {
console.log(`router running on http://localhost:${port}`);
});
export default router;
/*
});
*/

export default router;
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
"author": "Muhammad Bin Khalid",
"license": "MIT",
"dependencies": {
"@google/genai": "^0.12.0",
"compression": "^1.8.0",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
"express": "^4.21.2",
"express-handlebars": "^8.0.1",
"express-minify": "^1.0.0",
"express-minify-html": "^0.12.0",
"google-auth-library": "^9.15.1",
"googleapis": "^148.0.0",
"handlebars": "^4.7.8",
"marked": "^15.0.7",
Expand Down
Binary file added public/Assets/Images/chatbot-m.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/Assets/Images/chatbot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/Assets/Images/dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions routes/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ router.get("/admin/dashboard", validateSessionAndRole("SuperAdmin"), async (req,
});

res.render("admin/dashboard.handlebars", {
page: "Dashboard",
stats,
recentChats,
topUsers,
Expand Down Expand Up @@ -205,6 +206,7 @@ router.get("/admin/users", validateSessionAndRole("SuperAdmin"), async (req, res
const availableModels = modelsResult.rows.map(row => row.ai_model);

res.render("admin/users.handlebars", {
page: "UserManagement",
users,
availableModels,
searchQuery: search || "",
Expand Down Expand Up @@ -329,6 +331,7 @@ router.get("/admin/chats", validateSessionAndRole("SuperAdmin"), async (req, res
const availableModels = modelsResult.rows.map(row => row.ai_model);

res.render("admin/chats.handlebars", {
page: "ChatManagement",
chats,
usernameFilter: username || "",
selectedModel: model || "",
Expand Down
Loading