Skip to content

Commit b66b14e

Browse files
author
Hyunje Jun
committed
Separate configs into client and middleware types
1 parent 1ca2887 commit b66b14e

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

lib/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import * as URL from "./urls";
33
import { toArray } from "./util";
44

55
export default class Client {
6-
public config: Line.Config;
6+
public config: Line.ClientConfig;
77

8-
constructor(config: Line.Config & { channelAccessToken: string }) {
8+
constructor(config: Line.Config & Line.ClientConfig) {
99
if (!config.channelAccessToken) {
1010
throw new Error("no channel access token");
1111
}

lib/middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type NextCallback = (err?: Error) => void;
99

1010
export type Middleware = (req: Request, res: Response, next: NextCallback) => void;
1111

12-
export default function middleware(config: Line.Config & { channelSecret: string }): Middleware {
12+
export default function middleware(config: Line.Config & Line.MiddlewareConfig): Middleware {
1313
if (!config.channelSecret) {
1414
throw new Error("no channel secret");
1515
}

types/global.d.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,16 @@
55
declare module "got";
66

77
declare namespace Line {
8-
export type Config = {
9-
channelAccessToken?: string,
10-
channelSecret?: string,
8+
export type ClientConfig = {
9+
channelAccessToken: string,
1110
};
1211

12+
export type MiddlewareConfig = {
13+
channelSecret: string,
14+
};
15+
16+
export type Config = ClientConfig | MiddlewareConfig;
17+
1318
export type Profile = {
1419
displayName: string,
1520
userId: string,

0 commit comments

Comments
 (0)