diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-03-01 22:33:43 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-03-01 22:33:43 +0900 |
| commit | 58c7cd5dadf0a0f414989f04a3084f6bac0b6e5c (patch) | |
| tree | a2cb7f9c98bfbbbb7fd25bcafb550db21c6723ca /src/api/api-handler.ts | |
| parent | [API] Fix bug and change limit 50 to 30 (diff) | |
| download | sharkey-58c7cd5dadf0a0f414989f04a3084f6bac0b6e5c.tar.gz sharkey-58c7cd5dadf0a0f414989f04a3084f6bac0b6e5c.tar.bz2 sharkey-58c7cd5dadf0a0f414989f04a3084f6bac0b6e5c.zip | |
Refactor
Diffstat (limited to 'src/api/api-handler.ts')
| -rw-r--r-- | src/api/api-handler.ts | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/api/api-handler.ts b/src/api/api-handler.ts index 45b3c6123e..4cde538ae1 100644 --- a/src/api/api-handler.ts +++ b/src/api/api-handler.ts @@ -1,12 +1,12 @@ import * as express from 'express'; -import { IEndpoint } from './endpoints'; +import { Endpoint } from './endpoints'; import authenticate from './authenticate'; import { IAuthContext } from './authenticate'; import _reply from './reply'; import limitter from './limitter'; -export default async (endpoint: IEndpoint, req: express.Request, res: express.Response) => { +export default async (endpoint: Endpoint, req: express.Request, res: express.Response) => { const reply = _reply.bind(null, res); let ctx: IAuthContext; @@ -21,7 +21,7 @@ export default async (endpoint: IEndpoint, req: express.Request, res: express.Re return reply(403, 'ACCESS_DENIED'); } - if (endpoint.shouldBeSignin && ctx.user == null) { + if (endpoint.withCredential && ctx.user == null) { return reply(401, 'PLZ_SIGNIN'); } @@ -31,7 +31,7 @@ export default async (endpoint: IEndpoint, req: express.Request, res: express.Re } } - if (endpoint.shouldBeSignin) { + if (endpoint.withCredential && endpoint.limit) { try { await limitter(endpoint, ctx); // Rate limit } catch (e) { |