moving to koa 2.0; + api

This commit is contained in:
tmshv committed 2016-03-23 14:56:59 +03:00
1 parent 44724132c0
commit 0ffa403b60
17 files changed
+398 -339

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
import {checkAuth} from '../core/service';
export function ensureServiceAuth() {
return async (ctx, next) => {
let service = ctx.request.headers['x-service-name'];
let token = ctx.request.headers['x-service-token'];
if (!checkAuth(service, token)) {
ctx.status = 401;
} else {
await next();
}
};
}