ConvoyPanel / panel

A modern platform tailored for hosting providers and enthusiasts to effortlessly interact with their servers. Seamlessly wrapping around Proxmox, Convoy is easily deployable, affordable at just $6 per node per month for commercial use, and completely free for personal and non-profit endeavors.
https://convoypanel.com
Other
308 stars 51 forks source link

Mark Fields as Unlimited Using '-1' Instead of Null #52

Open ericwang401 opened 7 months ago

ericwang401 commented 7 months ago

Is there an existing feature request for this?

Describe the feature you would like to see.

In the admin area for servers, administrators can give a server unlimited bandwidth by omitting any value (essentially null) from the bandwidth allocation field. This is a little tricky to implement internally as null is a very ambiguous value-can indicate that the request simply does not want to modify the bandwidth field.

It can also be extremely confusing if it is an optional field in an API request as null can mean if its optional or if its marked as unlimited, and this is virtually impossible to differentiate as a type in Typescript. For example, determine whether the type below indicates whether the admin wants the field to stay untouched or mark it as unlimited. (Don't say just use undefined because you should refrain from using undefined as much as possible).

type BandwidthAllocationParam = number | null | undefined

Describe the solution you'd like.

Instead of using null as an indicator for no limitation on a resource, it should be switched to -1 as it's a defined value and clearly indicates that a field is unlimited (because you cannot allocate negative resources).

Additional context to this request.

No response