MCPcopy
hub / github.com/caprover/caprover / saveApp

Method saveApp

src/datastore/AppsDataStore.ts:56–214  ·  view source on GitHub ↗
(appName: string, app: IAppDef)

Source from the content-addressed store, hash-verified

54 }
55
56 private saveApp(appName: string, app: IAppDef) {
57 const self = this
58
59 return Promise.resolve()
60 .then(function () {
61 if (!appName) {
62 throw ApiStatusCodes.createError(
63 ApiStatusCodes.STATUS_ERROR_GENERIC,
64 'App Name should not be empty'
65 )
66 }
67
68 if (app.forceSsl) {
69 let hasAtLeastOneSslDomain = app.hasDefaultSubDomainSsl
70 const customDomainArray = app.customDomain
71 if (customDomainArray && customDomainArray.length > 0) {
72 for (
73 let idx = 0;
74 idx < customDomainArray.length;
75 idx++
76 ) {
77 if (customDomainArray[idx].hasSsl) {
78 hasAtLeastOneSslDomain = true
79 }
80 }
81 }
82
83 if (!hasAtLeastOneSslDomain) {
84 throw ApiStatusCodes.createError(
85 ApiStatusCodes.ILLEGAL_OPERATION,
86 'Cannot force SSL without at least one SSL-enabled domain!'
87 )
88 }
89 }
90
91 if (app.envVars) {
92 for (let i = 0; i < app.envVars.length; i++) {
93 const element = app.envVars[i]
94 if (!element.key) {
95 throw ApiStatusCodes.createError(
96 ApiStatusCodes.STATUS_ERROR_GENERIC,
97 'Environmental Variable key is empty!'
98 )
99 }
100 }
101 }
102
103 if (app.ports) {
104 for (let i = 0; i < app.ports.length; i++) {
105 const obj = app.ports[i]
106 if (obj.containerPort && obj.hostPort) {
107 const containerPort = Number(obj.containerPort)
108 const hostPort = Number(obj.hostPort)
109
110 if (
111 !isPortValid(containerPort) ||
112 !isPortValid(hostPort)
113 ) {

Calls 4

isPortValidFunction · 0.85
createErrorMethod · 0.80
encryptMethod · 0.80
isNameAllowedFunction · 0.70

Tested by

no test coverage detected