2024-06-11 13:16:15 +02:00
|
|
|
import Router from "@koa/router"
|
|
|
|
import Joi from "joi"
|
|
|
|
import { auth } from "@budibase/backend-core"
|
|
|
|
import * as controller from "../../controllers/global/tenant"
|
|
|
|
import cloudRestricted from "../../../middleware/cloudRestricted"
|
|
|
|
|
|
|
|
const router: Router = new Router()
|
|
|
|
const OPTIONAL_STRING = Joi.string().optional().allow(null).allow("")
|
|
|
|
|
|
|
|
function buildTenantInfoValidation() {
|
|
|
|
return auth.joiValidator.body(
|
|
|
|
Joi.object({
|
|
|
|
owner: Joi.object({
|
|
|
|
email: Joi.string().required(),
|
|
|
|
password: OPTIONAL_STRING,
|
|
|
|
ssoId: OPTIONAL_STRING,
|
|
|
|
givenName: OPTIONAL_STRING,
|
|
|
|
familyName: OPTIONAL_STRING,
|
|
|
|
budibaseUserId: OPTIONAL_STRING,
|
|
|
|
}).required(),
|
2024-06-17 11:22:44 +02:00
|
|
|
hosting: Joi.string().required(),
|
2024-06-11 13:16:15 +02:00
|
|
|
tenantId: Joi.string().required(),
|
|
|
|
}).required()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-06-17 11:22:44 +02:00
|
|
|
router
|
|
|
|
.post(
|
|
|
|
"/api/global/tenant",
|
|
|
|
cloudRestricted,
|
|
|
|
buildTenantInfoValidation(),
|
|
|
|
controller.save
|
|
|
|
)
|
|
|
|
.get("/api/global/tenant/:id", controller.get)
|
2024-06-11 13:16:15 +02:00
|
|
|
|
|
|
|
export default router
|