This directory holds the code for the Ticket Booking tutorial.
There are two directories:
medusafor the Medusa Application code. You can install and use it, or copy its source files into an existing Medusa application.storefrontfor the Next.js Starter storefront with Ticket Booking customizations.
- After cloning the repository, change to the
ticket-booking/medusadirectory:
cd examples/ticket-booking/medusa2. Rename the .env.template file to .env.
3. If necessary, change the PostgreSQL username, password, and host in the DATABASE_URL environment variable.
4. Install dependencies:
yarn # or npm install5. Setup and seed the database:
npx medusa db:setup
yarn seed # or npm run seed6. Start the Medusa application:
yarn dev # or npm run devIn the Medusa Admin, you can create a venue and a ticket product. If you run the Next.js Starter Storefront, you can purchase a ticket and receive an order confirmation email with the generated QR code for the ticket.
If you have an existing Medusa application, copy the content of the following directories:
src/modules/ticket-bookingsrc/workflowssrc/apisrc/adminsrc/subscriberssrc/links
Then, add the Ticket Booking Module to medusa-config.js:
module.exports = defineConfig({
// ...
modules: [
{
resolve: "./src/modules/ticket-booking",
},
]
})Next, run the database migrations to create the necessary tables for the Ticket Booking Module's data models and for the links:
npx medusa db:migrateThen, start the Medusa application:
yarn dev # or npm run devIn the Medusa Admin, you can create a venue and a ticket product. If you run the Next.js Starter Storefront, you can purchase a ticket and receive an order confirmation email with the generated QR code for the ticket.
To setup and run the Next.js Storefront:
- Change to the
ticket-booking/storefrontdirectory. - Copy
.env.templateto.env.localand set the following environment variable:
# Your Medusa application's publishable API key. See - https://docs.medusajs.com/resources/storefront-development/publishable-api-keys
NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY=pk_test3. Install the dependencies:
yarn install # or npm install4. Start the Next.js Starter Storefront (while the Medusa application is running):
yarn dev # or npm devIf you created ticket products in the Medusa application, you can browse them in the storefront, select show dates and seats to purchase, and place an order with your ticket selections.
- Medusa Documentation
- OpenAPI Spec file: Can be imported into tools like Postman to view and send requests to this project's API routes.