Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './node/config'
export { createDevToolsContext } from './node/context'
export { DevTools } from './node/plugins'
export { createDevToolsMiddleware } from './node/server'
35 changes: 35 additions & 0 deletions packages/core/src/node/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { StartOptions } from './cli-commands'
import { isObject } from './utils'

export interface DevToolsConfig extends Partial<StartOptions> {
enabled: boolean
Comment thread
webfansplz marked this conversation as resolved.
/**
* Disable client authentication.
*
* Beware that if you disable client authentication,
* any browsers can connect to the devtools and access to your server and filesystem.
* (including other devices, if you open server `host` option to LAN or WAN)
*
* @default true
*/
clientAuth?: boolean
}

export interface ResolvedDevToolsConfig {
config: Omit<DevToolsConfig, 'enabled'> & { host: string }
enabled: boolean
}

export function normalizeDevToolsConfig(
config: DevToolsConfig | boolean | undefined,
host: string,
): ResolvedDevToolsConfig {
return {
enabled: config === true || !!(config && config.enabled),
config: {
...(isObject(config) ? config : {}),
clientAuth: isObject(config) ? config.clientAuth : true,
Comment thread
webfansplz marked this conversation as resolved.
Outdated
host: isObject(config) ? (config?.host ?? host) : host,
Comment thread
webfansplz marked this conversation as resolved.
Outdated
Comment thread
webfansplz marked this conversation as resolved.
Outdated
},
}
}
Comment thread
webfansplz marked this conversation as resolved.
3 changes: 3 additions & 0 deletions packages/core/src/node/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function isObject(value: unknown): value is Record<string, any> {
return Object.prototype.toString.call(value) === '[object Object]'
}
Comment thread
webfansplz marked this conversation as resolved.
Loading