import express from "express";
import {
  createRecord,
  deleteRecordByPk,
  getRecordByPk,
  updateRecordByPk
} from "../controllers/genericCrudController.js";
import { listOracQuestionsEnriched } from "../controllers/oracQuestionsListController.js";

const router = express.Router();
const tableName = "orac_questions";
const primaryKeys = ["question_id", "question_type_id"];
const pkPath = primaryKeys.map((k) => `:${k}`).join("/");

router.get("/orac_questions", listOracQuestionsEnriched);
router.get("/orac_questions/", listOracQuestionsEnriched);
router.get(`/orac_questions/${pkPath}`, getRecordByPk(tableName, primaryKeys));
router.post("/orac_questions", createRecord(tableName));
router.put(`/orac_questions/${pkPath}`, updateRecordByPk(tableName, primaryKeys));
router.delete(`/orac_questions/${pkPath}`, deleteRecordByPk(tableName, primaryKeys));

export default router;
