Skip to content

Commit

Permalink
did some stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
anirvinv committed Apr 16, 2024
1 parent c513a7e commit 3964268
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion backend/public/routes/admin_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ const express_1 = __importDefault(require("express"));
const admin_schema_1 = __importDefault(require("../schemas/admin_schema"));
const auth_1 = __importDefault(require("../middleware/auth"));
const roles_1 = __importDefault(require("../middleware/roles"));
const mongoose_1 = __importDefault(require("mongoose"));
const router = express_1.default.Router();
// Route to fetch an admin by its ID
router.get("/:id", [auth_1.default, roles_1.default.admin], (req, res) => {
admin_schema_1.default.findById(req.params.id)
admin_schema_1.default.findById(new mongoose_1.default.Types.ObjectId(req.params.id))
.then((admin) => {
if (!admin) {
// If admin is not found, respond with a 404 status code
Expand Down
3 changes: 2 additions & 1 deletion backend/public/routes/client_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const express_1 = __importDefault(require("express"));
const client_schema_1 = __importDefault(require("../schemas/client_schema"));
const auth_1 = __importDefault(require("../middleware/auth"));
const roles_1 = __importDefault(require("../middleware/roles"));
const mongoose_1 = __importDefault(require("mongoose"));
const router = express_1.default.Router();
router.get("/all", (req, res) => {
client_schema_1.default.find()
Expand All @@ -29,7 +30,7 @@ router.get("/all", (req, res) => {
});
// Route to fetch a client by its ID
router.get("/:id", [auth_1.default, roles_1.default.admin], (req, res) => {
client_schema_1.default.findById(req.params.id)
client_schema_1.default.findById(new mongoose_1.default.Types.ObjectId(req.params.id))
.then((client) => {
if (!client) {
// If client is not found, respond with a 404 status code
Expand Down
2 changes: 1 addition & 1 deletion backend/public/routes/order_route.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ router.get("/all", [auth_1.default, roles_1.default.volunteer], (req, res) => __
}));
// Route to fetch an order by its ID
router.get("/:id", [auth_1.default, roles_1.default.volunteer], (req, res) => {
order_schema_1.default.findById(req.params.id)
order_schema_1.default.findById(new mongoose_1.default.Types.ObjectId(req.params.id))
.then((order) => {
if (!order) {
// If client is not found, respond with a 404 status code
Expand Down
6 changes: 3 additions & 3 deletions backend/routes/admin_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import express, { Request, Response } from "express";
import Admin from "../schemas/admin_schema";
import auth from "../middleware/auth";
import roles from "../middleware/roles";

import mongoose from "mongoose";

const router = express.Router();

// Route to fetch an admin by its ID
router.get("/:id", [auth,roles.admin],(req: Request, res: Response) => {
Admin.findById(req.params.id)
router.get("/:id", [auth, roles.admin], (req: Request, res: Response) => {
Admin.findById(new mongoose.Types.ObjectId(req.params.id))
.then((admin: any) => {
if (!admin) {
// If admin is not found, respond with a 404 status code
Expand Down
4 changes: 3 additions & 1 deletion backend/routes/client_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import express, { Request, Response } from "express";
import Client from "../schemas/client_schema";
import auth from "../middleware/auth";
import roles from "../middleware/roles";
import mongoose from "mongoose";

const router = express.Router();

router.get("/all", (req: Request, res: Response) => {
Expand All @@ -17,7 +19,7 @@ router.get("/all", (req: Request, res: Response) => {

// Route to fetch a client by its ID
router.get("/:id", [auth, roles.admin], (req: Request, res: Response) => {
Client.findById(req.params.id)
Client.findById(new mongoose.Types.ObjectId(req.params.id))
.then((client: any) => {
if (!client) {
// If client is not found, respond with a 404 status code
Expand Down
2 changes: 1 addition & 1 deletion backend/routes/order_route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ router.get("/all", [auth, roles.volunteer], async (req: Request, res: Response)

// Route to fetch an order by its ID
router.get("/:id", [auth, roles.volunteer], (req: Request, res: Response) => {
Order.findById(req.params.id)
Order.findById(new mongoose.Types.ObjectId(req.params.id))
.then((order: any) => {
if (!order) {
// If client is not found, respond with a 404 status code
Expand Down

0 comments on commit 3964268

Please sign in to comment.