Socket
Socket
Sign inDemoInstall

node-fb-graph

Package Overview
Dependencies
61
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.11 to 0.1.0

5

package.json
{
"name": "node-fb-graph",
"version": "0.0.11",
"version": "0.1.0",
"description": "Node.js module for interacting with the Facebook Graph API",

@@ -12,3 +12,3 @@ "main": "index.js",

"preversion": "npm run lint && npm test && npm run cover",
"prepublishOnly": "npm version patch && git push --tags && git push"
"prepublishOnly": "npm version minor && git push --tags && git push"
},

@@ -34,2 +34,3 @@ "repository": {

"chai": "^4.2.0",
"chance": "^1.1.3",
"coveralls": "^3.0.5",

@@ -36,0 +37,0 @@ "eslint": "^6.1.0",

2

README.md

@@ -1,2 +0,2 @@

[![Build Status](https://travis-ci.org/brencon/node-fb-graph.svg?branch=master)](https://travis-ci.org/brencon/node-fb-graph) [![Coverage Status](https://coveralls.io/repos/github/brencon/node-fb-graph/badge.svg?branch=master)](https://coveralls.io/github/brencon/node-fb-graph?branch=master)
[![Build Status](https://api.travis-ci.com/brencon/fb-graph-api.svg?branch=master)](https://travis-ci.com/brencon/fb-graph-api) [![Coverage Status](https://coveralls.io/repos/github/brencon/fb-graph-api/badge.svg?branch=master)](https://coveralls.io/github/brencon/fb-graph-api?branch=master)

@@ -3,0 +3,0 @@ [![NPM](https://nodei.co/npm/node-fb-graph.png)](https://nodei.co/npm/node-fb-graph/)

@@ -6,16 +6,17 @@ 'use strict';

const _PAGE_ACCESS_TOKEN = 'EAAUggZAfCJdcBAArrTyMt6wRbGy4g9GFuhEtOJvowoAAaBoOounsV7HcQCsq67bhOFZCAv6o2es1aIHPcdrl8vpq7bDnc5SPXFr341VZAM8U6lYACtZAtfa7y2ZBtLy8JD1BNwAkCaQ8qn0fVirXWxHtdaQX76WHfMqdCWnCvG6nacCmWQV9zWZAfZAnifxmsTeDXFVDVn67wZDZD';
const _PAGE_ID = '1618039481631017';
const _OPTIONS = {
method: 'GET',
rejectUnauthorized: false,
insecure: true
};
async function getPage(pageAccessToken, pageId) {
const options = {
url: `${fbURL}/${pageId}?fields=rating_count,id,name,picture,about,privacy_info_url,cover&access_token=${pageAccessToken}`,
method: 'GET',
rejectUnauthorized: false,
insecure: true
};
const data = await rp.get(options, function(err, res, body) {
if (err) return err;
else return body;
});
_OPTIONS.url = `${fbURL}/${pageId}?fields=rating_count,id,name,picture,about,privacy_info_url,cover&access_token=${pageAccessToken}`;
const data = await rp(_OPTIONS)
.then(function(res) {
return res;
})
.catch(function(err) {
return err.response.body;
});
return { page: JSON.parse(data) };

@@ -26,27 +27,23 @@ }

async function getPosts(pageAccessToken, pageId) {
const options = {
url: `${fbURL}/${pageId}/posts?fields=likes.summary(true),message,story,created_time&access_token=${pageAccessToken}`,
method: 'GET',
rejectUnauthorized: false,
insecure: true
};
const data = await rp.get(options, function(err, res, body) {
if (err) return err;
else return body;
});
return { page: { posts: JSON.parse(data).data } };
_OPTIONS.url = `${fbURL}/${pageId}/posts?fields=likes.summary(true),message,story,created_time&access_token=${pageAccessToken}`;
const data = await rp(_OPTIONS)
.then(function(res) {
return { page: { posts: JSON.parse(res).data } };
})
.catch(function(err) {
return { page: JSON.parse(err.response.body) };
});
return data;
}
async function getRatings(pageAccessToken, pageId) {
const options = {
url: `${fbURL}/${pageId}/ratings?fields=reviewer,review_text,recommendation_type,rating,has_review,has_rating,created_time&access_token=${pageAccessToken}`,
method: 'GET',
rejectUnauthorized: false,
insecure: true
};
const data = await rp.get(options, function(err, res, body) {
if (err) return err;
else return body;
});
return { page: { ratings: JSON.parse(data).data } };
_OPTIONS.url = `${fbURL}/${pageId}/ratings?fields=reviewer,review_text,recommendation_type,rating,has_review,has_rating,created_time&access_token=${pageAccessToken}`;
const data = await rp(_OPTIONS)
.then(function(res) {
return { page: { ratings: JSON.parse(res).data } };
})
.catch(function(err) {
return { page: JSON.parse(err.response.body) };
});
return data;
};

@@ -53,0 +50,0 @@

'use strict';
const chance = require('chance').Chance();
const expect = require('chai').expect;

@@ -9,15 +10,26 @@ const npmms = require('../../index');

const _PAGE_ACCESS_TOKEN_INVALID = chance.apple_token();
const _PAGE_ID_INVALID = chance.string({ length: 16, pool: '0123456789' });
describe('node-fb-graph', function() {
it('return business page details', async function() {
const result = await npmms.getPage(_PAGE_ACCESS_TOKEN, _PAGE_ID);
console.log(JSON.stringify(result));
expect(result.page.id).to.not.be.undefined;
expect(result.page.name).to.not.be.undefined;
});
it('return error for business page details', async function() {
const result = await npmms.getPage(_PAGE_ACCESS_TOKEN_INVALID, _PAGE_ID_INVALID);
expect(result.page.error).to.not.be.undefined;
expect(result.page.error.message).to.not.be.undefined;
});
it('return all posts for a given business page', async function() {
const result = await npmms.getPosts(_PAGE_ACCESS_TOKEN, _PAGE_ID);
console.log(JSON.stringify(result.page.posts));
expect(result.page.posts.length).to.be.greaterThan(0);
expect(result.page.posts[0].likes.summary.total_count).to.be.greaterThan(-1);
});
it('return error for all posts for a given business page', async function() {
const result = await npmms.getPosts(_PAGE_ACCESS_TOKEN_INVALID, _PAGE_ID_INVALID);
expect(result.page.error).to.not.be.undefined;
expect(result.page.error.message).to.not.be.undefined;
});
it('return all ratings for a given business page', async function() {

@@ -27,2 +39,7 @@ const result = await npmms.getRatings(_PAGE_ACCESS_TOKEN, _PAGE_ID);

});
it('return error for all ratings for a given business page', async function() {
const result = await npmms.getRatings(_PAGE_ACCESS_TOKEN_INVALID, _PAGE_ID_INVALID);
expect(result.page.error).to.not.be.undefined;
expect(result.page.error.message).to.not.be.undefined;
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc