Skip to content

Commit

Permalink
chore: update url schema roles
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Jan 29, 2022
1 parent 25b251c commit 88a9dd2
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion packages/koishi/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ declare module '@koishijs/core' {
defineProperty(App.Config, 'Network', Schema.object({
host: Schema.string().default('localhost').description('要监听的 IP 地址。如果将此设置为 `0.0.0.0` 将监听所有地址,包括局域网和公网地址。'),
port: Schema.number().description('要监听的端口。'),
selfUrl: Schema.string().description('应用暴露在公网的地址。部分插件 (例如 github 和 telegram) 需要用到。'),
selfUrl: Schema.string().role('url').description('应用暴露在公网的地址。部分插件 (例如 github 和 telegram) 需要用到。'),
}).description('网络设置'))

App.Config.list.unshift(App.Config.Network)
Expand Down
2 changes: 1 addition & 1 deletion plugins/adapter/onebot/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class HttpServer extends Adapter<BotConfig, AdapterConfig> {
static schema: Schema<BotConfig> = Schema.object({
selfId: Schema.string().description('机器人的账号。').required(),
token: Schema.string().description('发送信息时用于验证的字段,应与 OneBot 配置文件中的 access_token 保持一致。').role('secret'),
endpoint: Schema.string().description('要连接的 OneBot 服务器地址。').required(),
endpoint: Schema.string().role('url').description('要连接的 OneBot 服务器地址。').required(),
...omit(Quester.Config.dict, ['endpoint']),
})

Expand Down
2 changes: 1 addition & 1 deletion plugins/adapter/onebot/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class WebSocketClient extends Adapter.WebSocketClient<BotConfig, AdapterC
static schema: Schema<BotConfig> = Schema.object({
selfId: Schema.string().description('机器人的账号。').required(),
token: Schema.string().description('发送信息时用于验证的字段,应与 OneBot 的 access_token 配置保持一致。').role('secret'),
endpoint: Schema.string().description('要连接的 OneBot 服务器地址。').required(),
endpoint: Schema.string().role('url').description('要连接的 OneBot 服务器地址。').required(),
})

protected accept = accept
Expand Down
4 changes: 2 additions & 2 deletions plugins/adapter/qqguild/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const AdapterConfig: Schema<AdapterConfig> = Schema.intersect([
sandbox: Schema.boolean()
.description('是否开启沙盒')
.default(true),
endpoint: Schema.string()
.description('api 入口地址')
endpoint: Schema.string().role('url')
.description('API 入口地址')
.default('https://api.sgroup.qq.com/'),
authType: Schema.union(['bot', 'bearer'])
.description('验证方式')
Expand Down
2 changes: 1 addition & 1 deletion plugins/adapter/telegram/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export interface AdapterConfig extends App.Config.Request {

export const AdapterConfig: Schema<AdapterConfig> = Schema.object({
path: Schema.string().description('服务器监听的路径。').default('/telegram'),
selfUrl: Schema.string().description('Koishi 服务暴露在公网的地址。缺省时将使用全局配置。'),
selfUrl: Schema.string().role('url').description('Koishi 服务暴露在公网的地址。缺省时将使用全局配置。'),
})
14 changes: 4 additions & 10 deletions plugins/assets/local/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { Assets, Context, sanitize, trimSlash, Schema } from 'koishi'
import { promises as fs, createReadStream, existsSync } from 'fs'
import { promises as fs, createReadStream } from 'fs'
import { extname, resolve, basename } from 'path'
import { createHmac, createHash } from 'crypto'

declare module 'koishi' {
interface Modules {
'assets-local': typeof import('.')
}
}
import { createHmac } from 'crypto'

class LocalAssets extends Assets {
private _promise: Promise<void>
Expand Down Expand Up @@ -107,8 +101,8 @@ namespace LocalAssets {

export const Config = Schema.object({
root: Schema.string().description('本地存储资源文件的绝对路径。'),
path: Schema.string().description('静态图片暴露在服务器的路径。').default('/assets'),
selfUrl: Schema.string().description('Koishi 服务暴露在公网的地址。缺省时将使用全局配置。'),
path: Schema.string().default('/files').description('静态图片暴露在服务器的路径。'),
selfUrl: Schema.string().role('url').description('Koishi 服务暴露在公网的地址。缺省时将使用全局配置。'),
secret: Schema.string().description('用于验证上传者的密钥,配合 assets-remote 使用。').role('secret'),
})
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/assets/remote/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace RemoteAssets {
}

export const Config = Schema.object({
endpoint: Schema.string().description('远程服务器地址。').required(),
endpoint: Schema.string().role('url').description('远程服务器地址。').required(),
secret: Schema.string().description('服务器设置的密钥,配合 assets-local 使用。').role('secret'),
})
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/assets/s3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ namespace S3Assets {

export const Config = Schema.object({
region: Schema.string().default('none'),
endpoint: Schema.string(),
endpoint: Schema.string().role('url'),
credentials: Credentials,
bucket: Schema.string().required(),
pathPrefix: Schema.string().default(''),
Expand Down
2 changes: 1 addition & 1 deletion plugins/frontend/console/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export namespace Console {
export const Config = Schema.object({
uiPath: Schema.string().description('前端页面呈现的路径。').default(''),
apiPath: Schema.string().description('后端 API 服务的路径。').default('/status'),
selfUrl: Schema.string().description('Koishi 服务暴露在公网的地址。').comment('与其他需要 selfUrl 配置项的地方不同的是,这里的属性不会继承 app.options.selfUrl 的值。这是因为,由于这里缺省时会使用相对路径,网页依旧可以正常访问。只有你将 uiPath 和 apiPath 分别部署到了不同的端口或域名时,这个选项才建议使用。').default(''),
selfUrl: Schema.string().description('Koishi 服务暴露在公网的地址。').role('url').comment('与其他需要 selfUrl 配置项的地方不同的是,这里的属性不会继承 app.options.selfUrl 的值。这是因为,由于这里缺省时会使用相对路径,网页依旧可以正常访问。只有你将 uiPath 和 apiPath 分别部署到了不同的端口或域名时,这个选项才建议使用。').default(''),
open: Schema.boolean().description('在应用启动后自动在浏览器中打开控制台。'),
devMode: Schema.boolean().description('启用调试模式(仅供开发者使用)。').hidden(),
})
Expand Down

0 comments on commit 88a9dd2

Please sign in to comment.