| 24 | } |
| 25 | |
| 26 | function calculateQueryDepth(query: string): number { |
| 27 | let depth = 0; |
| 28 | let currentDepth = 0; |
| 29 | let inString = false; |
| 30 | |
| 31 | for (let i = 0; i < query.length; i++) { |
| 32 | const char = query[i]; |
| 33 | |
| 34 | if (char === '"' && query[i - 1] !== '\\') { |
| 35 | inString = !inString; |
| 36 | } |
| 37 | |
| 38 | if (!inString) { |
| 39 | if (char === '{') { |
| 40 | currentDepth++; |
| 41 | if (currentDepth > depth) { |
| 42 | depth = currentDepth; |
| 43 | } |
| 44 | } else if (char === '}') { |
| 45 | currentDepth--; |
| 46 | } |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | return depth; |
| 51 | } |
| 52 | |
| 53 | export async function registerRoutes(app: Express): Promise<Server> { |
| 54 | app.use( |