Add sorting functionality to various inventory and management routes
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
All checks were successful
farmcontrol/farmcontrol-api/pipeline/head This commit looks good
This update introduces a new utility function, `getSort`, to validate and apply sorting based on allowed sorters across multiple routes in the inventory and management modules. The function is integrated into route handlers for invoices, payments, tax records, filament stocks, order items, part stocks, product stocks, purchase orders, shipments, and various management entities. This enhancement improves the flexibility and consistency of sorting operations throughout the application.
This commit is contained in:
parent
3d4150c6cc
commit
aa4b173a7e
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -15,8 +15,9 @@ const listAllowedFilters = [
|
||||
'orderType',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['createdAt', 'state', 'updatedAt', 'invoiceDate', 'dueDate'];
|
||||
const propertiesAllowedFilters = [
|
||||
'vendor',
|
||||
'client',
|
||||
@ -50,7 +51,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listInvoicesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listInvoicesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -90,7 +91,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getInvoiceNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getInvoiceNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -14,8 +14,9 @@ const listAllowedFilters = [
|
||||
'invoice._id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['createdAt', 'state', 'updatedAt', 'paymentDate'];
|
||||
const propertiesAllowedFilters = [
|
||||
'vendor',
|
||||
'client',
|
||||
@ -50,7 +51,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listPaymentsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listPaymentsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -90,7 +91,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getPaymentNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getPaymentNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,18 +1,21 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'taxRate',
|
||||
'taxRate._id',
|
||||
'transactionType',
|
||||
'transaction',
|
||||
'transaction._id',
|
||||
'transactionDate',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['transactionDate', 'amount', 'taxAmount', 'createdAt', '_id', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['taxRate', 'transactionType', 'transaction'];
|
||||
import {
|
||||
listTaxRecordsRouteHandler,
|
||||
@ -33,7 +36,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listTaxRecordsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listTaxRecordsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -73,7 +76,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getTaxRecordNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getTaxRecordNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -8,16 +8,17 @@ const listAllowedFilters = [
|
||||
'filament',
|
||||
'filament._id',
|
||||
'filamentSku',
|
||||
'filamentSku._id',
|
||||
'state',
|
||||
'startingWeight',
|
||||
'currentWeight',
|
||||
'filamentSku._id',
|
||||
'stockLocation',
|
||||
'stockLocation._id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['createdAt', 'updatedAt', 'filament', 'filamentSku', 'state'];
|
||||
const propertiesAllowedFilters = [
|
||||
'filament',
|
||||
'filament._id',
|
||||
@ -45,7 +46,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listFilamentStocksRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listFilamentStocksRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -85,7 +86,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getFilamentStockNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getFilamentStockNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -19,6 +19,7 @@ const listAllowedFilters = [
|
||||
'updatedAt',
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['createdAt', 'updatedAt', 'itemAmount', 'quantity', 'state', 'name'];
|
||||
const propertiesAllowedFilters = [
|
||||
'name',
|
||||
'itemType',
|
||||
@ -49,7 +50,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listOrderItemsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listOrderItemsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -88,7 +89,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getOrderItemNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getOrderItemNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,21 +1,22 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'partSku',
|
||||
'partSku._id',
|
||||
'state',
|
||||
'startingQuantity',
|
||||
'currentQuantity',
|
||||
'partSku._id',
|
||||
'stockLocation',
|
||||
'stockLocation._id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['partSku', 'startingQuantity', 'currentQuantity', 'state', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['part', 'state.type'];
|
||||
import {
|
||||
listPartStocksRouteHandler,
|
||||
@ -37,7 +38,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listPartStocksRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listPartStocksRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -77,7 +78,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getPartStockNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getPartStockNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,20 +1,21 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'productSku',
|
||||
'productSku._id',
|
||||
'state',
|
||||
'currentQuantity',
|
||||
'productSku._id',
|
||||
'stockLocation',
|
||||
'stockLocation._id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['productSku', 'currentQuantity', 'state', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['productSku', 'state.type'];
|
||||
import {
|
||||
listProductStocksRouteHandler,
|
||||
@ -36,7 +37,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listProductStocksRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listProductStocksRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -74,7 +75,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getProductStockNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getProductStockNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'vendor',
|
||||
'vendor._id',
|
||||
'state',
|
||||
'value',
|
||||
'vendor._id',
|
||||
'totalAmount',
|
||||
'totalAmountWithTax',
|
||||
'totalTaxAmount',
|
||||
@ -19,6 +19,17 @@ const listAllowedFilters = [
|
||||
'updatedAt',
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'createdAt',
|
||||
'state',
|
||||
'updatedAt',
|
||||
'totalAmount',
|
||||
'totalAmountWithTax',
|
||||
'totalTaxAmount',
|
||||
'shippingAmount',
|
||||
'shippingAmountWithTax',
|
||||
'grandTotalAmount',
|
||||
];
|
||||
const propertiesAllowedFilters = [
|
||||
'vendor',
|
||||
'state.type',
|
||||
@ -53,7 +64,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listPurchaseOrdersRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listPurchaseOrdersRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -92,7 +103,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getPurchaseOrderNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getPurchaseOrderNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,20 +1,23 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'orderType',
|
||||
'order',
|
||||
'order._id',
|
||||
'state',
|
||||
'courierService',
|
||||
'order._id',
|
||||
'courierService._id',
|
||||
'taxRate',
|
||||
'taxRate._id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['createdAt', 'state', 'updatedAt', 'shippedAt', 'expectedAt', 'deliveredAt'];
|
||||
const propertiesAllowedFilters = [
|
||||
'orderType',
|
||||
'order',
|
||||
@ -45,7 +48,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listShipmentsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listShipmentsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -84,7 +87,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getShipmentNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getShipmentNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { parseFilter, getFilter } from '../../utils.js';
|
||||
import { parseFilter, getFilter, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
import {
|
||||
@ -22,8 +22,9 @@ const listAllowedFilters = [
|
||||
'state',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['createdAt', 'updatedAt', 'state'];
|
||||
|
||||
// List stock audits
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
@ -66,7 +67,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getStockAuditNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getStockAuditNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
// Get specific stock audit
|
||||
|
||||
@ -1,16 +1,11 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'owner._id',
|
||||
'parent._id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
const listAllowedFilters = ['owner._id', 'parent._id', 'createdAt', 'updatedAt', '_reference'];
|
||||
const listAllowedSorters = ['createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['owner._id', 'parent._id'];
|
||||
import {
|
||||
listStockEventsRouteHandler,
|
||||
@ -32,7 +27,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listStockEventsRouteHandler(req, res, page, limit, filter, sort, order);
|
||||
listStockEventsRouteHandler(req, res, page, limit, filter, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -72,7 +67,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getStockEventNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getStockEventNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = ['name','createdAt','updatedAt','_reference'];
|
||||
const listAllowedFilters = ['name', 'createdAt', 'updatedAt', '_reference'];
|
||||
const listAllowedSorters = ['name', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['name'];
|
||||
import {
|
||||
listStockLocationsRouteHandler,
|
||||
@ -25,7 +26,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listStockLocationsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listStockLocationsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -63,7 +64,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getStockLocationNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getStockLocationNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -11,8 +11,9 @@ const listAllowedFilters = [
|
||||
'name',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'createdAt', 'postedAt', 'state', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['state.type'];
|
||||
import {
|
||||
listStockTransfersRouteHandler,
|
||||
@ -34,7 +35,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listStockTransfersRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listStockTransfersRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -72,7 +73,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getStockTransferNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getStockTransferNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -8,12 +8,13 @@ const listAllowedFilters = [
|
||||
'_id',
|
||||
'name',
|
||||
'user',
|
||||
'active',
|
||||
'user._id',
|
||||
'active',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'user', 'active', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['name', 'user', 'active'];
|
||||
import {
|
||||
listAppPasswordsRouteHandler,
|
||||
@ -34,7 +35,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listAppPasswordsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listAppPasswordsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -73,7 +74,7 @@ router.post('/:id/regenerateSecret', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getAppPasswordNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getAppPasswordNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -7,37 +7,19 @@ import {
|
||||
getAuditLogHistoryRouteHandler,
|
||||
searchAuditLogsRouteHandler,
|
||||
} from '../../services/management/auditlogs.js';
|
||||
import { parseFilter } from '../../utils.js';
|
||||
import { getFilter, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
// List note types
|
||||
const listAllowedFilters = ['parent._id', 'owner._id', 'operation', 'createdAt', 'updatedAt', '_reference'];
|
||||
const listAllowedSorters = ['createdAt', 'updatedAt'];
|
||||
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, sort, order } = req.query;
|
||||
|
||||
const allowedFilters = [
|
||||
'parent._id',
|
||||
'owner._id',
|
||||
'operation',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
|
||||
var filter = {};
|
||||
|
||||
for (const [key, value] of Object.entries(req.query)) {
|
||||
for (var i = 0; i < allowedFilters.length; i++) {
|
||||
if (key == allowedFilters[i]) {
|
||||
const parsedFilter = await parseFilter(key, value);
|
||||
filter = { ...filter, ...parsedFilter };
|
||||
}
|
||||
}
|
||||
}
|
||||
listAuditLogsRouteHandler(req, res, page, limit, filter, sort, order);
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listAuditLogsRouteHandler(req, res, page, limit, filter, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
// get audit log stats
|
||||
router.get('/search', isAuthenticated, async (req, res) => {
|
||||
const { search } = req.query;
|
||||
searchAuditLogsRouteHandler(req, res, search);
|
||||
@ -47,16 +29,10 @@ router.get('/stats', isAuthenticated, async (req, res) => {
|
||||
getAuditLogStatsRouteHandler(req, res);
|
||||
});
|
||||
|
||||
// get audit log history
|
||||
router.get('/history', isAuthenticated, async (req, res) => {
|
||||
getAuditLogHistoryRouteHandler(req, res);
|
||||
});
|
||||
|
||||
/**
|
||||
* @route GET /api/auditlogs/:id
|
||||
* @desc Get a single audit log by ID
|
||||
* @access Private
|
||||
*/
|
||||
router.get('/:id', async (req, res) => {
|
||||
await getAuditLogRouteHandler(req, res);
|
||||
});
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -13,8 +13,9 @@ const listAllowedFilters = [
|
||||
'country',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'country', 'email', 'createdAt', '_id', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['name', 'website', 'email', 'phone', 'contact', 'country'];
|
||||
import {
|
||||
listCouriersRouteHandler,
|
||||
@ -35,7 +36,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listCouriersRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listCouriersRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -75,7 +76,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getCourierNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getCourierNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -16,8 +16,20 @@ const listAllowedFilters = [
|
||||
'costWithTax',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'courier',
|
||||
'active',
|
||||
'tracked',
|
||||
'cost',
|
||||
'costWithTax',
|
||||
'estimatedDeliveryTime',
|
||||
'createdAt',
|
||||
'_id',
|
||||
'updatedAt',
|
||||
];
|
||||
const propertiesAllowedFilters = [
|
||||
'_id',
|
||||
'courier',
|
||||
@ -48,7 +60,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listCourierServicesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listCourierServicesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -88,7 +100,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getCourierServiceNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getCourierServiceNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -11,8 +11,9 @@ const listAllowedFilters = [
|
||||
'state',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'state', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = [];
|
||||
import {
|
||||
listDocumentJobsRouteHandler,
|
||||
@ -33,7 +34,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listDocumentJobsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listDocumentJobsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -73,7 +74,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getDocumentJobNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getDocumentJobNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -12,8 +12,9 @@ const listAllowedFilters = [
|
||||
'state',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'documentSize', 'connectedAt', 'updatedAt', 'state', 'createdAt'];
|
||||
const propertiesAllowedFilters = ['tags'];
|
||||
import {
|
||||
listDocumentPrintersRouteHandler,
|
||||
@ -34,7 +35,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listDocumentPrintersRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listDocumentPrintersRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -74,7 +75,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getDocumentPrinterNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getDocumentPrinterNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,17 +1,11 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'name',
|
||||
'width',
|
||||
'height',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
const listAllowedFilters = ['name', 'width', 'height', 'createdAt', 'updatedAt', '_reference'];
|
||||
const listAllowedSorters = ['name', 'width', 'height', 'infiniteHeight', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = [];
|
||||
import {
|
||||
listDocumentSizesRouteHandler,
|
||||
@ -32,7 +26,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listDocumentSizesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listDocumentSizesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -72,7 +66,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getDocumentSizeNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getDocumentSizeNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -9,11 +9,25 @@ const listAllowedFilters = [
|
||||
'tags',
|
||||
'active',
|
||||
'global',
|
||||
'parent',
|
||||
'parent._id',
|
||||
'documentSize',
|
||||
'documentSize._id',
|
||||
'objectType',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'parent',
|
||||
'documentSize',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'active',
|
||||
'global',
|
||||
'objectType',
|
||||
];
|
||||
const propertiesAllowedFilters = ['documentSize', 'tags'];
|
||||
import {
|
||||
listDocumentTemplatesRouteHandler,
|
||||
@ -33,7 +47,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listDocumentTemplatesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listDocumentTemplatesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -73,7 +87,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getDocumentTemplateNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getDocumentTemplateNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { convertPropertiesString, getFilter, parseFilter } from '../../utils.js';
|
||||
import { convertPropertiesString, getFilter, parseFilter, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -13,8 +13,17 @@ const listAllowedFilters = [
|
||||
'cost',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'createdAt',
|
||||
'vendor',
|
||||
'material',
|
||||
'cost',
|
||||
'costWithTax',
|
||||
'updatedAt',
|
||||
];
|
||||
const propertiesAllowedFilters = ['diameter', 'material'];
|
||||
import {
|
||||
listFilamentsRouteHandler,
|
||||
@ -47,7 +56,7 @@ router.get('/', isAuthenticated, async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
listFilamentsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listFilamentsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -87,7 +96,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getFilamentNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getFilamentNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -17,6 +17,16 @@ const listAllowedFilters = [
|
||||
'updatedAt',
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'barcode',
|
||||
'filament',
|
||||
'name',
|
||||
'color',
|
||||
'cost',
|
||||
'costWithTax',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
];
|
||||
const propertiesAllowedFilters = ['filament', 'filament._id', 'diameter'];
|
||||
import {
|
||||
listFilamentSkusRouteHandler,
|
||||
@ -35,7 +45,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listFilamentSkusRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listFilamentSkusRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -72,7 +82,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getFilamentSkuNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getFilamentSkuNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -12,8 +12,9 @@ const listAllowedFilters = [
|
||||
'extension',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'type', 'size', 'createdAt', 'temp', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['type', 'extension'];
|
||||
import {
|
||||
listFilesRouteHandler,
|
||||
@ -37,7 +38,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listFilesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listFilesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -81,7 +82,7 @@ router.delete('/:id/flush', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getFileNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getFileNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,18 +1,20 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'_id',
|
||||
'name',
|
||||
'tags',
|
||||
'_id',
|
||||
'state',
|
||||
'tags',
|
||||
'connectedAt',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'state', 'connectedAt', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['tags'];
|
||||
import {
|
||||
listHostsRouteHandler,
|
||||
@ -32,7 +34,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listHostsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listHostsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -72,7 +74,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getHostNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getHostNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,17 +1,11 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { convertPropertiesString, getFilter, parseFilter } from '../../utils.js';
|
||||
import { convertPropertiesString, getFilter, parseFilter, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'_id',
|
||||
'name',
|
||||
'tags',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
const listAllowedFilters = ['_id', 'name', 'tags', 'createdAt', 'updatedAt', '_reference'];
|
||||
const listAllowedSorters = ['name', 'createdAt', 'updatedAt', '_id'];
|
||||
const propertiesAllowedFilters = ['name', 'tags'];
|
||||
import {
|
||||
listMaterialsRouteHandler,
|
||||
@ -40,7 +34,7 @@ router.get('/', isAuthenticated, async (req, res) => {
|
||||
}
|
||||
}
|
||||
|
||||
listMaterialsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listMaterialsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -80,7 +74,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getMaterialNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getMaterialNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'_id',
|
||||
'name',
|
||||
'active',
|
||||
'_id',
|
||||
'color',
|
||||
'active',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'color', 'active', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['active', 'color'];
|
||||
import {
|
||||
listNoteTypesRouteHandler,
|
||||
@ -33,7 +34,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listNoteTypesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listNoteTypesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -73,7 +74,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getNoteTypeNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getNoteTypeNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,17 +1,21 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'product._id',
|
||||
'_id',
|
||||
const listAllowedFilters = ['product._id', '_id', 'name', 'createdAt', 'updatedAt', '_reference'];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'priceMode',
|
||||
'cost',
|
||||
'costWithTax',
|
||||
'price',
|
||||
'priceWithTax',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_id',
|
||||
];
|
||||
const propertiesAllowedFilters = ['product._id'];
|
||||
import {
|
||||
listPartsRouteHandler,
|
||||
@ -32,7 +36,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listPartsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listPartsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -72,7 +76,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getPartNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getPartNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -14,8 +14,19 @@ const listAllowedFilters = [
|
||||
'price',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'barcode',
|
||||
'part',
|
||||
'name',
|
||||
'cost',
|
||||
'costWithTax',
|
||||
'price',
|
||||
'priceWithTax',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
];
|
||||
const propertiesAllowedFilters = ['part', 'part._id'];
|
||||
import {
|
||||
listPartSkusRouteHandler,
|
||||
@ -35,7 +46,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listPartSkusRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listPartSkusRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -73,7 +84,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getPartSkuNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getPartSkuNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { convertPropertiesString, getFilter } from '../../utils.js';
|
||||
import { convertPropertiesString, getFilter, getSort } from '../../utils.js';
|
||||
import {
|
||||
deleteProductCategoryRouteHandler,
|
||||
editProductCategoryRouteHandler,
|
||||
@ -18,13 +18,14 @@ import {
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = ['_id','name','createdAt','updatedAt','_reference'];
|
||||
const listAllowedFilters = ['_id', 'name', 'createdAt', 'updatedAt', '_reference'];
|
||||
const listAllowedSorters = ['name', 'createdAt', 'updatedAt', '_id'];
|
||||
const propertiesAllowedFilters = ['name'];
|
||||
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listProductCategoriesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listProductCategoriesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -62,7 +63,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getProductCategoryNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getProductCategoryNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -12,8 +12,20 @@ const listAllowedFilters = [
|
||||
'productCategory._id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'productCategory',
|
||||
'createdAt',
|
||||
'type',
|
||||
'vendor',
|
||||
'cost',
|
||||
'costWithTax',
|
||||
'price',
|
||||
'priceWithTax',
|
||||
'updatedAt',
|
||||
];
|
||||
const propertiesAllowedFilters = [];
|
||||
import {
|
||||
listProductsRouteHandler,
|
||||
@ -34,7 +46,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listProductsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listProductsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -74,7 +86,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getProductNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getProductNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -14,8 +14,19 @@ const listAllowedFilters = [
|
||||
'price',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'barcode',
|
||||
'product',
|
||||
'name',
|
||||
'cost',
|
||||
'costWithTax',
|
||||
'price',
|
||||
'priceWithTax',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
];
|
||||
const propertiesAllowedFilters = ['product', 'product._id'];
|
||||
import {
|
||||
listProductSkusRouteHandler,
|
||||
@ -35,7 +46,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listProductSkusRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listProductSkusRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -73,7 +84,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getProductSkuNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getProductSkuNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -12,8 +12,18 @@ const listAllowedFilters = [
|
||||
'country',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'rate',
|
||||
'rateType',
|
||||
'active',
|
||||
'country',
|
||||
'createdAt',
|
||||
'_id',
|
||||
'updatedAt',
|
||||
];
|
||||
const propertiesAllowedFilters = ['rateType', 'country', 'active'];
|
||||
import {
|
||||
listTaxRatesRouteHandler,
|
||||
@ -34,7 +44,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listTaxRatesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listTaxRatesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -74,7 +84,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getTaxRateNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getTaxRateNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { convertPropertiesString, getFilter } from '../../utils.js';
|
||||
import { convertPropertiesString, getFilter, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -12,8 +12,9 @@ const listAllowedFilters = [
|
||||
'email',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'email', 'role', 'createdAt', '_id', 'updatedAt'];
|
||||
const propertiesAllowedFilters = [];
|
||||
import {
|
||||
listUsersRouteHandler,
|
||||
@ -33,7 +34,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listUsersRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listUsersRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -69,7 +70,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getUserNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getUserNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
const listAllowedFilters = ['country', 'active', 'createdAt', 'updatedAt', 'name', '_reference'];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'country',
|
||||
'email',
|
||||
'active',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'name',
|
||||
'_reference'
|
||||
];
|
||||
'_id',
|
||||
];
|
||||
const propertiesAllowedFilters = ['country', 'active', 'createdAt', 'updatedAt'];
|
||||
import {
|
||||
listVendorsRouteHandler,
|
||||
@ -32,7 +34,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listVendorsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listVendorsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -72,7 +74,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getVendorNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getVendorNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -13,23 +13,31 @@ import {
|
||||
|
||||
getNoteNeighborsRouteHandler
|
||||
} from '../../services/misc/notes.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'_id',
|
||||
'user',
|
||||
'user._id',
|
||||
'parentType',
|
||||
'parent',
|
||||
'parent._id',
|
||||
'noteType',
|
||||
'noteType._id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['createdAt', 'updatedAt', 'parentType', 'noteType'];
|
||||
const propertiesAllowedFilters = ['parent'];
|
||||
|
||||
// list of notes
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listNotesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listNotesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -65,7 +73,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getNoteNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getNoteNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { convertPropertiesString, getFilter } from '../../utils.js';
|
||||
import { convertPropertiesString, getFilter, getSort } from '../../utils.js';
|
||||
import {
|
||||
deleteFilamentProfileRouteHandler,
|
||||
editFilamentProfileRouteHandler,
|
||||
@ -16,13 +16,14 @@ import {
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = ['_id','name','createdAt','updatedAt','_reference'];
|
||||
const listAllowedFilters = ['_id', 'name', 'createdAt', 'updatedAt', '_reference'];
|
||||
const listAllowedSorters = ['name', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['name'];
|
||||
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listFilamentProfilesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listFilamentProfilesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -51,7 +52,7 @@ router.post('/', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getFilamentProfileNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getFilamentProfileNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -12,8 +12,9 @@ const listAllowedFilters = [
|
||||
'filamentSku._id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'filament', 'filamentSku', 'cost', 'createdAt', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['filament', 'filament._id', 'filamentSku', 'filamentSku._id'];
|
||||
import {
|
||||
listGCodeFilesRouteHandler,
|
||||
@ -28,13 +29,13 @@ import {
|
||||
|
||||
getGCodeFileNeighborsRouteHandler
|
||||
} from '../../services/production/gcodefiles.js';
|
||||
import { convertPropertiesString, getFilter } from '../../utils.js';
|
||||
import { convertPropertiesString, getFilter, getSort } from '../../utils.js';
|
||||
|
||||
// list of gcodeFiles
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listGCodeFilesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listGCodeFilesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -70,7 +71,7 @@ router.get('/stats', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getGCodeFileNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getGCodeFileNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -5,13 +5,25 @@ const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'state',
|
||||
'gcodeFile',
|
||||
'gcodeFile._id',
|
||||
'quantity',
|
||||
'_id',
|
||||
'_reference',
|
||||
'createdAt',
|
||||
'updatedAt'
|
||||
];
|
||||
'updatedAt',
|
||||
'startedAt',
|
||||
'finishedAt',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'createdAt',
|
||||
'state',
|
||||
'quantity',
|
||||
'gcodeFile',
|
||||
'updatedAt',
|
||||
'startedAt',
|
||||
'finishedAt',
|
||||
];
|
||||
const propertiesAllowedFilters = ['state'];
|
||||
import {
|
||||
listJobsRouteHandler,
|
||||
@ -26,13 +38,13 @@ import {
|
||||
getJobPropertyValuesRouteHandler,
|
||||
getJobNeighborsRouteHandler,
|
||||
} from '../../services/production/jobs.js';
|
||||
import { convertPropertiesString, getFilter } from '../../utils.js';
|
||||
import { convertPropertiesString, getFilter, getSort } from '../../utils.js';
|
||||
|
||||
// list of jobs
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listJobsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listJobsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -71,7 +83,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getJobNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getJobNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { convertPropertiesString, getFilter } from '../../utils.js';
|
||||
import { convertPropertiesString, getFilter, getSort } from '../../utils.js';
|
||||
import {
|
||||
deletePrinterProfileRouteHandler,
|
||||
editPrinterProfileRouteHandler,
|
||||
@ -16,13 +16,22 @@ import {
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = ['_id','name','createdAt','updatedAt','_reference'];
|
||||
const listAllowedFilters = ['_id', 'name', 'createdAt', 'updatedAt', '_reference'];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'printBedWidth',
|
||||
'printBedHeight',
|
||||
'printableHeight',
|
||||
'zOffset',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
];
|
||||
const propertiesAllowedFilters = ['name'];
|
||||
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listPrinterProfilesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listPrinterProfilesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -51,7 +60,7 @@ router.post('/', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getPrinterProfileNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getPrinterProfileNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -14,10 +14,11 @@ import {
|
||||
getPrinterPropertyValuesRouteHandler,
|
||||
getPrinterNeighborsRouteHandler,
|
||||
} from '../../services/production/printers.js';
|
||||
import { convertPropertiesString, getFilter } from '../../utils.js';
|
||||
import { convertPropertiesString, getFilter, getSort } from '../../utils.js';
|
||||
|
||||
const listAllowedFilters = [
|
||||
'tags',
|
||||
'host',
|
||||
'host._id',
|
||||
'active',
|
||||
'online',
|
||||
@ -26,14 +27,15 @@ const listAllowedFilters = [
|
||||
'_reference',
|
||||
'state',
|
||||
'createdAt',
|
||||
'updatedAt'
|
||||
];
|
||||
'updatedAt',
|
||||
];
|
||||
const listAllowedSorters = ['name', 'state', 'connectedAt', 'createdAt', 'updatedAt', 'host'];
|
||||
const propertiesAllowedFilters = ['tags'];
|
||||
// list of printers
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listPrintersRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listPrintersRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -68,7 +70,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getPrinterNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getPrinterNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
// get printer stats
|
||||
|
||||
@ -5,13 +5,26 @@ const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'_id',
|
||||
'job',
|
||||
'job._id',
|
||||
'printer',
|
||||
'printer._id',
|
||||
'_reference',
|
||||
'state',
|
||||
'createdAt',
|
||||
'updatedAt'
|
||||
];
|
||||
'updatedAt',
|
||||
'startedAt',
|
||||
'finishedAt',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'createdAt',
|
||||
'state',
|
||||
'updatedAt',
|
||||
'startedAt',
|
||||
'finishedAt',
|
||||
'job',
|
||||
'printer',
|
||||
];
|
||||
const propertiesAllowedFilters = ['job'];
|
||||
import {
|
||||
listSubJobsRouteHandler,
|
||||
@ -23,13 +36,13 @@ import {
|
||||
getSubJobPropertyValuesRouteHandler,
|
||||
getSubJobNeighborsRouteHandler,
|
||||
} from '../../services/production/subjobs.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
// list of sub jobs
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listSubJobsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listSubJobsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -64,7 +77,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getSubJobNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getSubJobNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,17 +1,20 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
const listAllowedFilters = ['country', 'active', 'createdAt', 'updatedAt', 'name', '_reference'];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'country',
|
||||
'email',
|
||||
'phone',
|
||||
'active',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'name',
|
||||
'_reference'
|
||||
];
|
||||
'_id',
|
||||
];
|
||||
const propertiesAllowedFilters = ['country', 'active', 'createdAt', 'updatedAt'];
|
||||
import {
|
||||
listClientsRouteHandler,
|
||||
@ -32,7 +35,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listClientsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listClientsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -72,7 +75,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getClientNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getClientNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,21 +1,35 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'product',
|
||||
'product._id',
|
||||
'vendor',
|
||||
'vendor._id',
|
||||
'stockLocation',
|
||||
'stockLocation._id',
|
||||
'marketplace',
|
||||
'marketplace._id',
|
||||
'courierServices',
|
||||
'state',
|
||||
'state.type',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'title',
|
||||
'vendor',
|
||||
'state',
|
||||
'price',
|
||||
'lastSyncedAt',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_id',
|
||||
];
|
||||
const propertiesAllowedFilters = [
|
||||
'product',
|
||||
'vendor',
|
||||
@ -47,7 +61,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listListingsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listListingsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -92,7 +106,7 @@ router.post('/:id/unpublish', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getListingNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getListingNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -8,13 +8,16 @@ const listAllowedFilters = [
|
||||
'listing',
|
||||
'listing._id',
|
||||
'product',
|
||||
'product._id',
|
||||
'productSku',
|
||||
'productSku._id',
|
||||
'state',
|
||||
'state.type',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['state', 'price', 'lastSyncedAt', 'createdAt', 'updatedAt', '_id'];
|
||||
const propertiesAllowedFilters = [
|
||||
'listing',
|
||||
'listing._id',
|
||||
@ -45,7 +48,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listListingVarientsRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listListingVarientsRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -91,7 +94,7 @@ router.post('/:id/unpublish', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getListingVarientNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getListingVarientNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@ -13,8 +13,18 @@ const listAllowedFilters = [
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'state',
|
||||
'_reference'
|
||||
];
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = [
|
||||
'name',
|
||||
'provider',
|
||||
'active',
|
||||
'connected',
|
||||
'state',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_id',
|
||||
];
|
||||
const propertiesAllowedFilters = ['name', 'provider', 'active', 'connected', 'state.type', 'createdAt', 'updatedAt'];
|
||||
import {
|
||||
listMarketplacesRouteHandler,
|
||||
@ -40,7 +50,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listMarketplacesRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listMarketplacesRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -103,7 +113,7 @@ router.post('/:id/hook', async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getMarketplaceNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getMarketplaceNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
@ -1,18 +1,19 @@
|
||||
import express from 'express';
|
||||
import { isAuthenticated } from '../../keycloak.js';
|
||||
import { getFilter, convertPropertiesString } from '../../utils.js';
|
||||
import { getFilter, convertPropertiesString, getSort } from '../../utils.js';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
const listAllowedFilters = [
|
||||
'client',
|
||||
'client._id',
|
||||
'state',
|
||||
'value',
|
||||
'client._id',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'_reference',
|
||||
];
|
||||
const listAllowedSorters = ['createdAt', 'state', 'updatedAt'];
|
||||
const propertiesAllowedFilters = ['client', 'state.type', 'value', 'client._id'];
|
||||
import {
|
||||
listSalesOrdersRouteHandler,
|
||||
@ -36,7 +37,7 @@ import {
|
||||
router.get('/', isAuthenticated, async (req, res) => {
|
||||
const { page, limit, property, search, sort, order } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
listSalesOrdersRouteHandler(req, res, page, limit, property, filter, search, sort, order);
|
||||
listSalesOrdersRouteHandler(req, res, page, limit, property, filter, search, getSort(sort, listAllowedSorters), order);
|
||||
});
|
||||
|
||||
router.get('/properties', isAuthenticated, async (req, res) => {
|
||||
@ -75,7 +76,7 @@ router.get('/history', isAuthenticated, async (req, res) => {
|
||||
router.get('/neighbors', isAuthenticated, async (req, res) => {
|
||||
const { property, search, sort, order, id } = req.query;
|
||||
const filter = await getFilter(req.query, listAllowedFilters);
|
||||
getSalesOrderNeighborsRouteHandler(req, res, property, filter, search, sort, order, id);
|
||||
getSalesOrderNeighborsRouteHandler(req, res, property, filter, search, getSort(sort, listAllowedSorters), order, id);
|
||||
});
|
||||
|
||||
router.get('/:id', isAuthenticated, async (req, res) => {
|
||||
|
||||
11
src/utils.js
11
src/utils.js
@ -1550,6 +1550,14 @@ function mergeFilterClauses(clauses) {
|
||||
return needsAnd ? { $and: valid } : Object.assign({}, ...valid);
|
||||
}
|
||||
|
||||
// Returns a validated sort field based on allowed sorters
|
||||
function getSort(sort, allowedSorters, defaultSort = 'createdAt') {
|
||||
if (sort && allowedSorters.includes(sort)) {
|
||||
return sort;
|
||||
}
|
||||
return defaultSort;
|
||||
}
|
||||
|
||||
// Returns a filter object based on allowed filters and req.query
|
||||
async function getFilter(query, allowedFilters, parse = true, model = null) {
|
||||
const clauses = [];
|
||||
@ -1729,7 +1737,8 @@ export {
|
||||
notfiyObjectUserNotifiers,
|
||||
createNotification,
|
||||
sendEmailNotification,
|
||||
getFilter, // <-- add here
|
||||
getFilter,
|
||||
getSort,
|
||||
convertPropertiesString,
|
||||
getFileMeta,
|
||||
modelHasRef,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user