Last active
May 2, 2017 13:37
-
-
Save skinofstars/60a8197a04cd6f42499e2a4bcabf97aa to your computer and use it in GitHub Desktop.
Feathers schema switching in sequelize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setup a middleware that provides access to the express headers | |
module.exports = (req, res, next) => { | |
req.feathers.headers = req.headers; | |
next(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// update the model schema based on express passed headers | |
module.exports = function() { | |
return function(hook) { | |
if (hook.params.headers.subdomain) { | |
hook.service.Model = hook.service.Model.schema( | |
hook.params.headers.subdomain, | |
); | |
} else { | |
throw new Error('subdomain header missing'); | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment