Skip to content

Commit

Permalink
chore(typings): add interface Config['cors'] (#12)
Browse files Browse the repository at this point in the history
* chore(typings): add interface Config['cors']

usage:

```ts
// {app_root}/config/config.default.ts

import { Config as CorsConfig } from 'egg-cors'

export default (appInfo: EggAppConfig) => {
  const config = <PowerPartial<EggAppConfig> & CorsConfig> {}
  // ...
  config.cors = {
    origin: '*',
    allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
  }

  return config
}
```
  • Loading branch information
waitingsong authored and fengmk2 committed Jul 11, 2018
1 parent da2b18b commit ff8b7da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions index.d.ts
@@ -0,0 +1,9 @@

declare module 'egg' {
export interface EggAppConfig {
cors: {
origin: string | (() => string);
allowMethods: string | string[];
}
};
}
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -8,7 +8,8 @@
"files": [
"app",
"config",
"app.js"
"app.js",
"index.d.ts"
],
"repository": {
"type": "git",
Expand Down

0 comments on commit ff8b7da

Please sign in to comment.