I am building a complex MERN stack app, and I just want to use only 4 endpoints with four controllers.and my question is:- is this a good practice or not, and what kind of problem may encountered like security or performance issues...
import { _create, _delete, _read, _update,} from "../controller/factoryController.js";//factory endpointrouter.route("/create").post(authentication, authorization, _create);router.route("/read").get(authentication, authorization, _read);router.route("/update").put(authentication, authorization, _update);router.route("/delete").delete(authentication, authorization, _delete);export default router;//and this is one of my controllers and there is 3 more for read,update and delete//createexport const _create = asyncCatch(async (req, res, next) => { const model = selectModel(req.query.tt_nn, next); if (model) { const data = await model.create(req.body); if (!data) return next( new AppError("something went wrong unable to create the data") ); res .status(201) .json({ status: "Success", message: "data created successfully", data }); }});
I am new for express and I just need a suggestion. should i keep this kind of practice or should i quite.thank you.