Skip to content

Commit 9c5be6e

Browse files
committed
chore: wip
1 parent 53aafd3 commit 9c5be6e

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

.stacks/core/actions/src/domains/purchase.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import process from 'node:process'
22
import { handleError } from '@stacksjs/error-handling'
3-
import { parseOptions } from '@stacksjs/cli'
3+
import { log, parseOptions } from '@stacksjs/cli'
44
import { ExitCode } from '@stacksjs/types'
5+
import { purchaseDomain } from '@stacksjs/cloud'
56

67
interface PurchaseOptions {
78
domain: string
@@ -91,11 +92,12 @@ if (!options.domain) {
9192
process.exit(ExitCode.FatalError)
9293
}
9394

94-
function purchaseDomain
95-
96-
const result = await purchaseDomain(options.domain)
95+
const result = purchaseDomain(options.domain, options)
9796

9897
if (result.isErr()) {
9998
handleError(result.error)
100-
process.exit(1)
99+
process.exit(ExitCode.FatalError)
101100
}
101+
102+
log.info(result.value)
103+
process.exit(ExitCode.Success)

.stacks/core/cloud/src/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { log } from '@stacksjs/cli'
2+
import { err, ok } from '@stacksjs/error-handling'
23
import aws from 'aws-sdk'
34

45
export * from './drivers'
@@ -44,10 +45,10 @@ interface PurchaseOptions {
4445
verbose?: boolean
4546
}
4647

47-
export function purchaseDomain(options: PurchaseOptions) {
48+
export function purchaseDomain(domain: string, options: PurchaseOptions) {
4849
const route53domains = new aws.Route53Domains({ region: 'us-east-1' })
4950
const params = {
50-
DomainName: options.domain,
51+
DomainName: domain,
5152
DurationInYears: options.years || 1,
5253
AutoRenew: options.autoRenew || true,
5354
AdminContact: {
@@ -94,10 +95,16 @@ export function purchaseDomain(options: PurchaseOptions) {
9495
PrivacyProtectTechContact: options.privacyTech || options.privacy || true,
9596
}
9697

97-
route53domains.registerDomain(params, (err, data) => {
98-
if (err)
99-
handleError(err, err.stack)
100-
else
101-
log.info(data)
98+
const result = route53domains.registerDomain(params, (error, data) => {
99+
if (error)
100+
return error
101+
102+
log.info(data)
103+
return data
102104
})
105+
106+
if (result instanceof Error)
107+
return err(result)
108+
109+
return ok(result)
103110
}

0 commit comments

Comments
 (0)