diff --git a/packages/core/src/env-set/GlobalValues.ts b/packages/core/src/env-set/GlobalValues.ts index 74c2be213..4d4d63c17 100644 --- a/packages/core/src/env-set/GlobalValues.ts +++ b/packages/core/src/env-set/GlobalValues.ts @@ -27,6 +27,11 @@ export default class GlobalValues { * - Admin Console will NOT be served under admin tenant since the cloud service will do. * - Incoming requests will use glob matching to parse the tenant ID from the request URL. * + * ```ts + * // ENDPOINT='https://*.domain.com' + * getTenantEndpoint('foo') => 'https://foo.domain.com' + * ``` + * * **When DBMT is disabled** * * - For non-admin tenants, tenant endpoint will always be `urlSet.endpoint`. @@ -51,6 +56,27 @@ export default class GlobalValues { /** @see urlSet For detailed explanation. */ public readonly isDomainBasedMultiTenancy = this.urlSet.endpoint.hostname.includes('*'); + /** + * This value indicates path-based multi-tenancy (PBMT) is enabled by setting env variable `PATH_BASED_MULTI_TENANCY` to a truthy value. + * + * Note the value will always be `false` if domain-based multi-tenancy is enabled. + * + * **When PBMT is enabled** + * + * - For non-admin tenants, tenant endpoint will be generated by appending the tenant ID to `urlSet.endpoint`. + * - For admin tenant, if `adminUrlSet` has no endpoint available, tenant endpoint will be generated by appending the tenant ID to `urlSet.endpoint`. + * - Admin Console will NOT be served under admin tenant since the cloud service will do. + * - Incoming requests will try to match the position of pathname segments of the URLs in `urlSet.deduplicated()` to parse the tenant ID from the request URL. + * + * ```ts + * // ENDPOINT='https://domain.com/foo' + * getTenantEndpoint('bar') => 'https://domain.com/foo/bar' + * matchTenantId('https://domain.com/foo/bar') => 'bar' + * matchTenantId('http://localhost:3001/foo/bar') => 'foo' + * ``` + * + * @see urlSet + */ public readonly isPathBasedMultiTenancy = !this.isDomainBasedMultiTenancy && yes(getEnv('PATH_BASED_MULTI_TENANCY'));