"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = require("express");
const client_1 = require("@prisma/client");
const router = (0, express_1.Router)();
const prisma = new client_1.PrismaClient();
// Get all tenants
router.get('/', async (req, res) => {
    try {
        const tenants = await prisma.tenant.findMany({
            include: { devices: true }
        });
        res.json(tenants);
    }
    catch (error) {
        res.status(500).json({ error: 'Internal server error' });
    }
});
// Create tenant
router.post('/', async (req, res) => {
    try {
        const { name } = req.body;
        const newTenant = await prisma.tenant.create({
            data: { name },
        });
        res.status(201).json(newTenant);
    }
    catch (error) {
        res.status(500).json({ error: 'Internal server error' });
    }
});
exports.default = router;
