Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/deployment-service/src/dns/dns.controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const mockPipelineProvider = {
}),
),
update: jest.fn((pipeline) => Promise.resolve(pipeline)),
findByDomain: jest.fn(() => Promise.resolve(null)),
}

const mockDnsProvider = {
Expand Down
6 changes: 5 additions & 1 deletion packages/deployment-service/src/dns/dns.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ export class DnsController {

this.ownershipProvider.check(pipeline, creds.developerId as string)

const domainExists = await this.pipelineProvider.findByDomain(body.customDomain)

if (domainExists) throw new UnprocessableEntityException()

const verifyDnsName = 'reapit-iaas'
const verifyDnsValue = uuid()

await this.pipelineProvider.update(pipeline, {
customDomain: body.customDomain, // TODO should strip everything not a domain? query params example
customDomain: body.customDomain,
verifyDnsValue,
verifyDnsName,
})
Expand Down
6 changes: 6 additions & 0 deletions packages/deployment-service/src/pipeline/pipeline-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,10 @@ export class PipelineProvider {
relations: ['repository'],
})
}

async findByDomain(customDomain: string): Promise<PipelineEntity | null> {
return this.repository.findOneBy({
customDomain,
})
}
}