feat: refactor folder structure (#4498)
* feat: wip refactor folder structure * Fix * fix position --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
|
||||
import { Request } from 'express';
|
||||
|
||||
const ALLOWED_DEPTH_VALUES = [1, 2];
|
||||
|
||||
export const computeDepth = (request: Request): number | undefined => {
|
||||
if (!request.query.depth) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const depth = +request.query.depth;
|
||||
|
||||
if (isNaN(depth) || !ALLOWED_DEPTH_VALUES.includes(depth)) {
|
||||
throw new BadRequestException(
|
||||
`'depth=${
|
||||
request.query.depth
|
||||
}' parameter invalid. Allowed values are ${ALLOWED_DEPTH_VALUES.join(
|
||||
', ',
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
|
||||
return depth;
|
||||
};
|
||||
Reference in New Issue
Block a user