// @ts-check
/**
* @import {ExpressRequestAuthorized, ExpressResponse} from '../types.js'
*/
import express from 'express';
import { checkAdmin, checkVisible } from '../utils/authChecks.js';
import * as eventController from './event/controller.js';
/** @type {express.Express} */
const api = express();
/**
* @swagger
* tags:
* name: Events
* description: Event management endpoints
*/
/**
* @swagger
* components:
* schemas:
* Event:
* type: object
* properties:
* UID:
* type: string
* format: uuid
* description: Event unique identifier
* Title:
* type: string
* description: Event title
* Display:
* type: string
* description: Display name for the event
* Data:
* type: object
* description: Event data object
* from:
* type: number
* description: Event start timestamp in seconds
* to:
* type: number
* description: Event end timestamp in seconds
* location:
* type: object
* properties:
* UID:
* type: string
* format: uuid
* extraParameter:
* type: array
* items:
* type: object
* properties:
* name:
* type: string
* type:
* type: string
* EventResponse:
* type: object
* properties:
* success:
* type: boolean
* result:
* $ref: '#/components/schemas/Event'
* message:
* type: string
* EventListResponse:
* type: object
* properties:
* success:
* type: boolean
* result:
* type: array
* items:
* $ref: '#/components/schemas/Event'
*/
// *************** event
/**
* @swagger
* /api/events/{group}/{template}:
* put:
* summary: Create a new event
* tags: [Events]
* parameters:
* - in: path
* name: group
* required: true
* schema:
* type: string
* format: uuid
* description: Group UUID
* - in: path
* name: template
* required: true
* schema:
* type: string
* format: uuid
* description: Event template UUID
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* title:
* type: string
* description: Event title
* from:
* type: number
* description: Start timestamp in seconds
* to:
* type: number
* description: End timestamp in seconds
* location:
* type: object
* properties:
* UID:
* type: string
* format: uuid
* extraParameter:
* type: array
* items:
* type: object
* properties:
* name:
* type: string
* type:
* type: string
* responses:
* 200:
* description: Event created successfully
* content:
* application/json:
* schema:
* $ref: '#/components/schemas/EventResponse'
* 300:
* description: Error creating event
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: false
* message:
* type: string
*/
// @ts-ignore
api.put('/:group/:template', eventController.createEventController);
/**
* @swagger
* /api/events/{UID}:
* post:
* summary: Update an existing event
* tags: [Events]
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UID
* required: true
* schema:
* type: string
* format: uuid
* description: Event UUID
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* title:
* type: string
* from:
* type: number
* to:
* type: number
* location:
* type: object
* responses:
* 200:
* description: Event updated successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* type: object
* 300:
* description: Update failed
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* message:
* type: string
*/
// @ts-ignore
api.post('/:UID', checkAdmin, eventController.updateEventController);
/**
* @swagger
* /api/events/{UID}:
* delete:
* summary: Delete an event
* tags: [Events]
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UID
* required: true
* schema:
* type: string
* format: uuid
* description: Event UUID to delete
* responses:
* 200:
* description: Event deleted successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* example: true
* 300:
* description: Deletion failed
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* message:
* type: string
*/
// @ts-ignore
api.delete('/:UID', checkAdmin, eventController.deleteEventController);
/**
* @swagger
* /api/events/{UID}:
* get:
* summary: Get a single event by UID
* tags: [Events]
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: UID
* required: true
* schema:
* type: string
* format: uuid
* description: Event UUID
* responses:
* 200:
* description: Event details retrieved successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* type: object
* properties:
* UID:
* type: string
* format: uuid
* UIDBelongsTo:
* type: string
* format: uuid
* Title:
* type: string
* Display:
* type: string
* Data:
* type: object
* UIDTemplate:
* type: string
* format: uuid
* TemplateData:
* type: object
* DisplayTemplate:
* type: string
* GroupTitle:
* type: string
* GroupDisplay:
* type: string
* UIDgroup:
* type: string
* format: uuid
* UIDresponsible:
* type: string
* format: uuid
* titleResponsible:
* type: string
* responsible:
* type: string
* 400:
* description: Event not found or not accessible
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* message:
* type: string
*/
// @ts-ignore
api.get('/:UID', checkVisible, eventController.getEventController);
/**
* @swagger
* /api/events:
* get:
* summary: Get list of events with optional filtering and pagination
* tags: [Events]
* security:
* - bearerAuth: []
* parameters:
* - in: query
* name: __page
* schema:
* type: integer
* description: Page number for pagination (optional)
* - in: query
* name: Data
* schema:
* type: string
* description: "Either 'all' or JSON string of field paths to retrieve, e.g., '[{\"path\":\"$.from\",\"alias\":\"fromTime\"}]'"
* - in: query
* name: after
* schema:
* type: string
* description: Filter events that finish after this timestamp
* - in: query
* name: before
* schema:
* type: string
* description: Filter events that start before this timestamp
* responses:
* 200:
* description: List of events retrieved successfully
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* result:
* type: array
* items:
* type: object
* properties:
* UID:
* type: string
* format: uuid
* Title:
* type: string
* Display:
* type: string
* fromDate:
* type: number
* toDate:
* type: number
* stage:
* type: string
* gender:
* type: string
* SortName:
* type: string
* lat:
* type: number
* lng:
* type: number
* responsible:
* type: string
* 500:
* description: Internal server error
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* message:
* type: string
*/
// @ts-ignore
api.get('/', eventController.listEventsController);
export default api;