From 98e8ea8799e69d98fa31d75ace987cc3c4c18a1b Mon Sep 17 00:00:00 2001 From: Hermann <blumh@ethz.ch> Date: Wed, 16 May 2018 10:40:46 +0200 Subject: [PATCH] add more documentation to auth --- src/auth.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/auth.js b/src/auth.js index 048051b..58fc35f 100644 --- a/src/auth.js +++ b/src/auth.js @@ -86,6 +86,14 @@ export function getSession() { } export class ResourceHandler { + /* + * The ResourceHandler manages access to the AMIVAPI for a given resource. + * It automatically handles: + * - authorization + * - etags + * - search queries + * - filtering out non-patchable keys + */ constructor(resource, searchKeys = false) { this.resource = resource; this.searchKeys = searchKeys || config[resource].searchKeys; @@ -95,7 +103,12 @@ export class ResourceHandler { checkAuthenticated(); } - // definitions of query parameters in addition to API go here + /* + * query is a dictionary of different queries + * Additional to anything specified from eve + * (http://python-eve.org/features.html#filtering) + * we support the key `search`, which is translated into a `where` filter + */ buildQuerystring(query) { const queryKeys = Object.keys(query); @@ -105,6 +118,8 @@ export class ResourceHandler { if ('search' in query && query.search.length > 0) { // translate search into where, we just look if any field contains search + // The search-string may match any of the keys in the object specified in the + // constructor const searchQuery = { $or: this.searchKeys.map((key) => { const fieldQuery = {}; -- GitLab