-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Update types + optional
server
and metrics
fields
- Loading branch information
1 parent
5bbb35f
commit 756d261
Showing
6 changed files
with
98 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@konfeature/erpc-config-generator": patch | ||
--- | ||
|
||
Optional `server` and `metrics` field in the root config object + generation info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@konfeature/erpc-config-generator": patch | ||
--- | ||
|
||
Update erpc types for erpc `v0.0.18` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
import type { Config } from "./generatedTypes/erpcTypes"; | ||
import type { | ||
Config, | ||
MetricsConfig, | ||
ServerConfig, | ||
} from "./generatedTypes/erpcTypes"; | ||
import type { OptionalField } from "./types/utils"; | ||
|
||
type ConfigWithOptionalServer = Omit<Config, "server" | "metrics"> & { | ||
server?: OptionalField< | ||
ServerConfig, | ||
"httpPort" | "httpHostV4" | "httpHostV6" | ||
>; | ||
metrics?: OptionalField<MetricsConfig, "port" | "hostV4" | "hostV6">; | ||
}; | ||
|
||
// Default config for metrics and server | ||
const defaultServerConfig = { | ||
httpPort: 4000, | ||
httpHostV4: "0.0.0.0", | ||
httpHostV6: "[::]", | ||
}; | ||
const defaultMetricsCofnig = { | ||
port: 4001, | ||
hostV4: "0.0.0.0", | ||
hostV6: "[::]", | ||
}; | ||
|
||
/** | ||
* Build the globel erpc config | ||
*/ | ||
export function buildErpcConfig({ config }: { config: Config }) { | ||
return config; | ||
export function buildErpcConfig({ | ||
config, | ||
}: { config: ConfigWithOptionalServer }) { | ||
return { | ||
...config, | ||
server: config?.server | ||
? { ...defaultServerConfig, ...config.server } | ||
: undefined, | ||
metrics: config?.metrics | ||
? { ...defaultMetricsCofnig, ...config.metrics } | ||
: undefined, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters