| 99 | } |
| 100 | |
| 101 | function handleArguments(args: any) { |
| 102 | try { |
| 103 | if (typeof args.args === 'string') { |
| 104 | args.args = JSON.parse(args.args); |
| 105 | } |
| 106 | if (typeof args.projection === 'string') { |
| 107 | args.projection = '{['.includes(args.projection[0]) |
| 108 | ? JSON.parse(args.projection) |
| 109 | : args.projection.split(',').map((i) => i.trim()).filter((i) => i); |
| 110 | } |
| 111 | } catch (e) { |
| 112 | throw new BadRequestError('Invalid arguments'); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | export class ApiService extends Service { |
| 117 | constructor(ctx: Context) { |