{ "$schema": "http://json-schema.org/draft-07/schema#", "title": "JSON Schema tibi-server hooks configuration", "description": "tibi-server hooks configuration", "type": "object", "additionalProperties": false, "patternProperties": { "^x\\-": { "description": "template property" } }, "properties": { "get": { "type": "object", "description": "hooks for http GET", "additionalProperties": false, "properties": { "read": { "description": "hook before reading from database", "$ref": "#/definitions/hookDef" }, "return": { "description": "hook before returning entries read from database", "$ref": "#/definitions/hookDef" }, "file": { "description": "hook for file download requests (GET /collection/:id/:field/*path)", "$ref": "#/definitions/hookDef" } } }, "post": { "type": "object", "description": "hooks for http POST", "additionalProperties": false, "properties": { "bind": { "description": "hook before binding data from post request", "$ref": "#/definitions/hookDef" }, "validate": { "description": "hook before validation data", "$ref": "#/definitions/hookDef" }, "create": { "description": "hook before creating entry in database", "$ref": "#/definitions/hookDef" }, "return": { "description": "hook before returning result (after database write)", "$ref": "#/definitions/hookDef" }, "bulkCreate": { "description": "hook for bulk create (POST with JSON array) — optimised single-DB-call path", "$ref": "#/definitions/hookDef" }, "bulkReturn": { "description": "hook before returning bulk create result", "$ref": "#/definitions/hookDef" } } }, "put": { "type": "object", "description": "hooks for http PUT", "additionalProperties": false, "properties": { "bind": { "description": "hook before binding data from put request", "$ref": "#/definitions/hookDef" }, "validate": { "description": "hook before validation data", "$ref": "#/definitions/hookDef" }, "update": { "description": "hook before updating entry in database", "$ref": "#/definitions/hookDef" }, "return": { "description": "hook before returning result (after database write)", "$ref": "#/definitions/hookDef" }, "bulkUpdate": { "description": "hook for bulk update (PUT without ID) — optimised single-DB-call path", "$ref": "#/definitions/hookDef" }, "bulkReturn": { "description": "hook before returning bulk update result", "$ref": "#/definitions/hookDef" } } }, "delete": { "type": "object", "description": "hooks for http DELETE", "additionalProperties": false, "properties": { "delete": { "description": "hook before deleting entry from database", "$ref": "#/definitions/hookDef" }, "return": { "description": "hook before returning result (after database write)", "$ref": "#/definitions/hookDef" }, "bulkDelete": { "description": "hook for bulk delete (DELETE without ID) — optimised single-DB-call path", "$ref": "#/definitions/hookDef" }, "bulkReturn": { "description": "hook before returning bulk delete result", "$ref": "#/definitions/hookDef" } } }, "audit": { "type": "object", "description": "hooks for audit log entries", "additionalProperties": false, "properties": { "return": { "description": "hook before returning audit log entries for this collection, can be used to remove sensitive fields from snapshots", "$ref": "#/definitions/hookDef" } } } }, "definitions": { "hookDef": { "type": "object", "properties": { "type": { "const": "javascript" }, "file": { "type": "string", "description": "location of javascript hook file relative to config.yml base" }, "timeout": { "type": "integer", "description": "execution timeout in seconds" } }, "required": ["type", "file"] } } }