mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 04:23:40 +00:00
chore: Update the sdk to match the rust and vica verse
This commit is contained in:
@@ -59,12 +59,13 @@ type AddSslOptions = {
|
||||
preferredExternalPort: number
|
||||
addXForwardedHeaders: boolean | null /** default: false */
|
||||
}
|
||||
type Security = { secure: false; ssl: false } | { secure: true; ssl: boolean }
|
||||
type Security = { ssl: boolean }
|
||||
export type BindOptions = {
|
||||
scheme: Scheme
|
||||
preferredExternalPort: number
|
||||
addSsl: AddSslOptions | null
|
||||
} & Security
|
||||
secure: Security | null
|
||||
}
|
||||
type KnownProtocols = typeof knownProtocols
|
||||
type ProtocolsWithSslVariants = {
|
||||
[K in keyof KnownProtocols]: KnownProtocols[K] extends {
|
||||
@@ -79,14 +80,15 @@ type NotProtocolsWithSslVariants = Exclude<
|
||||
>
|
||||
|
||||
type BindOptionsByKnownProtocol =
|
||||
| ({
|
||||
| {
|
||||
protocol: ProtocolsWithSslVariants
|
||||
preferredExternalPort?: number
|
||||
preferredExternalPort: number | null
|
||||
scheme: Scheme | null
|
||||
} & ({ noAddSsl: true } | { addSsl?: Partial<AddSslOptions> }))
|
||||
addSsl: Partial<AddSslOptions> | null
|
||||
}
|
||||
| {
|
||||
protocol: NotProtocolsWithSslVariants
|
||||
preferredExternalPort?: number
|
||||
preferredExternalPort: number | null
|
||||
scheme: Scheme | null
|
||||
addSsl: AddSslOptions | null
|
||||
}
|
||||
@@ -120,17 +122,12 @@ export class Host {
|
||||
|
||||
private async bindPortForUnknown(
|
||||
internalPort: number,
|
||||
options:
|
||||
| ({
|
||||
scheme: Scheme
|
||||
preferredExternalPort: number
|
||||
addSsl: AddSslOptions | null
|
||||
} & { secure: false; ssl: false })
|
||||
| ({
|
||||
scheme: Scheme
|
||||
preferredExternalPort: number
|
||||
addSsl: AddSslOptions | null
|
||||
} & { secure: true; ssl: boolean }),
|
||||
options: {
|
||||
scheme: Scheme
|
||||
preferredExternalPort: number
|
||||
addSsl: AddSslOptions | null
|
||||
secure: { ssl: boolean } | null
|
||||
},
|
||||
) {
|
||||
await this.options.effects.bind({
|
||||
kind: this.options.kind,
|
||||
@@ -154,18 +151,13 @@ export class Host {
|
||||
knownProtocols[options.protocol].defaultPort
|
||||
const addSsl = this.getAddSsl(options, protoInfo)
|
||||
|
||||
const security: Security = !protoInfo.secure
|
||||
? {
|
||||
secure: protoInfo.secure,
|
||||
ssl: protoInfo.ssl,
|
||||
}
|
||||
: { secure: false, ssl: false }
|
||||
const secure: Security | null = !protoInfo.secure ? null : { ssl: false }
|
||||
|
||||
const newOptions = {
|
||||
scheme,
|
||||
preferredExternalPort,
|
||||
addSsl,
|
||||
...security,
|
||||
secure,
|
||||
}
|
||||
|
||||
await this.options.effects.bind({
|
||||
|
||||
Reference in New Issue
Block a user