{"size": 884, "ext": "js", "max_stars_repo_path": "routes/api/contacts.js", "max_stars_repo_name": "YaroslavLazorenko/goit-node-homework", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "routes/api/contacts.js", "max_issues_repo_name": "YaroslavLazorenko/goit-node-homework", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "routes/api/contacts.js", "max_forks_repo_name": "YaroslavLazorenko/goit-node-homework", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 21.0476190476, "max_line_length": 74, "alphanum_fraction": 0.7126696833}
const express = require("express");
const {
  getAll,
  getById,
  add,
  updateById,
  removeById,
  updateStatusContact,
} = require("../../controllers/contacts");
const {
  addContactSchema,
  updateContactSchema,
  updateStatusSchema,
} = require("../../schemas/contacts");
const { validateBody, ctrlWrapper, guard } = require("../../middlewares");

const router = express.Router();

router.get("/", guard, ctrlWrapper(getAll));

router.get("/:contactId", guard, ctrlWrapper(getById));

router.post("/", guard, validateBody(addContactSchema), ctrlWrapper(add));

router.delete("/:contactId", guard, ctrlWrapper(removeById));

router.put(
  "/:contactId",
  guard,
  validateBody(updateContactSchema),
  ctrlWrapper(updateById)
);

router.patch(
  "/:contactId/favorite",
  guard,
  validateBody(updateStatusSchema),
  ctrlWrapper(updateStatusContact)
);

module.exports = router;
