All files / src/routers AdminEntityRouter.ts

100% Statements 13/13
100% Branches 0/0
100% Functions 9/9
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 282x 2x 2x   2x   1x   2x   2x   1x   1x       1x   1x       1x   1x  
import * as express from 'express'
import { sendResponse } from '@commun/core'
import { AdminController } from '../controllers/AdminController'
 
export const AdminEntityRouter = express.Router()
  .get('/', (req, res, next) =>
    sendResponse(req, res, next, new AdminController().listEntities(req, res)))
  .post('/', (req, res, next) =>
    sendResponse(req, res, next, new AdminController().createEntity(req, res)))
  .get('/:entityName', (req, res, next) =>
    sendResponse(req, res, next, new AdminController().getEntity(req, res)))
  .put('/:entityName', (req, res, next) =>
    sendResponse(req, res, next, new AdminController().updateEntity(req, res)))
  .delete('/:entityName', (req, res, next) =>
    sendResponse(req, res, next, new AdminController().deleteEntity(req, res)))
 
  // Schema
  .put('/:entityName/properties/:propertyKey', (req, res, next) =>
    sendResponse(req, res, next, new AdminController().updateEntityProperty(req, res)))
  .delete('/:entityName/properties/:propertyKey', (req, res, next) =>
    sendResponse(req, res, next, new AdminController().deleteEntityProperty(req, res)))
 
  // Join properties
  .put('/:entityName/joinProperties/:propertyKey', (req, res, next) =>
    sendResponse(req, res, next, new AdminController().updateEntityJoinProperties(req, res)))
  .delete('/:entityName/joinProperties/:propertyKey', (req, res, next) =>
    sendResponse(req, res, next, new AdminController().deleteEntityJoinProperty(req, res)))