# @mrapi/api 配置项
当前配置仅提供给 @mrapi/api 使用。
注意: 请先查看 mrapi 整体配置项说明
# 参数说明
// @mrapi/api config
api: {
// @mrapi/api openapi config
openapi: {
// @mrapi/api openapi custom api dir
dir: '/src/openapi',
// @mrapi/api openapi custom api preifx
prefix: '/api',
},
// @mrapi/api graphql config
graphql: {
// @mrapi/api graphql custom api dir
dir: '/src/graphql',
// @mrapi/api graphql api prefix
path: '/graphql',
// @mrapi/api graphql playground
playground: 'playground',
// @mrapi/api graphql sources
sources: [],
},
// @mrapi/api server config
server: {
// @mrapi/api server listen port
port: 1358,
// @mrapi/api server type
type: 'standalone',
// @mrapi/api fastify server options
options: {},
},
// @mrapi/api prisma schema names array
schemaNames: [],
// auto run scripts mrapi generate
autoGenerate: true,
// mrapi db choose header key
schemaIdentity: 'mrapi-schema',
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
tenantIdentity: String.默认值mrapi-pmt多租户在 header 中的 key 值api: Object. api 包配置api.schemaNames: Array.默认值[]type 为combined时需要加载的 schema 名称api.autoGenerate: Boolean.默认值true,是否根据根据api.schemaNames自定执行npx mrapi generate脚本(生产环境建议开启,开发环境在 db 变更后开启)api.schemaIdentity: String.默认值mrapi-db,dal 结合使用下,自定义 openapi 中 db 选择的 header keyapi.openapi: Object. openapi 相关配置api.openapi.dir: String.默认值/src/openapi自定义 openapi 存放目录api.openapi.prefix: String.默认值/api自定义 openapi 路由前缀api.graphql: Object. graphql 相关配置api.graphql.dir: String. 默认值/src/graphql自定义 graphql 文件目录api.graphql.path: String. 默认值/graphqlgraphql 访问路径,真实访问路径为${api.graphql.path}/:${schemaName},正则匹配 schemaName(决定 handler 上下文中的 prismaClient,standlone模式使用时${schemaName}请传default,确保路由能被命中)api.graphql.palyground: String|Boolean. 默认值palygroundgraphql palyground 地址,如果false则是关闭 playgroundapi.graphql.sources: Array. 默认值[]需要 mesh 的 graphql 源配置api.server: Object. server 服务相关配置api.server.port: Number. 默认值1358服务监听端口api.server.type: String. 默认值standaloneenum['standalone','combined']api 包使用模式['单独使用','结合 dal 使用']api.server.options: Object.默认值{}透传给 fastify 的 options