Skip to content

Commit 33f788e

Browse files
author
Hyunje Jun
committed
Simplify config type
Use separate config type for client and middleware.
1 parent b33d2f8 commit 33f788e

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

lib/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { toArray } from "./util";
66
export default class Client {
77
public config: Types.ClientConfig;
88

9-
constructor(config: Types.Config & Types.ClientConfig) {
9+
constructor(config: Types.ClientConfig) {
1010
if (!config.channelAccessToken) {
1111
throw new Error("no channel access token");
1212
}

lib/middleware.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ export type Middleware = (
1414
next: NextCallback,
1515
) => void;
1616

17-
export default function middleware(
18-
config: Types.Config & Types.MiddlewareConfig,
19-
): Middleware {
17+
export default function middleware(config: Types.MiddlewareConfig): Middleware {
2018
if (!config.channelSecret) {
2119
throw new Error("no channel secret");
2220
}

lib/types.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
export type ClientConfig = {
1+
export interface Config {
2+
channelAccessToken?: string;
3+
channelSecret?: string;
4+
}
5+
6+
export interface ClientConfig extends Config {
27
channelAccessToken: string;
3-
};
8+
}
49

5-
export type MiddlewareConfig = {
10+
export interface MiddlewareConfig extends Config {
611
channelSecret: string;
7-
};
8-
9-
export type Config = ClientConfig | MiddlewareConfig;
12+
}
1013

1114
export type Profile = {
1215
displayName: string;

0 commit comments

Comments
 (0)