'use strict';
import { crudGet, crudPost, controllerDelete, crudGetById, crudUpsert, crudPut } from '../controllers/generic-controllers/crud-controller.js';
import { apiBadRequestError } from '../../../../fd-toolbox/server/web/errors.js';
import { responseMessages } from '../../../../fd-toolbox/server/web/response-messages.js';
import { apiNoContentResponse } from '../web/responses.js';
import { isValidUuid } from '../../../../fd-toolbox/uuids.js';
import { parseJsonBodyFromRequest } from '../../../../fd-toolbox/lib/utils.js';

var __defProp=Object['defineProperty'],__name=(_0x16ac6e,_0x3754d0)=>__defProp(_0x16ac6e,'name',{'value':_0x3754d0,'configurable':!![]});async function getResourceRoute(_0x174418,{params:_0x450c0f}){const _0x1191a3=_0x450c0f['resourceName'];if(_0x1191a3)return crudGet(_0x174418,_0x1191a3);else throw apiBadRequestError(responseMessages['routingError']);}__name(getResourceRoute,'getResourceRoute');async function postResourceRoute(_0x5b55f3,{params:_0x205430}){const _0x493dcd=_0x205430['resourceName'];if(_0x493dcd)return crudPost(_0x5b55f3,_0x493dcd);else throw apiBadRequestError(responseMessages['routingError']);}__name(postResourceRoute,'postResourceRoute');async function deleteResourceRoute(_0x96debd,{params:_0x30ae4b}){const _0x33bcf2=_0x30ae4b['resourceName'],_0x2f8f39=await parseJsonBodyFromRequest(_0x96debd),_0x471959=_0x2f8f39['id'];if(_0x33bcf2){const _0x49de0d=await controllerDelete(_0x33bcf2,_0x471959);if(_0x49de0d['ok'])return apiNoContentResponse();else throw apiBadRequestError();}else throw apiBadRequestError(responseMessages['routingError']);}__name(deleteResourceRoute,'deleteResourceRoute');async function putResourceRoute(_0x2beb2c,{params:_0x16351a}){return putResource(_0x2beb2c,_0x16351a['resourceName']);}__name(putResourceRoute,'putResourceRoute');async function getResourceByIdRoute(_0x5db4ef,{params:_0x5ce3a9}){const _0x40e80e=_0x5ce3a9['resourceName'],_0x4b750e=_0x5ce3a9['id'];if(_0x4b750e&&isValidUuid(_0x4b750e)&&_0x40e80e)return crudGetById(_0x5db4ef,_0x40e80e,_0x4b750e);else throw apiBadRequestError(responseMessages['routingError']);}__name(getResourceByIdRoute,'getResourceByIdRoute');async function putResourceByIdRoute(_0xc54777,{params:_0x3ce4f3}){return putResource(_0xc54777,_0x3ce4f3['resourceName']);}__name(putResourceByIdRoute,'putResourceByIdRoute');async function deleteResourceByIdRoute(_0x8b7e31,{params:_0x466314}){const _0x122037=_0x466314['resourceName'],_0x5969be=_0x466314['id'];if(_0x122037&&_0x5969be)return controllerDelete(_0x122037,_0x5969be);else throw apiBadRequestError(responseMessages['routingError']);}__name(deleteResourceByIdRoute,'deleteResourceByIdRoute');async function upsertResourceRoute(_0x11a793,{params:_0x58d2e9}){const _0x170921=_0x58d2e9['resourceName'];if(_0x170921)return crudUpsert(_0x11a793,_0x170921);else throw apiBadRequestError(responseMessages['routingError']);}__name(upsertResourceRoute,'upsertResourceRoute');function putResource(_0x4b607c,_0x1a1cda){if(_0x1a1cda)return crudPut(_0x4b607c,_0x1a1cda);else throw apiBadRequestError(responseMessages['routingError']);}__name(putResource,'putResource');

export { deleteResourceByIdRoute, deleteResourceRoute, getResourceByIdRoute, getResourceRoute, postResourceRoute, putResourceByIdRoute, putResourceRoute, upsertResourceRoute };
