Ticketing Example

December 10, 2025 ยท View on GitHub

Example demonstrating the Unchained Engine ticketing extension for event tickets and digital passes.

Features

  • Fastify HTTP server with custom Unchained logger
  • Base plugins via @unchainedshop/plugins/presets/base
  • Ticketing module with @unchainedshop/ticketing
  • PDF ticket rendering (placeholder implementation)
  • Apple Wallet pass generation (placeholder implementation)
  • Google Wallet pass generation (placeholder implementation)
  • Magic key order access for ticket retrieval without login
  • Database seeding with admin user, country, currency, language, and providers
  • Integration tests for ticketing functionality

Prerequisites

  • Node.js >= 22
  • MongoDB (or uses in-memory MongoDB for development)

Quick Start

npm install
npm run dev

Server starts at http://localhost:4010 with:

  • GraphQL endpoint: /graphql
  • Default login: admin@unchained.local / password

Scripts

CommandDescription
npm run devStart development server with watch mode
npm run buildBuild TypeScript to lib/
npm startStart production server
npm run test:run:integrationRun integration tests
npm run lintFormat code with Prettier

Environment Variables

Required

VariableDescriptionDefault
ROOT_URLPublic URL of the serverhttp://localhost:4010
PORTServer port4010
UNCHAINED_TOKEN_SECRETSecret for session tokens (min 32 chars)-
UNCHAINED_SECRETSecret for magic key encryptionsecret
EMAIL_FROMDefault sender emailnoreply@unchained.local
EMAIL_WEBSITE_NAMEWebsite name for emailsUnchained
EMAIL_WEBSITE_URLWebsite URL for emailshttp://localhost:4010

Seeding

VariableDescriptionDefault
UNCHAINED_SEED_PASSWORDAdmin password (generate for random)password
UNCHAINED_COUNTRYDefault country ISO codeCH
UNCHAINED_CURRENCYDefault currency ISO codeCHF
UNCHAINED_LANGDefault language ISO codede

Apple Wallet (Optional)

VariableDescription
PASS_CERTIFICATE_PATHPath to Apple pass certificate (PEM)
PASS_CERTIFICATE_SECRETPEM passphrase
PASS_TEAM_IDApple Developer Team ID

Ticketing Setup

The example includes placeholder implementations for ticket rendering:

setupTicketing(platform.unchainedAPI, {
  renderOrderPDF: () => { /* Implement PDF generation */ },
  createAppleWalletPass: () => { /* Implement Apple Wallet pass */ },
  createGoogleWalletPass: () => { /* Implement Google Wallet pass */ },
});

Implementing PDF Tickets

import ReactPDF from '@react-pdf/renderer';

const renderOrderPDF = async ({ orderId }, { modules }) => {
  const order = await modules.orders.findOrder({ orderId });
  return ReactPDF.renderToStream(<TicketDocument order={order} />);
};

Implementing Wallet Passes

See the @unchainedshop/ticketing documentation for detailed implementation guides.

Database Seeding

On first start, the seed script creates:

  • Admin user: admin@unchained.local
  • Country: Switzerland (CH)
  • Currency: Swiss Franc (CHF)
  • Language: German (de)
  • Delivery provider: Send Message
  • Payment provider: Invoice

Testing

Run integration tests:

npm run test:run:integration

Tests are located in the tests/ directory.

Docker

docker build -t unchained-ticketing .
docker run -p 4010:4010 unchained-ticketing

License

EUPL-1.2