### Installation commands Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/README.md Clones the repository, changes into the project directory, installs dependencies, and copies the environment example file. Run these commands in a terminal to set up the project locally. ```bash git clone https://github.com/ECCdigital/smart-city-booking-backend.git cd smart-city-booking-backend npm install cp .env-example .env ``` -------------------------------- ### Start the backend Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/deployment.md Start the backend after installing production dependencies. Use a process manager (e.g., systemd or PM2) to ensure the service restarts automatically. ```bash npm start ``` -------------------------------- ### Start full stack with Docker Compose Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/getting-started.md Set up the full stack (MongoDB, Backend, Admin UI, Storefront) using the example Docker Compose file. Copy the example files, edit secrets in .env, and start the stack in detached mode with build. The backend is built from the current directory and frontends from their public GitHub develop branches. ```bash cp docker-compose.full-stack.example.yml docker-compose.yml cp .env.full-stack.example .env # Edit secrets in .env (CRYPTO_SECRET, JWT_*, INIT_ADMIN_SECRET, optional Nextcloud) docker compose up -d --build ``` -------------------------------- ### Run Storefront locally with npm Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/getting-started.md Clone the Storefront repository, install dependencies, copy the environment template, and start the development server. Set NUXT_API_BASE_URL to http://localhost:8081 and configure Storefront/Admin URLs as described in the URL matrix. The Storefront will be available at http://localhost:3000. ```bash git clone https://github.com/ECCdigital/smart-city-booking-store-front.git cd smart-city-booking-store-front git checkout develop # or version/1.x npm install cp .env.example .env # Set NUXT_API_BASE_URL=http://localhost:8081 and Storefront/Admin URLs (see matrix above) npm run dev ``` -------------------------------- ### Instance entity example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of the Instance entity, representing global configuration for the entire deployment. There is only one instance per installation. Note that publicOffersEnabled and portalUrl replace legacy fields enableCatalog and catalogUrl, and instance-level branding applies to catalogs and the public portal. ```json { "applications": [], "mailTemplate": "...", "mailAddress": "contact@example.com", "noreplyMail": "noreply@example.com", "noreplyDisplayName": "No Reply", "noreplyHost": "smtp.example.com", "noreplyPort": 587, "noreplyUser": "noreply@example.com", "noreplyPassword": {}, "noreplyStarttls": true, "noreplyUseGraphApi": false, "noreplyGraphTenantId": "", "noreplyGraphClientId": "", "noreplyGraphClientSecret": {}, "mailEnabled": true, "contactAddress": "contact@example.com", "contactUrl": "https://example.com/contact", "dataProtection": { "source": "url", "url": "https://example.com/privacy", "fileName": "" }, "legalNotice": { "source": "url", "url": "https://example.com/legal", "fileName": "" }, "termsAndConditions": { "source": "file", "url": "https://backend.example.com/api/files/get?name=/public/legal/agb.pdf", "fileName": "agb.pdf" }, "allowAllUsersToCreateTenant": false, "allowedUsersToCreateTenant": [], "ownerUserIds": ["admin@example.com"], "isInitialized": true, "userNotifications": [], "checkout": { "useLegacyCheckout": true, "checkoutUrl": "" }, "publicOffersEnabled": false, "portalUrl": "", "branding": { "active": false, "theme": { "colors": { "primary": "", "secondary": "" } }, "logoUrl": "", "faviconUrl": "" }, "bookableCustomFields": [] } ``` -------------------------------- ### Run Backend API locally with npm Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/getting-started.md Clone the backend repository, install dependencies, copy the environment template, and start the development server. Requires MongoDB to be running and reachable at the configured DB_URL. The API will be available at http://localhost:8081 with a live check at /healthz/live. ```bash git clone https://github.com/ECCdigital/smart-city-booking-backend.git cd smart-city-booking-backend git checkout develop # or version/4.x npm install cp .env-example .env # Edit secrets, DB_URL, FRONTEND_URL, BACKEND_URL npm run dev ``` -------------------------------- ### Start development server Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/README.md Starts the API in development mode. MongoDB must be running. The API listens on the port configured in .env (default: 8081). ```bash npm run dev ``` -------------------------------- ### Challenge document example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of a challenge building block for onboarding or verification flows, with rolesToAssign when completed. ```json { "id": "chlg-terms", "tenantId": "default", "key": "accept-terms", "enabled": true, "defaultConfig": { "url": "https://example.com/terms" }, "label": "Accept Terms of Service", "description": "User must read and accept the current terms of service.", "rolesToAssign": ["member"] } ``` -------------------------------- ### Install production dependencies Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/deployment.md Install production dependencies only, omitting development dependencies. Run this before starting the backend with npm start. ```bash npm ci --omit=dev ``` -------------------------------- ### AccessPoint document example (locker) Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of an access point for a locker integration with provider 'ilockit'. Types include 'locker'; providers are integration-specific (e.g., ilockit, nuki, salto). ```json { "id": "ap-123", "tenant": "default", "type": "locker", "provider": "ilockit", "externalId": "locker-unit-42", "locationId": "building-a", "label": "Box 12", "metadata": {} } ``` -------------------------------- ### Run Admin UI locally with npm Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/getting-started.md Clone the Admin UI repository, install dependencies, copy the environment template, and start the development server. Set VUE_APP_SERVER_BASE_URL to http://localhost:8081 to point to the backend API. The Admin UI will be available at http://localhost:8080. ```bash git clone https://github.com/ECCdigital/smart-city-booking-vue-app.git cd smart-city-booking-vue-app git checkout develop # or version/4.x npm install cp .env-example .env # Set VUE_APP_SERVER_BASE_URL=http://localhost:8081 npm run serve ``` -------------------------------- ### Invitation document example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of an invitation granting access to a tenant, with single-use type, maxUses, challenges, roles, and expiry timestamp. ```json { "tenantId": "default", "token": "INV-123", "type": "single", "maxUses": 1, "usedCount": 0, "challenges": ["chlg-terms"], "roles": ["member"], "intendedUserId": "someone@example.com", "expiresAt": 1735685940000, "status": "active" } ``` -------------------------------- ### Full stack with Docker Compose Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/deployment.md Set up the full stack with Docker Compose by copying example files, editing secrets, and starting the stack in detached mode with build. For production, prefer pinned release tags or GHCR images behind a TLS reverse proxy. ```bash cp docker-compose.full-stack.example.yml docker-compose.yml cp .env.full-stack.example .env # Edit secrets, then: docker compose up -d --build ``` -------------------------------- ### Workflow state machine example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of a workflow state machine with two states (Pending, Approved) and eventStateMapping for onCreate, onCommit, onReject, and onPay events. ```json { "tenantId": "default", "name": "Booking Approval", "description": "Workflow for approving bookings", "states": [ { "id": "state-1", "name": "Pending", "actions": [], "tasks": [] }, { "id": "state-2", "name": "Approved", "actions": [], "tasks": [] } ], "archive": [], "eventStateMapping": { "onCreate": "state-1", "onCommit": "state-2", "onReject": "", "onPay": "state-2" }, "active": true } ``` -------------------------------- ### Membership object example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of a membership object linking a user to a tenant with roles, ownership, status, source, and invitation details including challenge states. ```json { "userId": "someone@example.com", "tenantId": "default", "roles": ["admin", "editor"], "owner": true, "status": "active", "source": "invite", "invitations": [ { "token": "INV-123", "status": "completed", "reason": "User accepted the invite", "challengeStates": [ { "challengeId": "chlg-terms", "status": "passed", "message": "Terms accepted", "updatedAt": "2024-01-01T12:00:00.000Z", "approvedBy": null } ] } ] } ``` -------------------------------- ### Catalog document example (single) Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of a single-tenant catalog with type 'single'. For aggregate catalogs type is 'aggregate' and for instance-wide catalogs type is 'instance' with tenantId/name/slug omitted. ```json { "type": "single", "slug": "city-hall", "name": "City Hall Catalog", "tenantId": "default", "tenantIds": [], "excludedTenantIds": [], "active": true, "visibility": "public", "hero": { "title": "Welcome", "subtitle": "Book city resources online" } } ``` -------------------------------- ### TokenSession document example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of a TokenSession document tracking an issued refresh token for revocation and audit purposes. ```json { "jti": "d8b9c5c2-9c3b-4c23-9c39-2f3c9c3b9c3b", "userId": "someone@example.com", "tokenType": "refresh", "status": "active", "issuedAt": "2024-01-01T12:00:00.000Z", "expiresAt": "2024-02-01T12:00:00.000Z", "revokedAt": null, "revokeReason": null, "deviceId": "browser-abc-123" } ``` -------------------------------- ### Role entity example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example Role document defining permission sets within a tenant, including adminInterfaces and granular manage permissions for users, bookables, bookings, coupons, and roles. Shows assignedUserId and freeBookings flags. ```json { "id": "admin", "name": "Administrator", "tenantId": "default", "adminInterfaces": [ "locations", "users", "roles", "bookings", "coupons", "rooms", "resources", "tickets", "events" ], "manageUsers": { "create": true, "readAny": true, "readOwn": true, "updateAny": true, "updateOwn": true, "deleteAny": true, "deleteOwn": true }, "manageBookables": { "create": true, "readAny": true, "readOwn": true, "updateAny": true, "updateOwn": true, "deleteAny": true, "deleteOwn": true }, "manageBookings": { "create": true, "readAny": true, "readOwn": true, "updateAny": true, "updateOwn": true, "deleteAny": true, "deleteOwn": true }, "manageCoupons": { "create": true, "readAny": true, "readOwn": true, "updateAny": true, "updateOwn": true, "deleteAny": true, "deleteOwn": true }, "manageRoles": { "create": true, "readAny": true, "readOwn": true, "updateAny": true, "updateOwn": true, "deleteAny": true, "deleteOwn": true }, "assignedUserId": "someone@example.com", "freeBookings": true } ``` -------------------------------- ### Stop Docker Compose stack Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/getting-started.md Stop and remove the Docker Compose stack started with the example compose file. ```bash docker compose down ``` -------------------------------- ### Compare availability engines Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Run this command to compare the V1 and V2 availability implementations locally. Replace and with actual values; the -s and -e flags specify the start and end dates. ```bash npm run compare:availability -- -t -b -s 2026-06-01 -e 2026-06-07 ``` -------------------------------- ### Authorization Header Example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/authentication.md Shows how to include the access token in the Authorization header for protected routes. ```http Authorization: Bearer ``` -------------------------------- ### Local Nextcloud URL Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/nextcloud.md Example for local development: run Nextcloud via Docker on port 9500 and point the URL to it. Credentials must match a user in the local instance. ```bash NEXTCLOUD_URL=http://localhost:9500 ``` -------------------------------- ### User entity example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example User document for an individual who can authenticate and interact with tenants via memberships. authType can be local or SSO; keycloakId links SSO users, cardAuth stores card-based auth metadata, and legalAcceptance records accepted legal documents per key. ```json { "id": "someone@example.com", "firstName": "John", "lastName": "Doe", "phone": "1234567890", "address": "123 Main St", "zipCode": "12345", "city": "Example City", "company": "Example Company", "secret": "", "hooks": [], "isVerified": true, "created": 1658991377408, "isSuspended": false, "authType": "local", "keycloakId": "", "cardAuth": {}, "legalAcceptance": {} } ``` -------------------------------- ### Coupon entity example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of a Coupon entity representing a percentage discount. The discount is 50%, with a maximum discount amount of 20 and a used amount of 3. Valid from 1677668400000 to 1735685940000. ```json { "id": "STUDENT50", "tenantId": "default", "description": "50% discount for students", "type": "percentage", "discount": 50, "amount": 0, "maxAmount": 20, "usedAmount": 3, "validFrom": 1677668400000, "validTo": 1735685940000, "ownerUserId": "some@example.com" } ``` -------------------------------- ### GroupBooking entity example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of a GroupBooking entity, representing a collection of related bookings managed together. Contains bookingIds, assignedUserId, mail, internalComments, timeCreated, and hooks. ```json { "id": "group-123", "tenantId": "default", "bookingIds": ["booking-1", "booking-2"], "assignedUserId": "user-123", "mail": "group@example.com", "internalComments": "", "timeCreated": 1707994800000, "hooks": [] } ``` -------------------------------- ### GET /api/tenants/public Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Returns a public list of tenants. No authentication required. ```APIDOC ## GET /api/tenants/public ### Description Returns a public list of tenants. No authentication required. ### Method GET ### Endpoint /api/tenants/public ### Response #### Success Response (200) - **tenants** (array) - List of public tenant objects. #### Response Example { "tenants": [] } ``` -------------------------------- ### npm commands for development, testing, and linting Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/AGENTS.md Common npm scripts for installing dependencies, running the dev server, running tests, and checking/formatting code with ESLint and Prettier. Run `npm test` and `npm run lint:check` before finishing a task. ```bash npm install # install dependencies npm run dev # dev server (nodemon, needs MongoDB) npm test # mocha tests npm run lint:check # eslint npm run lint:fix # eslint --fix npm run format:check # prettier --check npm run format:write # prettier --write ``` -------------------------------- ### Database environment configuration Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/README.md Sets the MongoDB connection string and database name in the .env file. Configure these values before starting the API. ```bash DB_URL=mongodb://localhost:27017/booking-manager DB_NAME=booking-manager ``` -------------------------------- ### Tenant entity example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example Tenant document showing fields like contact info, mail templates, SMTP settings, receipt/invoice numbering, cancellation refund tiers, and catalog participation. Sensitive fields such as noreplyPassword and payment secrets are stored encrypted. cancellationRefundTiers uses calendar days in Europe/Berlin; an empty array preserves the default full refund. ```json { "id": "default", "name": "Example Name", "contactName": "Example Contact", "location": "Example Location", "mail": "example@example.com", "phone": "1234567890", "website": "https://example.com", "bookableDetailLink": "https://example.com/bookable-detail", "eventDetailLink": "https://example.com/event-detail", "genericMailTemplate": "...", "useInstanceMail": true, "noreplyMail": "example@example.com", "noreplyDisplayName": "Example Display Name", "noreplyHost": "smtp.example.com", "noreplyPort": 465, "noreplyUser": "smtp_user", "noreplyPassword": {}, "noreplyStarttls": false, "noreplyUseGraphApi": false, "noreplyGraphTenantId": "GraphTenantId", "noreplyGraphClientId": "GraphClientId", "noreplyGraphClientSecret": {}, "receiptTemplate": "...", "receiptNumberPrefix": "exmp", "receiptCount": { "2024": 1 }, "receiptEnableBCC": false, "invoiceTemplate": "...", "invoiceNumberPrefix": "exmp", "invoiceCount": { "2024": 1 }, "cancellationRefundTiers": [ { "daysBeforeStart": 20, "refundPercentage": 100 }, { "daysBeforeStart": 0, "refundPercentage": 50 } ], "paymentPurposeSuffix": "Example 123 4 56", "applications": [], "maxBookingAdvanceInMonths": 12, "defaultEventCreationMode": "simple", "enablePublicStatusView": true, "notifyOnNewBooking": true, "catalogParticipation": { "visible": true, "restricted": false } } ``` -------------------------------- ### Bunyan logger setup and usage Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/agents/coding-standards.md Logging with bunyan. Uses process.env.LOG_LEVEL for level and logs structured info with tenantId and bookingId. ```javascript const bunyan = require("bunyan"); const logger = bunyan.createLogger({ name: "my-service.js", level: process.env.LOG_LEVEL, }); logger.info({ tenantId, bookingId }, "Booking created"); ``` -------------------------------- ### GET /api/:tenant/bookables/public Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves public bookables for a tenant. Authentication is optional. ```APIDOC ## GET /api/:tenant/bookables/public ### Description Returns public bookables for a tenant. Authentication is optional. ### Method GET ### Endpoint /api/:tenant/bookables/public ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. ### Authentication Optional. ``` -------------------------------- ### GET /api/tenants/:id Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Returns a single tenant. Requires JWT. ```APIDOC ## GET /api/tenants/:id ### Description Returns a single tenant. Requires JWT. ### Method GET ### Endpoint /api/tenants/:id ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the tenant. ### Authentication Requires a valid JWT. ### Response #### Success Response (200) - **tenant** (object) - The requested tenant object. #### Response Example { "tenant": {} } ``` -------------------------------- ### Tenant auth application (Keycloak SSO) Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of a tenant application of type 'auth' with id 'keycloak' for Keycloak SSO. Includes serverUrl, realm, publicClient, privateClient, and empty secret/roleMapping objects. ```json { "type": "auth", "id": "keycloak", "active": true, "title": "Keycloak SSO", "serverUrl": "https://auth.example.com", "realm": "booking", "publicClient": "storefront", "privateClient": "backend", "privateClientSecret": {}, "roleMapping": {} } ``` -------------------------------- ### GET /api/:tenant/bookings/:id/hooks/:hookId/cancellation-refund-preview Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Returns a customer-safe refund preview for a pending REJECT verification hook. No JWT. ```APIDOC ## GET /api/:tenant/bookings/:id/hooks/:hookId/cancellation-refund-preview ### Description Returns a customer-safe refund preview for a pending REJECT verification hook. No JWT. ### Method GET ### Endpoint /api/:tenant/bookings/:id/hooks/:hookId/cancellation-refund-preview ### Parameters #### Path Parameters - **tenant** (string) - Required - Tenant identifier - **id** (string) - Required - Booking identifier - **hookId** (string) - Required - Hook identifier ``` -------------------------------- ### GET /auth/me Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/authentication.md Retrieve data of the currently authenticated user. ```APIDOC ## GET /auth/me ### Description Retrieve data of the currently authenticated user. ### Method GET ### Endpoint /auth/me ### Authentication Requires a valid access token in the Authorization header: `Authorization: Bearer ` ### Response #### Success Response (200) - **id** (string) - The user's identifier. - **firstName** (string) - The user's first name. - **lastName** (string) - The user's last name. #### Response Example { "id": "someone@example.com", "firstName": "First Name", "lastName": "Last Name" } ``` -------------------------------- ### GET /api/:tenant/bookables/:id/openingHours Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves opening hours for a bookable. No authentication required. ```APIDOC ## GET /api/:tenant/bookables/:id/openingHours ### Description Returns opening hours for a bookable. No authentication middleware is applied. ### Method GET ### Endpoint /api/:tenant/bookables/:id/openingHours ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. - **id** (string) - Required - The bookable ID. ### Authentication None. ``` -------------------------------- ### Event entity example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of an Event entity. Events describe real-world events and can be linked to ticket bookables. The externalBookingUrl field links to an external booking page when the event is not booked through this platform. ```json { "id": "event-123", "tenantId": "default", "attachments": [], "attendees": { "publicEvent": true, "needsRegistration": false, "free": false, "maxAttendees": null, "priceCategories": [] }, "location": { "coordinates": { "type": "Point", "points": [null, null] }, "display_address": "", "address": { "street": null, "house_number": null, "post_code": null, "city": null, "suburb": null, "state": null, "country": null, "country_code": null }, "meta": {} }, "eventLocation": { "name": "", "phoneNumber": "", "emailAddress": "", "select": null, "room": null, "url": "" }, "eventOrganizer": { "name": "", "addContactPerson": true, "contactPersonName": "", "contactPersonPhoneNumber": "", "contactPersonEmailAddress": "", "contactPersonImage": "", "speakers": [] }, "format": 0, "images": [], "information": { "name": "", "teaserText": "", "description": "", "teaserImage": null, "startDate": "", "startTime": "", "endDate": "", "endTime": "", "tags": [], "flags": [] }, "isPublic": true, "schedules": [], "ownerUserId": "user-123", "externalBookingUrl": "" } ``` -------------------------------- ### Booking JSON Example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md A JSON representation of a booking object with all its fields. Use this as a reference for the expected structure and data types when creating or processing bookings. ```json { "id": "BK-1234", "tenantId": "default", "assignedUserId": "user1", "attachments": [], "bookableItems": [], "comment": "Please provide a projector and whiteboard.", "internalComments": "Internal note", "rejectionReason": "", "company": "Some Corp", "couponCode": "COUPON123", "isCommitted": true, "isPayed": true, "isRejected": false, "location": "Anytown", "lockerInfo": [], "mail": "john.doe@example.com", "name": "John Doe", "paymentProvider": "stripe", "paymentMethod": "credit-card", "phone": "1234567890", "priceEur": 100, "street": "123 Main St", "timeBegin": 1707994800000, "timeCreated": 1707994800000, "timeEnd": 1708009200000, "timePaid": 1708002800000, "vatIncludedEur": 19, "_couponUsed": {}, "customFieldValues": [], "cancellationPolicy": { "userCancellable": true, "contactHint": "" }, "hooks": [] } ``` -------------------------------- ### GET /api/:tenant/bookings/:id/cancellation-refund-preview Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Returns the current policy proposal for an administrator. Requires JWT and booking update permission. ```APIDOC ## GET /api/:tenant/bookings/:id/cancellation-refund-preview ### Description Returns the current policy proposal for an administrator. Requires JWT and booking update permission. ### Method GET ### Endpoint /api/:tenant/bookings/:id/cancellation-refund-preview ### Parameters #### Path Parameters - **tenant** (string) - Required - Tenant identifier - **id** (string) - Required - Booking identifier ### Authentication Requires JWT and booking update permission. ``` -------------------------------- ### GET /api/tenants Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Returns tenants visible to the authenticated user. Requires JWT. ```APIDOC ## GET /api/tenants ### Description Returns tenants visible to the authenticated user. Requires JWT. ### Method GET ### Endpoint /api/tenants ### Authentication Requires a valid JWT. ### Response #### Success Response (200) - **tenants** (array) - List of tenant objects visible to the user. #### Response Example { "tenants": [] } ``` -------------------------------- ### GET /api/:tenant/bookables/:id/prices Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves price categories for a bookable. No authentication required. ```APIDOC ## GET /api/:tenant/bookables/:id/prices ### Description Returns price categories for a bookable. No authentication middleware is applied. ### Method GET ### Endpoint /api/:tenant/bookables/:id/prices ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. - **id** (string) - Required - The bookable ID. ### Authentication None. ``` -------------------------------- ### GET /api/roles Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves all roles at the instance level. Requires JWT authentication. ```APIDOC ## GET /api/roles ### Description Returns all roles at the instance level. Requires JWT authentication. ### Method GET ### Endpoint /api/roles ### Authentication Requires JWT. ``` -------------------------------- ### CommonJS module example Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/agents/coding-standards.md CommonJS module pattern used throughout the project. Requires managers and errors, then exports the service object. ```javascript const BookingManager = require("../data-managers/booking-manager"); const { BadRequestError } = require("../../errors/BaseError"); module.exports = { BookingService }; ``` -------------------------------- ### Tenant payment application (ePayBL) Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/entities.md Example of a tenant payment application with id 'ePayBL'. Payment ids include ePayBL, pmPayment, giroCockpit, and invoice, each with provider-specific fields. ```json { "type": "payment", "id": "ePayBL", "active": true, "title": "ePayBL", "merchantId": "..." } ``` -------------------------------- ### GET /api/:tenant/bookables/:id/occupancy Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves occupancy information for a bookable. No authentication required. ```APIDOC ## GET /api/:tenant/bookables/:id/occupancy ### Description Returns occupancy information for a bookable. No authentication middleware is applied, but uses `user?.id` when present. ### Method GET ### Endpoint /api/:tenant/bookables/:id/occupancy ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. - **id** (string) - Required - The bookable ID. #### Query Parameters - **timeBegin** (timestamp, optional) - Start time for the occupancy check. - **timeEnd** (timestamp, optional) - End time for the occupancy check. - **ignoreRelatedEntities** (boolean, optional) - If `true`, related entities are ignored in the occupancy calculation. Default: `false`. ### Authentication None (uses `user?.id` when present). ### Response - **bookableId** - ID of the bookable resource. - **title** - Title of the bookable resource. - **isAvailable** - Whether the bookable is available in the specified time range. - **totalCapacity** - Total capacity of the bookable. - **booked** - Number of booked units. - **remaining** - Number of remaining units. ``` -------------------------------- ### GET /api/:tenant/bookings/:id/cancellation-refund-preview/public?name= Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Returns a customer-safe refund preview for self-cancellation. Requires matching booking owner name. No JWT. ```APIDOC ## GET /api/:tenant/bookings/:id/cancellation-refund-preview/public?name= ### Description Returns a customer-safe refund preview for self-cancellation. Requires matching booking owner name. No JWT. ### Method GET ### Endpoint /api/:tenant/bookings/:id/cancellation-refund-preview/public ### Parameters #### Path Parameters - **tenant** (string) - Required - Tenant identifier - **id** (string) - Required - Booking identifier #### Query Parameters - **name** (string) - Required - Booking owner name ``` -------------------------------- ### GET /api/:tenant/bookables Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves all bookables (including non-public) for a tenant. Requires JWT authentication. ```APIDOC ## GET /api/:tenant/bookables ### Description Returns all bookables, including non-public ones, for a tenant. Requires JWT authentication. ### Method GET ### Endpoint /api/:tenant/bookables ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. ### Authentication Requires JWT. ``` -------------------------------- ### GET /api/:tenant/roles Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves all roles for a specific tenant. Requires JWT authentication. ```APIDOC ## GET /api/:tenant/roles ### Description Returns all roles for a specific tenant. Requires JWT authentication. ### Method GET ### Endpoint /api/:tenant/roles ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. ### Authentication Requires JWT. ``` -------------------------------- ### GET /api/:tenant/group-bookings/:id/cancellation-refund-preview Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Returns per-booking calculations and aggregate amounts for a group booking. Requires JWT and booking update permission. ```APIDOC ## GET /api/:tenant/group-bookings/:id/cancellation-refund-preview ### Description Returns per-booking calculations and aggregate amounts for a group booking. Requires JWT and booking update permission. ### Method GET ### Endpoint /api/:tenant/group-bookings/:id/cancellation-refund-preview ### Parameters #### Path Parameters - **tenant** (string) - Required - Tenant identifier - **id** (string) - Required - Group booking identifier ### Authentication Requires JWT and booking update permission. ``` -------------------------------- ### GET /api/:tenant/bookables/:id Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves a single bookable by ID. Requires JWT authentication. ```APIDOC ## GET /api/:tenant/bookables/:id ### Description Returns a single bookable by its ID. Requires JWT authentication. ### Method GET ### Endpoint /api/:tenant/bookables/:id ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. - **id** (string) - Required - The bookable ID. ### Authentication Requires JWT. ``` -------------------------------- ### GET /api/:tenant/bookables/public/:id Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves a single public bookable by ID. Authentication is optional. ```APIDOC ## GET /api/:tenant/bookables/public/:id ### Description Returns a single public bookable by its ID. Authentication is optional. ### Method GET ### Endpoint /api/:tenant/bookables/public/:id ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. - **id** (string) - Required - The bookable ID. ### Authentication Optional. ``` -------------------------------- ### GET /auth/verify/:hookId Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/authentication.md Verify a user using the hook ID generated during signup. ```APIDOC ## GET /auth/verify/:hookId ### Description Verify a user using the hook ID generated during signup. ### Method GET ### Endpoint /auth/verify/:hookId ### Parameters #### Path Parameters - **hookId** (string) - Required - The hook ID generated during signup. ### Response #### Success Response (200) Verification successful. ``` -------------------------------- ### GET /api/:tenant/bookables/:id/availability/v2 Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Alias for the primary availability endpoint using the V2 engine. Optional authentication. ```APIDOC ## GET /api/:tenant/bookables/:id/availability/v2 ### Description Alias for the primary `/availability` endpoint, using the same V2 engine. Authentication is optional. ### Method GET ### Endpoint /api/:tenant/bookables/:id/availability/v2 ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. - **id** (string) - Required - The bookable ID. ### Authentication Optional. ``` -------------------------------- ### GET /api/:tenant/bookables/:id/availability Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves availability intervals for a bookable using the V2 engine. Optional authentication. ```APIDOC ## GET /api/:tenant/bookables/:id/availability ### Description Returns availability intervals for a bookable using the V2 engine (shared `availability-rules`). Authentication is optional. ### Method GET ### Endpoint /api/:tenant/bookables/:id/availability ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. - **id** (string) - Required - The bookable ID. #### Query Parameters - **amount** (number, optional) - The number of units to check availability for. Default: 1. - **startDate** (string, optional) - Start date in ISO format. - **endDate** (string, optional) - End date in ISO format. ### Authentication Optional. ### Response Headers - `X-Availability-Engine: v2` ### Response Body ```json { "title": "string", "availability": [ { "timeBegin": "string", "timeEnd": "string", "available": "boolean" } ], "_metrics": "object" } ``` ``` -------------------------------- ### GET /api/:tenant/roles/tenant Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves the current user's roles in the specified tenant. Requires JWT authentication. ```APIDOC ## GET /api/:tenant/roles/tenant ### Description Returns the current user's roles within the specified tenant. Requires JWT authentication. ### Method GET ### Endpoint /api/:tenant/roles/tenant ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. ### Authentication Requires JWT. ``` -------------------------------- ### GET /api/:tenant/bookables/:id/availability/v1 (deprecated) Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Deprecated legacy availability endpoint. Use the primary availability endpoint instead. ```APIDOC ## GET /api/:tenant/bookables/:id/availability/v1 (deprecated) ### Description Legacy iterative checkout-based availability. Prefer the `/availability` endpoint. Authentication is optional. Response includes `Deprecation: true`, `Sunset`, and `Link` successor headers. ### Method GET ### Endpoint /api/:tenant/bookables/:id/availability/v1 ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. - **id** (string) - Required - The bookable ID. ### Authentication Optional. ### Response Headers - `Deprecation: true` - `Sunset` - `Link` (successor) ``` -------------------------------- ### Build and run backend with Docker Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/deployment.md Build and run the backend with Docker, using an environment file and mapping port 8081. The container is set to restart unless stopped. ```bash docker build -t smart-city-booking-backend . docker run -d \ --name smart-city-booking-backend \ --restart unless-stopped \ --env-file .env \ -p 8081:8081 \ smart-city-booking-backend ``` -------------------------------- ### Initialize Booking Manager Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/web-integration.md Initialize the Booking Manager by creating a new instance, setting the backend API URL and tenant identifier, then calling init() on window load. init() loads FullCalendar libraries from a CDN, fetches data from the backend, and binds it to placeholder elements. ```html ``` -------------------------------- ### Recommended environment settings Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/deployment.md Recommended environment settings for production deployment. Set NODE_ENV to production, LOG_LEVEL to info, DISABLE_EMAIL_CHECK to false, and PORT to 8081. See .env-example for the full list of configuration options. ```bash NODE_ENV=production LOG_LEVEL=info DISABLE_EMAIL_CHECK=false PORT=8081 ``` -------------------------------- ### POST /auth/signup Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/authentication.md Register a new user with the provided details. ```APIDOC ## POST /auth/signup ### Description Register a new user. ### Method POST ### Endpoint /auth/signup ### Parameters #### Request Body - **id** (string) - Required - The user's identifier (e.g., email). - **password** (string) - Required - The user's password. - **firstName** (string) - Required - The user's first name. - **lastName** (string) - Required - The user's last name. ### Request Example { "id": "someone@example.com", "password": "your-password", "firstName": "First Name", "lastName": "Last Name" } ### Response #### Success Response (200) - **hookId** (string) - A hook ID generated during signup, used for verification. #### Response Example { "hookId": "" } ``` -------------------------------- ### Build Docker image Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/README.md Builds the Docker image for the backend service. Use this command to create the image before running the container. ```bash docker build -t smart-city-booking-backend . ``` -------------------------------- ### Controller pattern with static methods Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/agents/api.md Illustrates the controller pattern: static methods that extract parameters, authenticate, authorize, delegate to services, and respond. ```javascript class BookingController { static async getBooking(req, res) { const { tenantId, bookingId } = req.params; // authenticate, authorize, delegate to service/manager, respond } } ``` -------------------------------- ### GET /auth/reset/:hookId Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/authentication.md Reset a user's password via a hook. ```APIDOC ## GET /auth/reset/:hookId ### Description Reset a user's password via a hook. ### Method GET ### Endpoint /auth/reset/:hookId ### Parameters #### Path Parameters - **hookId** (string) - Required - The hook ID for password reset. ### Response #### Success Response (200) Password reset initiated. ``` -------------------------------- ### Script URL for booking-manager.min.js Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/web-integration.md URL pattern for the built booking-manager.min.js script, served from the frontend host after deployment. Replace with the actual host. ```text https:///cdn/current/booking-manager.min.js ``` -------------------------------- ### POST /auth/signup Request Body Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/authentication.md JSON body for registering a new user with email, password, and name fields. ```json { "id": "someone@example.com", "password": "your-password", "firstName": "First Name", "lastName": "Last Name" } ``` -------------------------------- ### GET /api/:tenant/bookables/:id/block-periods Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/api/README.md Retrieves block-period availability for a bookable. Optional authentication. ```APIDOC ## GET /api/:tenant/bookables/:id/block-periods ### Description Returns block-period availability for a bookable. Authentication is optional. ### Method GET ### Endpoint /api/:tenant/bookables/:id/block-periods ### Parameters #### Path Parameters - **tenant** (string) - Required - The tenant identifier. - **id** (string) - Required - The bookable ID. ### Authentication Optional. ``` -------------------------------- ### Storefront .env configuration Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/getting-started.md Storefront environment configuration for local npm development. Sets the server-side API URL, public storefront URL, optional admin UI link, and disables caching. ```bash NUXT_API_BASE_URL=http://localhost:8081 NUXT_USER_BASE_URL=http://localhost:3000 NUXT_PUBLIC_USER_BASE_URL=http://localhost:3000 NUXT_ADMIN_BASE_URL=http://localhost:8080 NUXT_PUBLIC_ADMIN_BASE_URL=http://localhost:8080 NUXT_CACHE_ENABLED=false ``` -------------------------------- ### Test conventions: describe/it block with sinon stub restore Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/agents/testing.md Standard test structure using Mocha's describe/it, importing modules relative to tests/, restoring stubs in afterEach, and testing behavior with arrange-act-assert comments. ```javascript const assert = require("assert"); const sinon = require("sinon"); const BlockPeriodService = require("../src/commons/services/block-period-service"); describe("BlockPeriodService", function () { afterEach(function () { sinon.restore(); }); it("rejects overlapping periods", async function () { // arrange → act → assert }); }); ``` -------------------------------- ### Admin UI .env configuration Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/getting-started.md Admin UI environment configuration for local npm development. Sets the API URL reachable from the browser. ```bash VUE_APP_SERVER_BASE_URL=http://localhost:8081 ``` -------------------------------- ### Nextcloud environment variables Source: https://github.com/eccdigital/smart-city-booking-backend/blob/develop/docs/nextcloud.md Environment variables required to configure the Nextcloud integration. Set these in the .env file; without them, file features fail with a configuration error. ```bash NEXTCLOUD_URL=http://localhost:9500 NEXTCLOUD_USERNAME=CHANGE_ME__NEXTCLOUD_USER NEXTCLOUD_PASSWORD=CHANGE_ME__NEXTCLOUD_PASSWORD ```