Skip to content

Commit

Permalink
feat: 自定义评论所用 db 名
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed Aug 25, 2022
1 parent 0874a85 commit 1723fe6
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Expand Up @@ -75,6 +75,7 @@ ENV VAN_BLOG_SERVER_URL "http://127.0.0.1:3000"
ENV VAN_BLOG_ALLOW_DOMAINS "pic.mereith.com"
ENV VAN_BLOG_CDN_URL "https://www.mereith.com"
ENV EMAIL "vanblog@mereith.com"
ENV VAN_BLOG_WALINE_DB "waline"
# 复制静态文件
WORKDIR /app/admin
COPY --from=ADMIN_BUILDER /usr/src/app/dist/ ./
Expand Down
2 changes: 2 additions & 0 deletions docker-compose/docker-compose.yml
Expand Up @@ -18,6 +18,8 @@ services:
VAN_BLOG_JWT_SECRET: "AnyString"
# 邮箱地址,用于自动申请 https 证书
EMAIL: "someone@mereith.com"
# 内嵌评论系统的 db 名,默认为 waline
VAN_BLOG_WALINE_DB: "waline"
volumes:
# 图床文件的存放地址,按需修改。
- ${PWD}/data/static:/app/static
Expand Down
2 changes: 2 additions & 0 deletions docs/guide/docker.md
Expand Up @@ -54,6 +54,8 @@ services:
VAN_BLOG_JWT_SECRET: "AnyString"
# 邮箱地址,用于自动申请 https 证书
EMAIL: "someone@mereith.com"
# 内嵌评论系统的 db 名,默认为 waline
VAN_BLOG_WALINE_DB: "waline"
volumes:
# 图床文件的存放地址,按需修改。
- ${PWD}/data/static:/app/static
Expand Down
15 changes: 8 additions & 7 deletions docs/ref/env.md
Expand Up @@ -7,13 +7,14 @@ icon: async

## 环境变量

| 名称 | 必填 | 说明 | 默认值 |
| ------------------------ | ---- | -------------------------------- | ---------------------------------------------------- |
| VAN_BLOG_DATABASE_URL || mongoDB URL | `mongodb://localhost:27017/vanBlog?authSource=admin` |
| VAN_BLOG_ALLOW_DOMAINS || 允许的外部图片域名 | `""` |
| VAN_BLOG_JWT_SECRET || 后端 JWT 密钥 | `boynextdoor` |
| VAN_BLOG_CDN_URL || CDN 部署的 url,不用的话不写也行 | `""` |
| EMAIL || 用于自动申请 https 证书的邮箱 | `""` |
| 名称 | 必填 | 说明 | 默认值 |
| ---------------------- | ---- | ----------------------------------- | ---------------------------------------------------- |
| VAN_BLOG_DATABASE_URL || mongoDB URL | `mongodb://localhost:27017/vanBlog?authSource=admin` |
| VAN_BLOG_ALLOW_DOMAINS || 允许的外部图片域名 | `""` |
| VAN_BLOG_JWT_SECRET || 后端 JWT 密钥 | `boynextdoor` |
| VAN_BLOG_CDN_URL || CDN 部署的 url,不用的话不写也行 | `""` |
| VAN_BLOG_WALINE_DB || 内嵌评论系统的 db 名,默认为 waline | `""` |
| EMAIL || 用于自动申请 https 证书的邮箱 | `""` |

## 目录映射

Expand Down
4 changes: 3 additions & 1 deletion packages/server/src/config/index.ts
Expand Up @@ -4,7 +4,8 @@ export interface Config {
mongoUrl: string;
jwtSecret: string;
staticPath: string;
demo?: boolean | string;
walineDB: string;
demo: boolean | string;
}

export const config: Config = {
Expand All @@ -15,4 +16,5 @@ export const config: Config = {
jwtSecret: loadConfig('jwt.secret', 'boynextdoor'),
staticPath: loadConfig('static.path', '/app/static'),
demo: loadConfig('demo', false),
walineDB: loadConfig('waline.db', 'waline'),
};
2 changes: 1 addition & 1 deletion packages/server/src/provider/waline/waline.provider.ts
Expand Up @@ -16,7 +16,7 @@ export class WalineProvider {
MONGO_PORT: url.port,
MONGO_USER: url.username,
MONGO_PASSWORD: url.password,
MONGO_DB: 'waline',
MONGO_DB: config.walineDB,
MONGO_AUTHSOURCE: 'admin',
};
const siteInfo = await this.metaProvider.getSiteInfo();
Expand Down

0 comments on commit 1723fe6

Please sign in to comment.