Skip to content

Commit bfa7232

Browse files
authored
Merge pull request #40 from microsoftgraph/dependencies-cleanup
Dependencies cleanup
2 parents 6a9dccf + d623917 commit bfa7232

File tree

15 files changed

+1903
-5500
lines changed

15 files changed

+1903
-5500
lines changed

.eslintrc.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ module.exports = {
1313
"prefer-arrow-callback": 0,
1414
"new-cap": 0,
1515
"no-param-reassign": 0,
16-
"no-use-before-define": 0
16+
"no-use-before-define": 0,
17+
"linebreak-style": 0,
18+
"no-plusplus": 0
1719
}
1820
};

.github/workflows/nodejs.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
strategy:
1818
matrix:
19-
node-version: [10.x]
19+
node-version: [10.x, 12.x]
2020

2121
steps:
2222
- uses: actions/checkout@v2
@@ -26,6 +26,7 @@ jobs:
2626
node-version: ${{ matrix.node-version }}
2727
- run: npm ci
2828
- run: npm run build --if-present
29-
- run: npm test
30-
env:
31-
CI: true
29+
- run: npm run lint
30+
# - run: npm test
31+
# env:
32+
# CI: true

NOTICES.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,3 @@ morgan, Copyright (c) by Douglas Christopher Wilson, is available under [The MIT
1515
serve-favicon, Copyright (c) by Douglas Christopher Wilson, is available under [The MIT License](https://raw.githubusercontent.com/expressjs/serve-favicon/master/LICENSE).
1616

1717
socket.io, Copyright (c) by Automattic, is available under [The MIT License](https://raw.githubusercontent.com/socketio/socket.io/master/LICENSE).
18-
19-
gulp, Copyright (c) by Fractal, is available under [The MIT License](https://raw.githubusercontent.com/gulpjs/gulp/master/LICENSE).
20-
21-
gulp-nodemon, Copyright (c) by Jackson Gariety, is available under [The BSD 2-clause "Simplified" License](http://spdx.org/licenses/BSD-2-Clause).
22-
23-
gulp-plumber, Copyright (c) by Vsevolod Strukchinsky, is available under [The MIT License](https://raw.githubusercontent.com/floatdrop/gulp-plumber/master/LICENSE).

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extensions:
1414
---
1515
# Microsoft Graph Webhooks Sample for Node.js
1616

17-
[![Build Status](https://travis-ci.org/microsoftgraph/nodejs-webhooks-rest-sample.svg)](https://travis-ci.org/microsoftgraph/nodejs-webhooks-rest-sample)
17+
![Build status](https://github.com/microsoftgraph/nodejs-webhooks-rest-sample/workflows/Node.js%20CI/badge.svg?branch=master)
1818

1919
## Table Of Contents. ##
2020
* [Introduction](#introduction)

babel.config.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compact": false,
3+
"ignore": [
4+
".tmp"
5+
],
6+
"presets": ["@babel/env"]
7+
}

gulpfile.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

helpers/authHelper.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ const resource = 'https://graph.microsoft.com/';
99
* @return {string} a fully formed uri with which authentication can be completed.
1010
*/
1111
export function getAuthUrl() {
12-
return adalConfiguration.authority + '/oauth2/authorize' +
13-
'?client_id=' + adalConfiguration.clientID +
14-
'&response_type=code' +
15-
'&redirect_uri=' + adalConfiguration.redirectUri;
12+
return adalConfiguration.authority + '/oauth2/authorize'
13+
+ '?client_id=' + adalConfiguration.clientID
14+
+ '&response_type=code'
15+
+ '&redirect_uri=' + adalConfiguration.redirectUri;
1616
}
1717

1818
/**

helpers/dbHelper.js

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@ const sqlite3 = sql.verbose();
1010
export function createDatabase() {
1111
const dbExists = fs.existsSync(dbFile);
1212
const db = new sqlite3.Database(dbFile);
13-
const createSubscriptionStatement =
14-
'CREATE TABLE Subscription (' +
15-
'UserId TEXT NOT NULL, ' +
16-
'SubscriptionId TEXT NOT NULL, ' +
17-
'AccessToken TEXT NOT NULL, ' +
18-
'Resource TEXT NOT NULL, ' +
19-
'ChangeType TEXT NOT NULL, ' +
20-
'ClientState TEXT NOT NULL, ' +
21-
'NotificationUrl TEXT NOT NULL, ' +
22-
'SubscriptionExpirationDateTime TEXT NOT NULL' +
23-
')';
13+
const createSubscriptionStatement = 'CREATE TABLE Subscription ('
14+
+ 'UserId TEXT NOT NULL, '
15+
+ 'SubscriptionId TEXT NOT NULL, '
16+
+ 'AccessToken TEXT NOT NULL, '
17+
+ 'Resource TEXT NOT NULL, '
18+
+ 'ChangeType TEXT NOT NULL, '
19+
+ 'ClientState TEXT NOT NULL, '
20+
+ 'NotificationUrl TEXT NOT NULL, '
21+
+ 'SubscriptionExpirationDateTime TEXT NOT NULL'
22+
+ ')';
2423

2524
db.serialize(() => {
2625
if (!dbExists) {
@@ -38,19 +37,18 @@ export function createDatabase() {
3837

3938
export function getSubscription(subscriptionId, callback) {
4039
const db = new sqlite3.Database(dbFile);
41-
const getUserDataStatement =
42-
'SELECT ' +
43-
'UserId as userId, ' +
44-
'SubscriptionId as subscriptionId, ' +
45-
'AccessToken as accessToken, ' +
46-
'Resource as resource, ' +
47-
'ChangeType as changeType, ' +
48-
'ClientState as clientState, ' +
49-
'NotificationUrl as notificationUrl, ' +
50-
'SubscriptionExpirationDateTime as subscriptionExpirationDateTime ' +
51-
'FROM Subscription ' +
52-
'WHERE SubscriptionId = $subscriptionId ' +
53-
'AND SubscriptionExpirationDateTime > datetime(\'now\')';
40+
const getUserDataStatement = 'SELECT '
41+
+ 'UserId as userId, '
42+
+ 'SubscriptionId as subscriptionId, '
43+
+ 'AccessToken as accessToken, '
44+
+ 'Resource as resource, '
45+
+ 'ChangeType as changeType, '
46+
+ 'ClientState as clientState, '
47+
+ 'NotificationUrl as notificationUrl, '
48+
+ 'SubscriptionExpirationDateTime as subscriptionExpirationDateTime '
49+
+ 'FROM Subscription '
50+
+ 'WHERE SubscriptionId = $subscriptionId '
51+
+ 'AND SubscriptionExpirationDateTime > datetime(\'now\')';
5452

5553
db.serialize(() => {
5654
db.get(
@@ -65,12 +63,11 @@ export function getSubscription(subscriptionId, callback) {
6563

6664
export function saveSubscription(subscriptionData, callback) {
6765
const db = new sqlite3.Database(dbFile);
68-
const insertStatement =
69-
'INSERT INTO Subscription ' +
70-
'(UserId, SubscriptionId, AccessToken, Resource, ChangeType, ' +
71-
'ClientState, NotificationUrl, SubscriptionExpirationDateTime) ' +
72-
'VALUES ($userId, $subscriptionId, $accessToken, $resource, $changeType, ' +
73-
'$clientState, $notificationUrl, $subscriptionExpirationDateTime)';
66+
const insertStatement = 'INSERT INTO Subscription '
67+
+ '(UserId, SubscriptionId, AccessToken, Resource, ChangeType, '
68+
+ 'ClientState, NotificationUrl, SubscriptionExpirationDateTime) '
69+
+ 'VALUES ($userId, $subscriptionId, $accessToken, $resource, $changeType, '
70+
+ '$clientState, $notificationUrl, $subscriptionExpirationDateTime)';
7471

7572
db.serialize(() => {
7673
db.run(
@@ -92,9 +89,8 @@ export function saveSubscription(subscriptionData, callback) {
9289

9390
export function deleteSubscription(subscriptionId, callback) {
9491
const db = new sqlite3.Database(dbFile);
95-
const deleteStatement =
96-
'DELETE FROM Subscription WHERE ' +
97-
'SubscriptionId = $subscriptionId';
92+
const deleteStatement = 'DELETE FROM Subscription WHERE '
93+
+ 'SubscriptionId = $subscriptionId';
9894

9995
db.serialize(() => {
10096
db.run(

helpers/requestHelper.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function postData(path, token, data, callback) {
2424
const req = https.request(options, res => {
2525
let subscriptionData = '';
2626

27-
res.on('data', chunk => (subscriptionData += chunk));
27+
res.on('data', chunk => { subscriptionData += chunk; });
2828
res.on('end', () => {
2929
if (res.statusCode === 201) callback(null, JSON.parse(subscriptionData));
3030
else callback(JSON.parse(subscriptionData), null);
@@ -50,16 +50,16 @@ export function getData(path, token, callback) {
5050
method: 'GET',
5151
headers: {
5252
'Content-Type': 'application/json',
53-
Accept: 'application/json;odata.metadata=minimal;' +
54-
'odata.streaming=true;IEEE754Compatible=false',
53+
Accept: 'application/json;odata.metadata=minimal;'
54+
+ 'odata.streaming=true;IEEE754Compatible=false',
5555
Authorization: 'Bearer ' + token
5656
}
5757
};
5858

5959
const req = https.request(options, res => {
6060
let endpointData = '';
6161

62-
res.on('data', chunk => (endpointData += chunk));
62+
res.on('data', chunk => { endpointData += chunk; });
6363
res.on('end', () => {
6464
if (res.statusCode === 200) callback(null, JSON.parse(endpointData));
6565
else callback(JSON.parse(endpointData), null);
@@ -91,8 +91,6 @@ export function deleteData(path, token, callback) {
9191
};
9292

9393
const req = https.request(options, res => {
94-
let endpointData = '';
95-
res.on('data', chunk => (endpointData += chunk));
9694
res.on('end', () => callback(null));
9795
});
9896

bin/www renamed to index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

3-
import { app } from '../app';
4-
import { createDatabase } from '../helpers/dbHelper';
3+
import { app } from './app';
4+
import { createDatabase } from './helpers/dbHelper';
55

66
createDatabase();
77

0 commit comments

Comments
 (0)