MCPcopy Create free account
hub / github.com/axe-api/axe-api / parseSections

Method parseSections

packages/axe-api/src/Services/QueryService.ts:229–270  ·  view source on GitHub ↗
(sections: URLSearchParams)

Source from the content-addressed store, hash-verified

227 }
228
229 private parseSections(sections: URLSearchParams): IQuery {
230 let q = sections.get("q");
231
232 if (q) {
233 const queryContent = q;
234
235 // Users can send an unacceptable query string. We shouldn't allow them to
236 // send unacceptable structure because of security reasons.
237 try {
238 q = JSON.parse(queryContent);
239 } catch (err) {
240 throw new ApiError(`Unacceptable query string: ${queryContent}`);
241 }
242 }
243
244 const withQueryResolver = new WithQueryResolver(this.model, this.models);
245
246 const query: IQuery = {
247 page: this.parsePage(sections.get("page")),
248 per_page: this.parsePerPage(sections.get("per_page")),
249 fields: this.parseFields(sections.get("fields")),
250 sort: this.parseSortingOptions(sections.get("sort")),
251 q: this.parseCondition(q),
252 with: withQueryResolver.resolve(sections.get("with") || ""),
253 text: sections.get("text") || null,
254 trashed: sections.get("trashed")
255 ? isBoolean(sections.get("trashed"))
256 : false,
257 };
258
259 const configPerPage =
260 this.config?.query.defaults?.perPage ||
261 DEFAULT_VERSION_CONFIG.query?.defaults?.perPage ||
262 10;
263 if (query.per_page !== configPerPage) {
264 valideteQueryFeature(this.model, QueryFeature.Limits);
265 }
266
267 this.addRelationColumns(query.with);
268
269 return query;
270 }
271
272 private parsePage(content: any) {
273 const value = parseInt(content);

Callers 1

getMethod · 0.95

Calls 10

parsePageMethod · 0.95
parsePerPageMethod · 0.95
parseFieldsMethod · 0.95
parseSortingOptionsMethod · 0.95
parseConditionMethod · 0.95
resolveMethod · 0.95
addRelationColumnsMethod · 0.95
isBooleanFunction · 0.90
valideteQueryFeatureFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected