diff --git a/src/puter-js/src/modules/Apps.js b/src/puter-js/src/modules/Apps.js index ccc943ebe..212c8b93e 100644 --- a/src/puter-js/src/modules/Apps.js +++ b/src/puter-js/src/modules/Apps.js @@ -69,11 +69,14 @@ class Apps{ // * allows for: puter.apps.new({name: 'example-app', indexURL: 'https://example.com'}) * else if (typeof args[0] === 'object' && args[0] !== null) { let options_raw = args[0]; + options = { object: { name: options_raw.name, index_url: options_raw.indexURL, - title: options_raw.title, + // title is optional only if name is provided. + // If title is provided, use it. If not, use name. + title: options_raw.title ?? options_raw.name, description: options_raw.description, icon: options_raw.icon, maximize_on_start: options_raw.maximizeOnStart, @@ -86,6 +89,27 @@ class Apps{ } }; } + + // name and indexURL are required + if(!options.object.name){ + throw { + success: false, + error: { + code: 'invalid_request', + message: 'Name is required' + } + }; + } + if(!options.object.index_url){ + throw { + success: false, + error: { + code: 'invalid_request', + message: 'Index URL is required' + } + }; + } + // Call the original chat.complete method return await utils.make_driver_method(['object'], 'puter-apps', undefined, 'create').call(this, options); }