- Enhanced event creation wizard with multi-step validation - Added advanced QR scanning system with offline support - Implemented comprehensive territory management features - Expanded analytics with export functionality and KPIs - Created complete design token system with theme switching - Added 25+ Playwright test files for comprehensive coverage - Implemented enterprise-grade permission system - Enhanced component library with 80+ React components - Added Firebase integration for deployment - Completed Phase 3 development goals substantially 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
125 lines
4.1 KiB
JavaScript
125 lines
4.1 KiB
JavaScript
"use strict";
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.api = void 0;
|
|
const https_1 = require("firebase-functions/v2/https");
|
|
const express_1 = __importDefault(require("express"));
|
|
const cors_1 = __importDefault(require("cors"));
|
|
const app = (0, express_1.default)();
|
|
// CORS: allow hosting origins + dev
|
|
const allowedOrigins = [
|
|
// Firebase Hosting URLs for dev-racer-433015-k3 project
|
|
"https://dev-racer-433015-k3.web.app",
|
|
"https://dev-racer-433015-k3.firebaseapp.com",
|
|
// Development servers
|
|
"http://localhost:5173", // Vite dev server
|
|
"http://localhost:4173", // Vite preview
|
|
"http://localhost:3000", // Common dev port
|
|
];
|
|
app.use((0, cors_1.default)({
|
|
origin: (origin, callback) => {
|
|
// Allow requests with no origin (mobile apps, curl, etc.)
|
|
if (!origin)
|
|
return callback(null, true);
|
|
if (allowedOrigins.includes(origin)) {
|
|
return callback(null, true);
|
|
}
|
|
return callback(new Error('Not allowed by CORS'));
|
|
},
|
|
credentials: true
|
|
}));
|
|
app.use(express_1.default.json({ limit: "2mb" }));
|
|
app.use(express_1.default.urlencoded({ extended: true }));
|
|
// Health check endpoint
|
|
app.get("/health", (req, res) => {
|
|
res.json({
|
|
status: "ok",
|
|
timestamp: new Date().toISOString(),
|
|
version: "1.0.0",
|
|
message: "API is running"
|
|
});
|
|
});
|
|
// Mock ticket verification endpoint
|
|
app.post("/tickets/verify", (req, res) => {
|
|
const { qr } = req.body;
|
|
if (!qr) {
|
|
return res.status(400).json({ error: "QR code is required" });
|
|
}
|
|
// Mock response for demo
|
|
return res.json({
|
|
valid: true,
|
|
ticket: {
|
|
id: "demo-ticket-001",
|
|
eventId: "demo-event-001",
|
|
ticketTypeId: "demo-type-001",
|
|
eventName: "Demo Event",
|
|
ticketTypeName: "General Admission",
|
|
status: "valid",
|
|
purchaserEmail: "demo@example.com"
|
|
}
|
|
});
|
|
});
|
|
// Mock checkout endpoint
|
|
app.post("/checkout/create", (req, res) => {
|
|
const { orgId, eventId, ticketTypeId, qty } = req.body;
|
|
if (!orgId || !eventId || !ticketTypeId || !qty) {
|
|
return res.status(400).json({ error: "Missing required fields" });
|
|
}
|
|
// Mock Stripe checkout session
|
|
return res.json({
|
|
id: "cs_test_demo123",
|
|
url: "https://checkout.stripe.com/pay/cs_test_demo123#fidkdWxOYHwnPyd1blppbHNgWjA0VGlgNG41PDVUc0t8Zn0xQnVTSDc2N01ocGRnVH1KMjZCMX9pPUBCZzJpPVE2TnQ3U1J%2FYmFRPTVvSU1qZW9EV1IzTmBAQkxmdFNncGNyZmU0Z0I9NV9WPT0nKSd3YGNgd3dgd0p3bGZsayc%2FcXdwYHgl"
|
|
});
|
|
});
|
|
// Mock Stripe Connect endpoints
|
|
app.post("/stripe/connect/start", (req, res) => {
|
|
const { orgId } = req.body;
|
|
if (!orgId) {
|
|
return res.status(400).json({ error: "Organization ID is required" });
|
|
}
|
|
return res.json({
|
|
url: "https://connect.stripe.com/oauth/authorize?response_type=code&client_id=ca_demo&scope=read_write"
|
|
});
|
|
});
|
|
app.get("/stripe/connect/status", (req, res) => {
|
|
const orgId = req.query.orgId;
|
|
if (!orgId) {
|
|
return res.status(400).json({ error: "Organization ID is required" });
|
|
}
|
|
return res.json({
|
|
connected: false,
|
|
accountId: null,
|
|
chargesEnabled: false,
|
|
detailsSubmitted: false
|
|
});
|
|
});
|
|
// Catch-all for unmatched routes
|
|
app.use("*", (req, res) => {
|
|
res.status(404).json({
|
|
error: "Not found",
|
|
path: req.originalUrl,
|
|
availableEndpoints: [
|
|
"GET /api/health",
|
|
"POST /api/tickets/verify",
|
|
"POST /api/checkout/create",
|
|
"POST /api/stripe/connect/start",
|
|
"GET /api/stripe/connect/status"
|
|
]
|
|
});
|
|
});
|
|
// Error handling middleware
|
|
app.use((error, req, res, next) => {
|
|
console.error('Express error:', error);
|
|
res.status(500).json({
|
|
error: 'Internal server error',
|
|
message: error.message
|
|
});
|
|
});
|
|
exports.api = (0, https_1.onRequest)({
|
|
region: "us-central1",
|
|
maxInstances: 10,
|
|
cors: true
|
|
}, app);
|
|
//# sourceMappingURL=api-simple.js.map
|