mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
fix: resource advanced view filter.
This commit is contained in:
@@ -1,17 +1,28 @@
|
||||
import { Response, Request } from 'express';
|
||||
import { Response, Request, NextFunction } from 'express';
|
||||
import { matchedData, validationResult } from "express-validator";
|
||||
import { camelCase, omit } from "lodash";
|
||||
import { mapKeysDeep } from 'utils'
|
||||
|
||||
export default class BaseController {
|
||||
|
||||
private dataToCamelCase(data) {
|
||||
return mapKeysDeep(data, (v, k) => camelCase(k));
|
||||
}
|
||||
|
||||
matchedBodyData(req: Request, options: any = {}) {
|
||||
const data = matchedData(req, {
|
||||
locations: ['body'],
|
||||
includeOptionals: true,
|
||||
...omit(options, ['locations']), // override any propery except locations.
|
||||
});
|
||||
return mapKeysDeep(data, (v, k) => camelCase(k));
|
||||
return this.dataToCamelCase(data);
|
||||
}
|
||||
|
||||
matchedQueryData(req: Request) {
|
||||
const data = matchedData(req, {
|
||||
locations: ['query'],
|
||||
});
|
||||
return this.dataToCamelCase(data);
|
||||
}
|
||||
|
||||
validationResult(req: Request, res: Response, next: NextFunction) {
|
||||
|
||||
Reference in New Issue
Block a user