Script for syncing Meetup.com data with Firebase database in NodeJS
- NodeJS 5.6
1) Install package
user@machine:~# npm install gugcz/meetup-firebase-sync
2) Go to installation directory
user@machine:~# cd node_modules/meetup-firebase-sync
3) Configure Firebase
Create file: 'firebase_config.json', example content:
{
"firebase_app_id": "<YOUR_FIREBASE_APP_ID>",
"firebase_app_secret": "<YOUR_FIREBASE_APP_SECRET>"
}
Import existing meetups to Firebase
user@machine:~# node sync.js --import
or
user@machine:~# ./bin/meetup-sync --import
Fetch new meetups / edits / removals and push them to Firebase
user@machine:~# node sync.js
or
user@machine:~# ./bin/meetup-sync
You may notice that we are using Firebase structure that is suitable for us, if it isn't for you, then go and write your own Firebase definition, then just add to configuration file this:
{
... ,
"firebase_definition": "<YOUR_DEFINITION_JS_FILENAME>"
}
If you take a look, we have our own definition in gug_cz_firebase_definition.js, so you can inspire how to write yours. The important parts are as follows:
"use strict";
const MeetupProcessor = require('./meetup_processor');
class YouCustomMeetupProcessor extends MeetupProcessor {
processEvent(meetupEvent, syncedData, output) {
//your meetupEvent processing, data you want to store in Firebase push to output (see definition)
}
eventsFilter(meetupEvent, syncedData) {
//this method returns true if you want to pass this event to method above or it's not for your (typically check your meetup id here)
}
}
var dataModel = {
syncPaths: [
//list of paths in your Firebase DB you want to have available to the MeetupProcessor above (syncedData parameters)
'events', 'path1', ...
],
eventsPath: 'events', //path to where you store events in your Firebase DB
geofirePath: 'geofire', //path to where you store GeoFire data in your Firebase DB
getImportGroupUrlNames: function (syncedData) {
//this method returns array of url names of groups you want to import data from
return ['MyGroup'];
}
};
module.exports = {
processor: GugMeetupProcessor,
dataModel: dataModel
};
TODO: information about output
variable and how to use it, for now check gug_cz_firebase_definition.js