Skip to content
Snippets Groups Projects
Commit 98e8ea87 authored by Hermann's avatar Hermann
Browse files

add more documentation to auth

parent 77f6147b
No related branches found
No related tags found
No related merge requests found
......@@ -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 = {};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment