Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
marihachi committed Jul 29, 2017
1 parent 91d7620 commit 59f530f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/streaming-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ const methods = require('methods');
module.exports = (http, directoryRouter, subscribers, db, config) => {
const authorize = async (connection, applicationKey, accessKey) => {
if (applicationKey == null) {
const message = 'applicationKey parameter is empty';
const message = 'application_key parameter is empty';
connection.send('authorization', {success: false, message: message});
throw new Error(message);
}

if (accessKey == null) {
const message = 'accessKey parameter is empty';
const message = 'access_key parameter is empty';
connection.send('authorization', {success: false, message: message});
throw new Error(message);
}

if (!await Application.verifyKeyAsync(applicationKey, db, config)) {
const message = 'applicationKey parameter is invalid';
const message = 'application_key parameter is invalid';
connection.send('authorization', {success: false, message: message});
throw new Error(message);
}

if (!await ApplicationAccess.verifyKeyAsync(accessKey, db, config)) {
const message = 'accessKey parameter is invalid';
const message = 'access_key parameter is invalid';
connection.send('authorization', {success: false, message: message});
throw new Error(message);
}
Expand Down Expand Up @@ -74,14 +74,18 @@ module.exports = (http, directoryRouter, subscribers, db, config) => {
// クライアント側からRESTリクエストを受信したとき
connection.on('rest', data => {
(async () => {
const {
let {
method,
endpoint,
query,
headers,
body
} = data.request;

query = query || {};
headers = headers || {};
body = body || {};

if (method == null || endpoint == null) {
return connection.send('rest', {success: false, message: 'request format is invalid'});
}
Expand Down

0 comments on commit 59f530f

Please sign in to comment.