Files
backend/src/domain-admin/domain-admin.controller.ts
T
Alireza HassaniandCursor a9d5f2e48d Fix storefront SSL probes and per-domain ensure for dashboards.
Skip redundant provision on edit, harden TLS hostname checks, and issue apex/business/customer SSL from one endpoint.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-09 16:32:05 +03:30

98 lines
2.6 KiB
TypeScript

import {
Body,
Controller,
Delete,
Get,
HttpCode,
Param,
Patch,
Post,
Query,
UseGuards,
} from '@nestjs/common';
import { AuthUser } from '../auth/auth.types';
import { CurrentUser } from '../auth/decorators/current-user.decorator';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
import { DisableDomainDto } from './dto/disable-domain.dto';
import { ListDomainsDto } from './dto/list-domains.dto';
import { ToggleSslDto } from './dto/toggle-ssl.dto';
import { UpdateDomainAdminDto } from './dto/update-domain-admin.dto';
import { DomainAdminService } from './domain-admin.service';
@Controller('domains')
export class DomainAdminController {
constructor(private readonly service: DomainAdminService) {}
@Get()
@UseGuards(JwtAuthGuard)
list(@Query() query: ListDomainsDto, @CurrentUser() user: AuthUser) {
return this.service.list(query, user);
}
@Post('ssl-sync')
@HttpCode(202)
@UseGuards(JwtAuthGuard)
syncSsl(@CurrentUser() user: AuthUser) {
return this.service.syncSsl(user);
}
/** Issue Let's Encrypt for storefront domains missing SSL (websites VM). */
@Post('website-ssl')
@HttpCode(200)
@UseGuards(JwtAuthGuard)
issueWebsiteSsl(@CurrentUser() user: AuthUser) {
return this.service.issueWebsiteSsl(user);
}
@Post(':domainId/deploy')
@HttpCode(202)
@UseGuards(JwtAuthGuard)
deploy(@Param('domainId') domainId: string, @CurrentUser() user: AuthUser) {
return this.service.deploy(domainId, user);
}
/** Issue / renew Let's Encrypt for one domain: apex + business.* + customer.*. */
@Post(':domainId/issue-ssl')
@HttpCode(200)
@UseGuards(JwtAuthGuard)
issueSsl(@Param('domainId') domainId: string, @CurrentUser() user: AuthUser) {
return this.service.issueSsl(domainId, user);
}
@Patch(':domainId')
@UseGuards(JwtAuthGuard)
update(
@Param('domainId') domainId: string,
@Body() dto: UpdateDomainAdminDto,
@CurrentUser() user: AuthUser,
) {
return this.service.update(domainId, dto, user);
}
@Patch(':domainId/disable')
@UseGuards(JwtAuthGuard)
disable(
@Param('domainId') domainId: string,
@Body() dto: DisableDomainDto,
@CurrentUser() user: AuthUser,
) {
return this.service.disable(domainId, dto, user);
}
@Patch(':domainId/ssl')
@UseGuards(JwtAuthGuard)
toggleSsl(
@Param('domainId') domainId: string,
@Body() dto: ToggleSslDto,
@CurrentUser() user: AuthUser,
) {
return this.service.toggleSsl(domainId, dto, user);
}
@Delete(':domainId')
@UseGuards(JwtAuthGuard)
remove(@Param('domainId') domainId: string, @CurrentUser() user: AuthUser) {
return this.service.remove(domainId, user);
}
}