[mod] api:register:abstraction
This commit is contained in:
parent
9910299675
commit
b4db263685
9 changed files with 58 additions and 16 deletions
|
@ -7,10 +7,10 @@ namespace _espe.api
|
|||
rest_subject : lib_plankton.rest.type_rest
|
||||
) : void
|
||||
{
|
||||
lib_plankton.rest.register<_espe.service.member.type_value, null>(
|
||||
register<_espe.service.member.type_value, null>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.delete,
|
||||
_espe.conf.get().server.path_base + "/member/:id",
|
||||
"/member/:id",
|
||||
{
|
||||
"description": "löscht ein vorhandenes Mitglied",
|
||||
"restriction": restriction_logged_in,
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace _espe.api
|
|||
rest_subject : lib_plankton.rest.type_rest
|
||||
) : void
|
||||
{
|
||||
lib_plankton.rest.register<
|
||||
register<
|
||||
int,
|
||||
(
|
||||
null
|
||||
|
@ -24,7 +24,7 @@ namespace _espe.api
|
|||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.get,
|
||||
_espe.conf.get().server.path_base + "/member/info/:id",
|
||||
"/member/info/:id",
|
||||
{
|
||||
"description": "gibt Angaben über ein Mitglied aus, die für die Registrierung verwendet werden dürfen",
|
||||
"input_schema": () => ({
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace _espe.api
|
|||
rest_subject : lib_plankton.rest.type_rest
|
||||
) : void
|
||||
{
|
||||
lib_plankton.rest.register<
|
||||
register<
|
||||
null,
|
||||
Array<
|
||||
{
|
||||
|
@ -22,7 +22,7 @@ namespace _espe.api
|
|||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.get,
|
||||
_espe.conf.get().server.path_base + "/member/list",
|
||||
"/member/list",
|
||||
{
|
||||
"description": "listet alle Mitglieder auf",
|
||||
"query_parameters": [
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace _espe.api
|
|||
rest_subject : lib_plankton.rest.type_rest
|
||||
) : void
|
||||
{
|
||||
lib_plankton.rest.register<
|
||||
register<
|
||||
{
|
||||
email_address_private : (null | string);
|
||||
registered : boolean;
|
||||
|
@ -17,7 +17,7 @@ namespace _espe.api
|
|||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.patch,
|
||||
_espe.conf.get().server.path_base + "/member/modify/:id",
|
||||
"/member/modify/:id",
|
||||
{
|
||||
"description": "ändert die Angaben eines vorhandenen Mitglieds",
|
||||
"input_schema": () => ({
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace _espe.api
|
|||
rest_subject : lib_plankton.rest.type_rest
|
||||
) : void
|
||||
{
|
||||
lib_plankton.rest.register<
|
||||
register<
|
||||
{
|
||||
membership_number : string;
|
||||
name_real_value : string;
|
||||
|
@ -17,7 +17,7 @@ namespace _espe.api
|
|||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.post,
|
||||
_espe.conf.get().server.path_base + "/member/project",
|
||||
"/member/project",
|
||||
{
|
||||
"description": "erstellt ein neues Mitglied und gibt die erzeugte ID aus",
|
||||
"input_schema": () => ({
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace _espe.api
|
|||
rest_subject : lib_plankton.rest.type_rest
|
||||
) : void
|
||||
{
|
||||
lib_plankton.rest.register<
|
||||
register<
|
||||
null,
|
||||
{
|
||||
membership_number : string;
|
||||
|
@ -28,7 +28,7 @@ namespace _espe.api
|
|||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.get,
|
||||
_espe.conf.get().server.path_base + "/member/read/:id",
|
||||
"/member/read/:id",
|
||||
{
|
||||
"description": "gibt ein Mitglied anhand seiner ID aus",
|
||||
"output_schema": () => ({
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace _espe.api
|
|||
rest_subject : lib_plankton.rest.type_rest
|
||||
) : void
|
||||
{
|
||||
lib_plankton.rest.register<
|
||||
register<
|
||||
{
|
||||
email_use_veiled_address : boolean;
|
||||
email_use_nominal_address : boolean;
|
||||
|
@ -24,7 +24,7 @@ namespace _espe.api
|
|||
>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.post,
|
||||
_espe.conf.get().server.path_base + "/member/register/:id",
|
||||
"/member/register/:id",
|
||||
{
|
||||
"description": "nimmt zusätzliche Angaben eines Mitglieds entgegen",
|
||||
"input_schema": () => ({
|
||||
|
|
|
@ -7,10 +7,10 @@ namespace _espe.api
|
|||
rest_subject : lib_plankton.rest.type_rest
|
||||
) : void
|
||||
{
|
||||
lib_plankton.rest.register<null, null>(
|
||||
register<null, null>(
|
||||
rest_subject,
|
||||
lib_plankton.http.enum_method.delete,
|
||||
_espe.conf.get().server.path_base + "/session/end",
|
||||
"/session/end",
|
||||
{
|
||||
"description": "beendet eine Sitzung",
|
||||
"input_schema": () => ({
|
||||
|
|
|
@ -65,5 +65,47 @@ namespace _espe.api
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
export function register<type_input, type_output>(
|
||||
rest_subject : lib_plankton.rest.type_rest,
|
||||
http_method : lib_plankton.http.enum_method,
|
||||
path : string,
|
||||
options : {
|
||||
active ?: ((version : string) => boolean);
|
||||
restriction ?: (null | lib_plankton.rest.type_restriction<type_input>);
|
||||
execution ?: lib_plankton.rest.type_execution<type_input, type_output>;
|
||||
title ?: (null | string);
|
||||
description ?: (null | string);
|
||||
query_parameters ?: Array<
|
||||
{
|
||||
name : string;
|
||||
description : (null | string);
|
||||
required : boolean;
|
||||
}
|
||||
>;
|
||||
input_schema ?: ((version: (null | string)) => lib_plankton.rest.type_oas_schema);
|
||||
output_schema ?: ((version: (null | string)) => lib_plankton.rest.type_oas_schema);
|
||||
request_body_mimetype ?: string;
|
||||
request_body_decode ?: ((http_request_body : Buffer, http_request_header_content_type : (null | string)) => any);
|
||||
response_body_mimetype ?: string;
|
||||
response_body_encode ?: ((output : any) => Buffer);
|
||||
} = {}
|
||||
) : void
|
||||
{
|
||||
options = Object.assign(
|
||||
{
|
||||
},
|
||||
options
|
||||
);
|
||||
lib_plankton.rest.register<type_input, type_output>(
|
||||
rest_subject,
|
||||
http_method,
|
||||
(_espe.conf.get().server.path_base + path),
|
||||
options
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue