Skip to content

Commit

Permalink
Working on adding webhooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jlkalberer committed Nov 25, 2016
1 parent 0c8ee1d commit 7e8e246
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
24 changes: 24 additions & 0 deletions src/lib/webhooks/WebhookUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Copyright (C) 2013-2014 Spark Labs, Inc. All rights reserved. - https://www.spark.io/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You can download the source here: https://github.com/spark/spark-server
*/

const settings = require('../../settings.js');

class WebhookUtils {
}

module.exports = new WebhookUtils();
4 changes: 3 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var OAuthServer = require('node-oauth2-server');
var OAuth2ServerModel = require('./lib/OAuth2ServerModel');
var AccessTokenViews = require('./lib/AccessTokenViews.js');

const Webhook = require('./views/Webhooks');

global._socket_counter = 1;

var oauth = OAuthServer({
Expand Down Expand Up @@ -85,7 +87,7 @@ var tokenViews = new AccessTokenViews({ });
eventsV1.loadViews(app);
api.loadViews(app);
tokenViews.loadViews(app);

const webhookViews = new Webhook(app);



Expand Down
43 changes: 43 additions & 0 deletions src/views/Webhooks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Copyright (C) 2013-2014 Spark Labs, Inc. All rights reserved. - https://www.spark.io/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You can download the source here: https://github.com/spark/spark-server
*/

const ROUTE_BASE = '/v1/webhooks';

class Webhooks {
constructor(app) {
app.get(ROUTE_BASE, this.get);
}

get(request, response) {
// console.log(JSON.stringify(request));

response.json(
[
{
"id": "12345",
"url": "https://samplesite.com",
"event": "hello",
"created_at": "2016-04-28T17:06:33.123Z",
"requestType": "POST",
},
],
);
}
}

module.exports = Webhooks;

0 comments on commit 7e8e246

Please sign in to comment.