Skip to content
Snippets Groups Projects

Keep track forked project to main project

Merged Tuan Hoang Dinh Anh requested to merge tuanh/backend-core:main into main
14 files
+ 269
37
Compare changes
  • Side-by-side
  • Inline
Files
14
+ 40
0
 
const httpStatus = require('http-status');
 
const { apiService } = require('../services');
 
const catchAsync = require('../utils/catchAsync');
 
 
const createApi = catchAsync(async (req, res) => {
 
const newApi = await apiService.createApi({
 
model: req.body.model,
 
cvi: JSON.parse(req.body.cvi),
 
created_by: req.user.id,
 
});
 
res.status(httpStatus.CREATED).send(newApi);
 
});
 
 
const getApi = catchAsync(async (req, res) => {
 
const api = await apiService.getApi(req.params.id);
 
res.send(api);
 
});
 
 
const getApiByModelId = catchAsync(async (req, res) => {
 
const api = await apiService.getApiByModelId(req.params.modelId);
 
res.send(api);
 
});
 
 
const updateApi = catchAsync(async (req, res) => {
 
const updatedApi = await apiService.updateApi(req.params.id, req.body, req.user.id);
 
res.send(updatedApi);
 
});
 
 
const deleteApi = catchAsync(async (req, res) => {
 
await apiService.deleteApi(req.params.id, req.user.id);
 
res.status(httpStatus.NO_CONTENT).send();
 
});
 
 
module.exports = {
 
createApi,
 
getApiByModelId,
 
getApi,
 
updateApi,
 
deleteApi,
 
};
Loading