80 lines
1.6 KiB
TypeScript
80 lines
1.6 KiB
TypeScript
|
|
namespace _zeitbild.api
|
|
{
|
|
|
|
/**
|
|
*/
|
|
export function register_calendar_list(
|
|
rest_subject : lib_plankton.rest.type_rest
|
|
) : void
|
|
{
|
|
register<
|
|
null,
|
|
Array<
|
|
{
|
|
id : _zeitbild.type.calendar_id;
|
|
name : string;
|
|
public : boolean;
|
|
role : (null | _zeitbild.type.role);
|
|
}
|
|
>
|
|
>(
|
|
rest_subject,
|
|
lib_plankton.http.enum_method.get,
|
|
"/calendars",
|
|
{
|
|
"description": "listet alle verfügbaren Kalender auf",
|
|
"query_parameters": [
|
|
],
|
|
"output_schema": () => ({
|
|
"type": "array",
|
|
"items": {
|
|
"type": "object",
|
|
"nullable": false,
|
|
"additionalProperties": false,
|
|
"properties": {
|
|
"id": {
|
|
"type": "number",
|
|
"nullable": false,
|
|
},
|
|
"name": {
|
|
"type": "string",
|
|
"nullable": false,
|
|
},
|
|
"public": {
|
|
"type": "boolean",
|
|
"nullable": false,
|
|
},
|
|
"role": {
|
|
"type": "string",
|
|
"nullable": true,
|
|
},
|
|
},
|
|
"required": [
|
|
"id",
|
|
"name",
|
|
"public",
|
|
"role",
|
|
],
|
|
}
|
|
}),
|
|
"restriction": restriction_logged_in,
|
|
"execution": async (stuff) => {
|
|
const session : {key : string; value : lib_plankton.session.type_session;} = await session_from_stuff(stuff);
|
|
const user_id : _zeitbild.type.user_id = await _zeitbild.service.user.identify(session.value.name);
|
|
|
|
return (
|
|
_zeitbild.service.calendar.overview(user_id)
|
|
.then(
|
|
data => Promise.resolve({
|
|
"status_code": 200,
|
|
"data": data,
|
|
})
|
|
)
|
|
);
|
|
}
|
|
}
|
|
);
|
|
}
|
|
|
|
}
|