Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Commit

Permalink
Multiple changes
Browse files Browse the repository at this point in the history
* Added `showActiveOnly` query string parameter (by updating facebook-events-by-location-core to 0.7.0)
* Version bump to 0.11.0
* Added handling of proxy IP address parameters for Morgan
  • Loading branch information
tobilg committed Oct 23, 2017
1 parent 3778646 commit 2ee4950
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Non-mandatory parameters
* `version`: The version of the Graph API to use. Default is `v2.7`.
* `since`: The start of the range to filter results. Format is Unix timestamp or `strtotime` data value, as accepted by [FB Graph API](https://developers.facebook.com/docs/graph-api/using-graph-api#time).
* `until`: The end of the range to filter results.
* `showActiveOnly`: Whether to show only active (non-draft, non-cancalled Events). Default is `true`, otherwise `false` can be passed to show all Events regardless of their state.

### Query results
The response will be `application/json` and contain an `events` property containing the array of event objects, as well as a `metadata` property with some stats. See below for an example.
Expand Down Expand Up @@ -107,6 +108,8 @@ Consequences:
"startTime": "2017-12-22T19:00:00-0500",
"endTime": null,
"timeFromNow": 9468080,
"isDraft": false,
"isCancelled": false,
"category": "MUSIC_EVENT",
"ticketing": {
"ticket_uri": "http://ticketf.ly/2wVV87f"
Expand Down
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ var EventSearch = require("facebook-events-by-location-core");
// Create the Express object
var app = express();

// Get real ip if passed by nginx
morgan.token("remote-addr", function (req) {
return req.headers["x-real-ip"] || req.headers["x-forwarded-for"] || req.connection.remoteAddress;
});

// Use morgan for logging
app.use(morgan("combined"));

Expand Down Expand Up @@ -106,6 +111,9 @@ app.get("/events", cors(corsOptions), function(req, res) {
if (req.query.until) {
options.until = req.query.until;
}
if (req.query.showActiveOnly && req.query.showActiveOnly === "false") {
options.showActiveOnly = Boolean(req.query.showActiveOnly);
}

// Instantiate EventSearch
var es = new EventSearch();
Expand Down
20 changes: 10 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"backend",
"app"
],
"version": "0.10.1",
"version": "0.11.0",
"private": false,
"scripts": {
"start": "node ./index",
Expand All @@ -20,8 +20,8 @@
},
"dependencies": {
"cors": "^2.8.4",
"express": "^4.16.1",
"facebook-events-by-location-core": "^0.6.1",
"express": "^4.16.2",
"facebook-events-by-location-core": "^0.7.0",
"morgan": "^1.9.0"
},
"bugs": {
Expand Down

0 comments on commit 2ee4950

Please sign in to comment.