* Creates a new app definition. * * @param appName The appName you want to register * @param hasPersistentData whether the app has persistent data, you can only run one instance of the app. * @returns {Promise}
(
appName: string,
projectId: string | undefined,
hasPersistentData: boolean
)
| 879 | * @returns {Promise} |
| 880 | */ |
| 881 | registerAppDefinition( |
| 882 | appName: string, |
| 883 | projectId: string | undefined, |
| 884 | hasPersistentData: boolean |
| 885 | ) { |
| 886 | const self = this |
| 887 | |
| 888 | return new Promise<IAppDef>(function (resolve, reject) { |
| 889 | if (!isNameAllowed(appName)) { |
| 890 | reject( |
| 891 | ApiStatusCodes.createError( |
| 892 | ApiStatusCodes.STATUS_ERROR_BAD_NAME, |
| 893 | 'App Name is not allowed. Only lowercase letters and single hyphens are allowed' |
| 894 | ) |
| 895 | ) |
| 896 | return |
| 897 | } |
| 898 | |
| 899 | if (self.data.get(`${APP_DEFINITIONS}.${appName}`)) { |
| 900 | reject( |
| 901 | ApiStatusCodes.createError( |
| 902 | ApiStatusCodes.STATUS_ERROR_ALREADY_EXIST, |
| 903 | 'App Name already exists. Please use a different name' |
| 904 | ) |
| 905 | ) |
| 906 | return |
| 907 | } |
| 908 | |
| 909 | const defaultAppDefinition: IAppDef = { |
| 910 | hasPersistentData: !!hasPersistentData, |
| 911 | projectId: projectId, |
| 912 | description: '', |
| 913 | instanceCount: 1, |
| 914 | captainDefinitionRelativeFilePath: |
| 915 | CaptainConstants.defaultCaptainDefinitionPath, |
| 916 | networks: [CaptainConstants.captainNetworkName], |
| 917 | envVars: [], |
| 918 | volumes: [], |
| 919 | ports: [], |
| 920 | tags: [], |
| 921 | versions: [], |
| 922 | deployedVersion: 0, |
| 923 | notExposeAsWebApp: false, |
| 924 | customDomain: [], |
| 925 | hasDefaultSubDomainSsl: false, |
| 926 | redirectDomain: '', |
| 927 | forceSsl: false, |
| 928 | websocketSupport: false, |
| 929 | } |
| 930 | |
| 931 | resolve(defaultAppDefinition) |
| 932 | }).then(function (app) { |
| 933 | return self.saveApp(appName, app) |
| 934 | }) |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | export default AppsDataStore |
no test coverage detected