Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
feathers-google-maps
Advanced tools
Readme
A Feathers service for Google Maps API
yarn add feathers-google-maps
This service is a light wrapper around the @googlemaps/google-maps-services-js library. Please refer to the @googlemaps/google-maps-services-js documenation for options that can be passed. You will also find it helpful to reference the Google Maps Web Service APIs docs.
The following methods are supported and map to the appropriate @google/maps methods:
const GoogleMapsService = require('feathers-google-maps');
const Directions = new GoogleMapsService({
key: 'YOUR API KEY',
method: 'directions'
});
app.use('directions', Directions);
The service exposes two methods, find(params)
and create(data, params)
. These two methods are functionally equivalent. The create()
method is added so that you can take advantage of the .on('created')
service event.
When using the find(params)
method, include the query
as the params to be passed to the underlying GoogleMaps method.
app.service('directions').find({
query: {
origin: 'Nashville, TN',
destination: 'Memphis, TN'
}
});
// This will call the googlMaps method like
googleMaps.directions({
params: {
origin: 'Nashville, TN',
destination: 'Memphis, TN',
key: 'YOUR API KEY'
}
});
When using the create(data, params)
method, the data
will be passed to the underlying GoogleMaps method.
app.service('directions').create({
origin: 'Nashville, TN',
destination: 'Memphis, TN'
});
// This will also call the googlMaps method like
googleMaps.directions({
params: {
origin: 'Nashville, TN',
destination: 'Memphis, TN',
key: 'YOUR API KEY'
}
});
const feathers = require('@feathersjs/feathers');
const express = require('@feathersjs/express');
const socketio = require('@feathersjs/socketio');
const GoogleMapsService = require('feathers-google-maps');
// Initialize the application
const app = feathers()
.configure(express.rest())
.configure(socketio())
.use(express.json())
.use(express.urlencoded({ extended: true }))
.use(express.errorHandler({ html: false }));
// Create a directions service
app.use('directions', new GoogleMapsService({
key: 'YOUR API KEY',
method: 'directions'
}));
// Create a geocode service
app.use('geocode', new GoogleMapsService({
key: 'YOUR API KEY',
method: 'geocode'
}));
const directionsService = app.service('directions');
const geocodeService = app.service('geocode');
const successHook = context => {
// On success, context.params.googleMaps will include a `response`
console.log('Success: ', context.data, context.params.googleMaps);
}
const errorHook = context => {
// On error, context.params.googleMaps will include an `error`
console.log('Error: ', context.error, context.params.googleMaps);
}
directionsService.hooks(
after: {
find: [successHook]
create: [successHook]
},
error: {
find: [errorHook]
create: [errorHook]
},
);
directionsService.on('created', result => {
console.log('Directions created event');
})
geocodeService.hooks(
after: {
find: [successHook]
create: [successHook]
},
error: {
find: [errorHook]
create: [errorHook]
},
);
geocodeService.on('created', result => {
console.log('Geocode created event');
})
directionsService
.find({ query: { origin: 'Nashville, TN', destination: 'Memphis, TN' } })
.then(result => {
console.log('Directions found', result);
})
.catch(error => {
console.log('Error finding directions', error);
});
directionsService
.create({ origin: 'Nashville, TN', destination: 'Memphis, TN' })
.then(result => {
console.log('Directions created', result);
})
.catch(error => {
console.log('Error creating directions', error);
});
geocodeService
.find({ query: { address: '1010 Forrest Ave, Nashville, TN' } })
.then(result => {
console.log('Geocode found', result);
})
.catch(error => {
console.log('Error geocoding', error);
});
geocodeService
.create({ address: '1010 Forrest Ave, Nashville, TN' })
.then(result => {
console.log('Geocode found', result);
})
.catch(error => {
console.log('Error geocoding', error);
});
app.listen(3030);
console.log('Feathers app started on 127.0.0.1:3030');
Copyright (c) 2019
Licensed under the MIT license.
FAQs
A Feathers service for interacting with the Google Maps API
The npm package feathers-google-maps receives a total of 52 weekly downloads. As such, feathers-google-maps popularity was classified as not popular.
We found that feathers-google-maps demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.