File tree Expand file tree Collapse file tree 3 files changed +31
-20
lines changed
src/routes/(console)/project-[region]-[project]
functions/function-[function]/domains/add-domain
settings/domains/add-domain
sites/site-[site]/domains/add-domain Expand file tree Collapse file tree 3 files changed +31
-20
lines changed Original file line number Diff line number Diff line change 48
48
49
49
async function addDomain() {
50
50
const apexDomain = getApexDomain (domainName );
51
- let domain = data .domains ?.domains .find ((d ) => d .domain === apexDomain );
51
+ let domain = data .domains ?.domains .find ((d : Models . Domain ) => d .domain === apexDomain );
52
52
53
53
if (apexDomain && ! domain && isCloud ) {
54
54
try {
55
55
domain = await sdk .forConsole .domains .create ($project .teamId , apexDomain );
56
56
} catch (error ) {
57
- addNotification ({
58
- type: ' error' ,
59
- message: error .message
60
- });
61
-
62
- return ;
57
+ // apex might already be added on organization level, skip.
58
+ const alreadyAdded = error ?.type === ' domain_already_exists' ;
59
+ if (! alreadyAdded ) {
60
+ addNotification ({
61
+ type: ' error' ,
62
+ message: error .message
63
+ });
64
+ return ;
65
+ }
63
66
}
64
67
}
65
68
Original file line number Diff line number Diff line change 12
12
import { isCloud } from ' $lib/system' ;
13
13
import { project } from ' $routes/(console)/project-[region]-[project]/store' ;
14
14
import { getApexDomain } from ' $lib/helpers/tlds' ;
15
+ import type { Models } from ' @appwrite.io/console' ;
15
16
16
17
const routeBase = ` ${base }/project-${page .params .region }-${page .params .project }/settings/domains ` ;
17
18
29
30
30
31
async function addDomain() {
31
32
const apexDomain = getApexDomain (domainName );
32
- let domain = data .domains ?.domains .find ((d ) => d .domain === apexDomain );
33
+ let domain = data .domains ?.domains .find ((d : Models . Domain ) => d .domain === apexDomain );
33
34
34
35
if (apexDomain && ! domain && isCloud ) {
35
36
try {
36
37
domain = await sdk .forConsole .domains .create ($project .teamId , apexDomain );
37
38
} catch (error ) {
38
- addNotification ({
39
- type: ' error' ,
40
- message: error .message
41
- });
42
-
43
- return ;
39
+ // apex might already be added on organization level, skip.
40
+ const alreadyAdded = error ?.type === ' domain_already_exists' ;
41
+ if (! alreadyAdded ) {
42
+ addNotification ({
43
+ type: ' error' ,
44
+ message: error .message
45
+ });
46
+ return ;
47
+ }
44
48
}
45
49
}
46
50
Original file line number Diff line number Diff line change 53
53
54
54
async function addDomain() {
55
55
const apexDomain = getApexDomain (domainName );
56
- let domain = data .domains ?.domains .find ((d ) => d .domain === apexDomain );
56
+ let domain = data .domains ?.domains .find ((d : Models . Domain ) => d .domain === apexDomain );
57
57
58
58
if (apexDomain && ! domain && isCloud ) {
59
59
try {
60
60
domain = await sdk .forConsole .domains .create ($project .teamId , apexDomain );
61
61
} catch (error ) {
62
- addNotification ({
63
- type: ' error' ,
64
- message: error .message
65
- });
66
- return ;
62
+ // apex might already be added on organization level, skip.
63
+ const alreadyAdded = error ?.type === ' domain_already_exists' ;
64
+ if (! alreadyAdded ) {
65
+ addNotification ({
66
+ type: ' error' ,
67
+ message: error .message
68
+ });
69
+ return ;
70
+ }
67
71
}
68
72
}
69
73
You can’t perform that action at this time.
0 commit comments