Skip to content

Commit 853523a

Browse files
committed
feat: add config files to override settings defined in framework
1 parent cc08882 commit 853523a

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { EggAppConfig, PowerPartial } from 'egg';
2+
3+
// for config.{env}.ts
4+
export type DefaultConfig = PowerPartial<EggAppConfig & BizConfig>;
5+
6+
// app special config scheme
7+
export interface BizConfig {
8+
sourceUrl: string;
9+
news: {
10+
pageSize: number;
11+
serverUrl: string;
12+
};
13+
}
14+
15+
export default (appInfo: EggAppConfig) => {
16+
const config = <PowerPartial<EggAppConfig> & BizConfig> {};
17+
18+
// app special config
19+
config.sourceUrl = `https://github.com/eggjs/examples/tree/master/${appInfo.name}`;
20+
config.news = {
21+
pageSize: 30,
22+
serverUrl: 'https://hacker-news.firebaseio.com/v0',
23+
};
24+
25+
// override config from framework / plugin
26+
config.keys = appInfo.name + '123456';
27+
28+
return config;
29+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { DefaultConfig } from './config.default';
2+
3+
export default () => {
4+
const config: DefaultConfig = {};
5+
config.news = {
6+
pageSize: 20,
7+
};
8+
return config;
9+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { DefaultConfig } from './config.default';
2+
3+
export default () => {
4+
const config: DefaultConfig = {};
5+
config.news = {
6+
pageSize: 30,
7+
};
8+
return config;
9+
};

framework-ts/app/config/plugin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
export default {
3+
};

0 commit comments

Comments
 (0)