Piping hot baked badges [closes #11]

This adds one new model, and one new route. It also modifies one old model and one old route.

* New route: `GET /public/images/:badgeImageSlug` (which is auth whitelisted) for serving baked badges. Uses the 
* New model: BadgeImages, which stores the badge image data (in base64).
* Modified model: EarnerBadges, added `badgeImageSlug` foreign key.
* Modified route: `POST /user/:userId/badges`, the interface remains the same however as part of the saving process, the remote badge image will be fetched, baked and stored locally in the BadgeImages model.
* Modified route: `GET /user/:userId/badges`, add `badgeBadgeUrl` to each of the badges in the `badges` array.
* Modified route: `GET /user/:userId/badges/:badgeId`, add `bakedBadgeUrl` to response
Agreed that BadgeClass images shouldn't be baked...EVER. That would be like
baking a shoe.

Only concern is if special info is baked into the [BadgeAssertion image](
https://github.com/mozilla/openbadges-specification/blob/master/Assertion/latest.md#badgeassertion),
will it be lost in the rebaking? It looks like we're never checking if the
BadgeAssertion has an image, just going straight to the BadgeClass.

Willing to back off the point in the interest of time.


On Fri, Jun 20, 2014 at 1:49 PM, Brian J Brennan <notifications@github.com>
wrote:

> In routes/earners.js:
>
> > @@ -382,6 +405,27 @@ function getAllBadgeStructures(assertionUrl, earnerId) {
> >    })
> >  }
> >
> > +function getStream(url) {
> > +  const get = (url.indexOf('https') == 0)
> > +      ? https.get
> > +      : http.get
> > +  return new Promise(function (resolve, reject) {
> > +    var req = get(url, function (res) { return resolve(res) })
> > +    req.on('error', function (err) { return reject(err) })
> > +  })
> > +}
> > +
> > +function getAndBakeImage(url, assertion) {
>
> Also, http://allrecipes.com/Recipe/Ultimate-Twice-Baked-Potatoes/
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/mozilla/badgekit-backpack/pull/20/files#r14035296>.
>