backedn converted to ts

This commit is contained in:
QkoSad
2023-07-27 15:58:35 +03:00
parent 3bf4e9fc56
commit 40051f9d5e
18 changed files with 1394 additions and 29668 deletions
+4 -3
View File
@@ -1,9 +1,10 @@
const mongoose = require('mongoose');
import mongoose from "mongoose";
// middleware to check for a valid object id
const checkObjectId = (idToCheck) => (req, res, next) => {
import type { Request, Response, NextFunction } from "express";
const checkObjectId = (idToCheck: string) => (req: Request, res: Response, next: NextFunction) => {
if (!mongoose.Types.ObjectId.isValid(req.params[idToCheck]))
return res.status(400).json({ msg: 'Invalid ID' });
next();
};
module.exports = checkObjectId;
export default checkObjectId