Skip to content

Commit

Permalink
Add admin courier controller
Browse files Browse the repository at this point in the history
- getAllCouriers
  • Loading branch information
polekstulod committed Aug 7, 2022
1 parent 8f32fae commit 8b722e9
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/controllers/admin/couriers.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const db = require('../../models');
const { dataResponse, errResponse, emptyDataResponse, checkAuthorization } = require('../../helpers/controller.helper');
const dataTable = require('sequelize-datatables');

exports.getAllCouriers = async (req, res) => {
if (!checkAuthorization(req, res, 'Admin')) {
return;
}

req.body = {
draw: 1,
columns: [
{
data: 'courier_id',
name: '',
searchable: true,
orderable: true,
search: {
value: '',
regex: false,
},
},
],
order: [
{
column: 0,
dir: 'asc',
},
],
start: 0,
length: 100,
search: {
value: '',
regex: false,
},
};

try {
const data = await dataTable(db.Courier, req.body, { include: 'created' });
res.send(data);
} catch (err) {
errResponse(res, err);
}
};

0 comments on commit 8b722e9

Please sign in to comment.