New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

googleplaces

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

googleplaces - npm Package Compare versions

Comparing version 0.0.1 to 0.2.0

.editorconfig

31

index.js

@@ -1,11 +0,22 @@

var PlaceSearch = require("./lib/PlaceSearch.js");
var TextSearch = require("./lib/TextSearch.js");
var PlaceDetailsRequest = require("./lib/PlaceDetailsRequest.js");
(function () {
"use strict";
module.exports = function (apiKey, outputFormat) {
return {
placeSearch:new PlaceSearch(apiKey, outputFormat),
textSearch:new TextSearch(apiKey, outputFormat),
placeDetailsRequest:new PlaceDetailsRequest(apiKey, outputFormat)
};
};
var PlaceSearch = require("./lib/PlaceSearch.js");
var TextSearch = require("./lib/TextSearch.js");
var PlaceDetailsRequest = require("./lib/PlaceDetailsRequest.js");
var AddEvent = require("./lib/AddEvent.js");
var DeleteEvent = require("./lib/DeleteEvent.js");
var EventDetails = require("./lib/EventDetails.js");
module.exports = function (apiKey, outputFormat) {
return {
placeSearch: new PlaceSearch(apiKey, outputFormat),
textSearch: new TextSearch(apiKey, outputFormat),
placeDetailsRequest: new PlaceDetailsRequest(apiKey, outputFormat),
addEvent: new AddEvent(apiKey, outputFormat),
deleteEvent: new DeleteEvent(apiKey, outputFormat),
eventDetails: new EventDetails(apiKey, outputFormat)
};
};
})();

@@ -1,19 +0,25 @@

/**
* Merge the data chunks of response and pass to callback
*
* @param callback
* @return {Function}
*/
module.exports = function (parseJson, callback) {
return function (response) {
var responseData = "";
response.setEncoding('utf8');
response.on("data", function (chunk) {
responseData += chunk;
});
response.on("end", function () {
if (parseJson) responseData = JSON.parse(responseData);
callback(responseData);
});
};
};
(function () {
"use strict";
/**
* Merge the data chunks of response and pass to callback
*
* @param parseJson
* @param callback
* @return {Function}
*/
module.exports = function (parseJson, callback) {
return function (response) {
var responseData = "";
response.setEncoding("utf8");
response.on("data", function (chunk) {
responseData += chunk;
});
response.on("end", function () {
if (parseJson) responseData = JSON.parse(responseData);
callback(null, responseData);
});
};
};
})();

@@ -1,24 +0,29 @@

var querystring = require("querystring");
var https = require("https");
(function () {
"use strict";
var HttpResponseProcessor = require("./HttpResponseProcessor.js");
var validate = require("./validate.js");
var querystring = require("querystring");
var https = require("https");
module.exports = function (apiKey, outputFormat) {
return function (parameters, callback) {
validate.apiKey(apiKey);
validate.outputFormat(outputFormat);
parameters.key = apiKey;
parameters.sensor = parameters.sensor || false;
if (!parameters.reference) throw new Error("Place reference is required")
var options = {
hostname:"maps.googleapis.com",
path:"/maps/api/place/details/" + outputFormat + "?" + querystring.stringify(parameters)
var HttpResponseProcessor = require("./HttpResponseProcessor.js");
var validate = require("./validate.js");
module.exports = function (apiKey, outputFormat) {
return function (parameters, callback) {
validate.apiKey(apiKey);
validate.outputFormat(outputFormat);
parameters.key = apiKey;
parameters.sensor = parameters.sensor || false;
if (!parameters.reference && !parameters.placeid) throw new Error("Place reference or placeid is required");
var options = {
hostname: "maps.googleapis.com",
path: "/maps/api/place/details/" + outputFormat + "?" + querystring.stringify(parameters)
};
var request = https.request(options, new HttpResponseProcessor(outputFormat === "json", callback));
request.on("error", function (error) {
throw new Error(error);
});
request.end();
};
};
var request = https.request(options, new HttpResponseProcessor(outputFormat === "json", callback));
request.on("error", function (error) {
throw new Error(error);
});
request.end();
};
};
})();

@@ -1,26 +0,31 @@

var querystring = require("querystring");
var https = require("https");
(function () {
"use strict";
var HttpResponseProcessor = require("./HttpResponseProcessor.js");
var validate = require("./validate.js");
var querystring = require("querystring");
var https = require("https");
module.exports = function (apiKey, outputFormat) {
return function (parameters, callback) {
validate.apiKey(apiKey);
validate.outputFormat(outputFormat);
parameters.key = apiKey;
parameters.location = parameters.location || "-33.8670522,151.1957362";
if (typeof parameters.location === "object") parameters.location = parameters.location.toString();
parameters.radius = parameters.radius || 500;
parameters.sensor = parameters.sensor || false;
var options = {
hostname:"maps.googleapis.com",
path:"/maps/api/place/search/" + outputFormat + "?" + querystring.stringify(parameters)
var HttpResponseProcessor = require("./HttpResponseProcessor.js");
var validate = require("./validate.js");
module.exports = function (apiKey, outputFormat) {
return function (parameters, callback) {
validate.apiKey(apiKey);
validate.outputFormat(outputFormat);
parameters.key = apiKey;
parameters.location = parameters.location || "-33.8670522,151.1957362";
if (typeof parameters.location === "object") parameters.location = parameters.location.toString();
parameters.radius = parameters.radius || 500;
parameters.sensor = parameters.sensor || false;
var options = {
hostname: "maps.googleapis.com",
path: "/maps/api/place/search/" + outputFormat + "?" + querystring.stringify(parameters)
};
var request = https.request(options, new HttpResponseProcessor(outputFormat === "json", callback));
request.on("error", function (error) {
throw new Error(error);
});
request.end();
};
};
var request = https.request(options, new HttpResponseProcessor(outputFormat === "json", callback));
request.on("error", function (error) {
throw new Error(error);
});
request.end();
};
};
})();

@@ -1,25 +0,30 @@

var querystring = require("querystring");
var https = require("https");
(function () {
"use strict";
var HttpResponseProcessor = require("./HttpResponseProcessor.js");
var validate = require("./validate.js");
var querystring = require("querystring");
var https = require("https");
module.exports = function (apiKey, outputFormat) {
return function (parameters, callback) {
validate.apiKey(apiKey);
validate.outputFormat(outputFormat);
parameters.key = apiKey;
parameters.query = parameters.query || "restaurant";
parameters.sensor = parameters.sensor || false;
if (typeof parameters.location === "object") parameters.location = parameters.location.toString();
var options = {
hostname:"maps.googleapis.com",
path:"/maps/api/place/textsearch/" + outputFormat + "?" + querystring.stringify(parameters)
var HttpResponseProcessor = require("./HttpResponseProcessor.js");
var validate = require("./validate.js");
module.exports = function (apiKey, outputFormat) {
return function (parameters, callback) {
validate.apiKey(apiKey);
validate.outputFormat(outputFormat);
parameters.key = apiKey;
parameters.query = parameters.query || "restaurant";
parameters.sensor = parameters.sensor || false;
if (typeof parameters.location === "object") parameters.location = parameters.location.toString();
var options = {
hostname: "maps.googleapis.com",
path: "/maps/api/place/textsearch/" + outputFormat + "?" + querystring.stringify(parameters)
};
var request = https.request(options, new HttpResponseProcessor(outputFormat === "json", callback));
request.on("error", function (error) {
throw new Error(error);
});
request.end();
};
};
var request = https.request(options, new HttpResponseProcessor(outputFormat === "json", callback));
request.on("error", function (error) {
throw new Error(error);
});
request.end();
};
};
})();

@@ -1,7 +0,13 @@

exports.apiKey = function (apiKey) {
if (!apiKey) throw new Error("apiKey must not be null");
};
exports.outputFormat = function (outputFormat) {
var validFormats = ["json", "xml"];
if (validFormats.indexOf(outputFormat) === -1) throw new Error("outputFormat must be 'json' or 'xml'");
};
(function () {
"use strict";
exports.apiKey = function (apiKey) {
if (!apiKey) throw new Error("apiKey must not be null");
};
exports.outputFormat = function (outputFormat) {
var validFormats = ["json", "xml"];
if (validFormats.indexOf(outputFormat) === -1) throw new Error("outputFormat must be 'json' or 'xml'");
};
})();
{
"name":"googleplaces",
"version":"0.0.1",
"version":"0.2.0",
"description":"Node.js library for the Google Places API",

@@ -12,3 +12,3 @@ "keywords":["google", "places", "api", "google places", "google places api"],

"author":"Srirangan <srirangan@gmail.com> (http://srirangan.net)",
"contributors":["", ""],
"contributors":["metafedora@gmail.com (http://andrew.dalgleish.info)"],
"main":"./index.js",

@@ -20,4 +20,4 @@ "repository":{

"scripts": {
"test": "sh ./test/test-runner.sh"
"test": "sh ./test.sh"
}
}
}

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

exports.apiKey = "AIzaSyDuDuJMT7TINlRl0R3G6SsP8EZOyKubFoY";
exports.outputFormat = "json";
(function () {
"use strict";
exports.apiKey = process.env.GOOGLE_API_KEY || "your google api key (server) comes here";
exports.outputFormat = "json";
})();

@@ -1,41 +0,46 @@

var assert = new require("assert");
(function () {
"use strict";
var config = require("./config.js");
var assert = require("assert");
var GooglePlaces = require("../index.js");
var googlePlaces = new GooglePlaces(config.apiKey, config.outputFormat);
var parameters;
var config = require("./config.js");
/**
* Place search - https://developers.google.com/places/documentation/#PlaceSearchRequests
*/
parameters = {
location:[-33.8670522, 151.1957362],
types:"doctor"
};
googlePlaces.placeSearch(parameters, function (response) {
assert.notEqual(response.results.length, 0, "Place search must not return 0 results");
});
var GooglePlaces = require("../index.js");
var googlePlaces = new GooglePlaces(config.apiKey, config.outputFormat);
var parameters;
/**
* Text search - https://developers.google.com/places/documentation/#TextSearchRequests
*/
parameters = {
query:"restaurants in dublin"
};
googlePlaces.textSearch(parameters, function (response) {
assert.notEqual(response.results.length, 0, "Text search must not return 0 results");
});
/**
* Place search - https://developers.google.com/places/documentation/#PlaceSearchRequests
*/
parameters = {
location: [-33.8670522, 151.1957362],
types: "doctor"
};
googlePlaces.placeSearch(parameters, function (error, response) {
assert.notEqual(response.results.length, 0, "Place search must not return 0 results");
});
/**
* Place details requests - https://developers.google.com/places/documentation/#PlaceDetails
*/
parameters = {
location:[-33.8670522, 151.1957362],
types:"doctor"
};
googlePlaces.placeSearch(parameters, function (response) {
googlePlaces.placeDetailsRequest({reference:response.results[0].reference}, function (response) {
assert.equal(response.status, "OK", "Place details request response status is OK");
});
});
/**
* Text search - https://developers.google.com/places/documentation/#TextSearchRequests
*/
parameters = {
query: "restaurants in dublin"
};
googlePlaces.textSearch(parameters, function (error, response) {
assert.notEqual(response.results.length, 0, "Text search must not return 0 results");
});
/**
* Place details requests - https://developers.google.com/places/documentation/#PlaceDetails
*/
parameters = {
location: [-33.8670522, 151.1957362],
types: "doctor"
};
googlePlaces.placeSearch(parameters, function (error, response) {
googlePlaces.placeDetailsRequest({reference: response.results[0].reference}, function (error, response) {
assert.equal(response.status, "OK", "Place details request response status is OK");
});
});
})();

@@ -1,19 +0,24 @@

var assert = new require("assert");
(function () {
"use strict";
var PlaceSearch = require("../lib/PlaceSearch.js");
var PlaceDetailsRequest = require("../lib/PlaceDetailsRequest.js");
var config = require("./config.js");
var assert = require("assert");
var placeSearch = new PlaceSearch(config.apiKey, config.outputFormat);
var placeDetailsRequest = new PlaceDetailsRequest(config.apiKey, config.outputFormat);
var PlaceSearch = require("../lib/PlaceSearch.js");
var PlaceDetailsRequest = require("../lib/PlaceDetailsRequest.js");
var config = require("./config.js");
var parameters = {
location:[-33.8670522, 151.1957362],
types:"doctor"
};
var placeSearch = new PlaceSearch(config.apiKey, config.outputFormat);
var placeDetailsRequest = new PlaceDetailsRequest(config.apiKey, config.outputFormat);
placeSearch(parameters, function (response) {
placeDetailsRequest({reference:response.results[0].reference}, function (response) {
assert.equal(response.status, "OK", "Place details request response status is OK");
});
});
var parameters = {
location: [-33.8670522, 151.1957362],
types: "doctor"
};
placeSearch(parameters, function (error, response) {
placeDetailsRequest({reference: response.results[0].reference}, function (error, response) {
assert.equal(response.status, "OK", "Place details request response status is OK");
});
});
})();

@@ -1,16 +0,20 @@

var assert = new require("assert");
(function () {
"use strict";
var PlaceSearch = require("../lib/PlaceSearch.js");
var config = require("./config.js");
var assert = require("assert");
var placeSearch = new PlaceSearch(config.apiKey, config.outputFormat);
var PlaceSearch = require("../lib/PlaceSearch.js");
var config = require("./config.js");
var parameters = {
location:[-33.8670522, 151.1957362],
types:"doctor"
};
var placeSearch = new PlaceSearch(config.apiKey, config.outputFormat);
placeSearch(parameters, function (response) {
// console.log(response);
assert.notEqual(response.results.length, 0, "Place search must not return 0 results");
});
var parameters = {
location: [40.7127, -74.0059],
types: "doctor"
};
placeSearch(parameters, function (error, response) {
assert.notEqual(response.results.length, 0, "Place search must not return 0 results");
});
})();

@@ -1,15 +0,20 @@

var assert = new require("assert");
(function () {
"use strict";
var TextSearch = require("../lib/TextSearch.js");
var config = require("./config.js");
var assert = require("assert");
var textSearch = new TextSearch(config.apiKey, config.outputFormat);
var TextSearch = require("../lib/TextSearch.js");
var config = require("./config.js");
var parameters = {
query:"restaurants in dublin"
};
var textSearch = new TextSearch(config.apiKey, config.outputFormat);
textSearch(parameters, function (response) {
// console.log(response);
assert.notEqual(response.results.length, 0, "Text search must not return 0 results");
});
var parameters = {
query: "restaurants in dublin"
};
textSearch(parameters, function (error, response) {
assert.notEqual(response.results.length, 0, "Text search must not return 0 results");
});
})();
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc