Created
March 22, 2019 07:41
-
-
Save hypeJunction/45fb564118ee2ad830abbec83ee76f28 to your computer and use it in GitHub Desktop.
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
export default class App { | |
constructor (services) { | |
this.services = services; | |
} | |
start () { | |
const { express, db } = this.services; | |
if (!db.models) { | |
db.loadModels(this.services); | |
} | |
express.set('services', this.services); | |
express.use(async (request, response, next) => { | |
const { User } = db.models; | |
// This is pseudocode, we have a session service that reads user it from JWT token | |
response.locals.user = await User.findByPk(request.headers['X-User-Id']); | |
next(); | |
}); | |
return express; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment