No description, website, or topics provided.
Clone or download
Pull request Compare This branch is 1 commit ahead, 87 commits behind mozilla:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Webmaker Events Service

This is a REST api service for Webmaker Events using Persona to authenticate requests.


npm install
cp .env-dist .env
node server

You must also run...

Webmaker Login Server


Configuration is stored in .env.

Option Default Description
DEV false If true, fake database generation methods will be exposed as GET routes.
PORT 1989 The port the server runs on.
LOGIN_URL * URL for Webmaker Login server. You MUST include this.
ALLOWED_DOMAINS http://localhost:1981 URL(s) webmaker-events front end. Comma-separated if more than one.
SECRET secretsauce The secret key for signing session cookies.
FORCE_SSL false Force SSL on cookies?
COOKIE_DOMAIN undefined If you want to use supercookies, add the domain here.
STORAGE events.sqlite If using sqlite, the name and location of the sqlite file.
DB_DIALECT sqlite Can be sqlite or mysql
DB_CONNECTIONSTRING undefined If defined, sequelize will use this to configure databse, username, password, etc.
DB_HOST undefined If you are using mysql, database host, e.g. localhost
DB_PORT 3306 If you are using mysql, database port
DB_DATABASE undefined Database name
DB_USER undefined Database user
DB_PASSWORD undefined Database password
DB_CERT undefined Path to Amazon RDS CA certificate


The default location is events.sqlite in the root folder, but it can be configured by setting STORAGE in your .env

Example event object

  "title": "My event",
  "description": "Blah blah blah...",
  "address": "15 Apple St.",
  "latitude": -4,
  "longitude": 101,
  "city": "Toronto",
  "country": "Canada",
  "attendees": 474,
  "beginDate": "2014-01-15T22:16:43.000Z",
  "endDate": null,
  "beginTime": null,
  "endTime": null,
  "registerLink": "",
  "picture": null,
  "organizer": "",
  "organizerId": "Laney8",
  "featured": false,
  "tags": ["security", "pizza", "jeff goldblum"]

Responses also contain id, createdAt, and updatedAt, which are added/updated automatically.


If you need to migrate your existing database, first create a configuration file:

cp config/config.json.dist config/config.json

Edit config/config.json with your database credentials.

Next, run the sequelize migration tool:

node_modules/.bin/sequelize -m

Existing database issues

For old data, that is data created from the previous events system,

  • city and country are null in all cases
  • beginDate endDate beginTime endTime contain redundancies, where times are just 1899-12-31 + time and dates are date + 00:00:00


Protected routes require a user session to be set via Webmaker Login.


POST /auth

  audience: {{ audience of persona token }},
  assertion: {{ valid persona token }}


200 OK

  email: {{ verified persona email }},
  token: {{ token for protected routes }},
  admin: {{ true | false }}


For protected routes, make sure you have a session set.

Method Path Query/Body Authentication required Description
GET /events Query parameters:

order (Sort order of returned array. e.g. 'beginDate DESC'. Defaults to 'beginDate')
organizerId (Constrain to events created by a user. e.g. 'mike_danton')
after (Return only events post-`after` time. Must be a string usable by `Date.parse`.)
dedupe (Only allow 1 event of per event title when set to `true`. Defaults to `false`.)
tag (Filter results to a single tag name)
search (Restrict to events with descriptions and/or titles that match the search term.)
csv (Return results as CSV when set to `true`. Defaults to JSON.)

Custom headers:

Pagination is achieved through standard range request headers (eg: Accept-Ranges, Range-Unit, Content-Range, Range).

Note: Only logged in admins will get user's email.
Returns an array of events.
GET /events/:id No Returns a single event object where the id matches :id
POST /events {{event object}} Persona Creates a new event
PUT /events/:id {{event object}} Persona Updates an event with id :id with the attributes specified in the body of the request.
DELETE /events/:id Persona Deletes an event with id :id.
GET /attendee/user/:id Persona (Users may only see their own attendance list. Admins may see anyone's attendance info.) Get a user's event attendance information.
GET /attendee/event/:id Lists for events with areAttendeesPublic set to false: Persona (admin or event creator) Get an event's attendee info.
POST /attendee Must include either userid (numerical) or email (for non-user attendees only) and eventid.

checkin can be specified either true or false.
rsvp can be specified either true or false.
Persona (Users may edit their own attendance, admins can edit anybody's attendance, and event creators may edit any attendees for their events.) Set a user's attendance info (RSVP and Check-in status) for an event.
GET /tags like Query for similar tag names. No Get an array of all event tag names similar to a query.
GET /dev/fake amount (number of events, e.g. 15) DEV=true on server config Adds fake items to the db.


heroku create webmaker-events-service
git push heroku master

To add a database: heroku addons:add cleardb

Heroku Configuration

If you don't already have the Heroku config plugin installed, do it now:

heroku plugins:install git://

Now you can push up your .env config file like this:

heroku config:push --overwrite