mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 08:30:39 +00:00
Improve Apps class to enforce required fields and improve title handling. Added validation for name and index URL, as they are mandatory for app creation. Updated title assignment to default to name if not provided.
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test (18.x) (push) Has been cancelled
test / test (20.x) (push) Has been cancelled
test / test (22.x) (push) Has been cancelled
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test (18.x) (push) Has been cancelled
test / test (20.x) (push) Has been cancelled
test / test (22.x) (push) Has been cancelled
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user