Answer the question
In order to leave comments, you need to log in
How do components interact with each other?
I am writing a project using express and using a component approach. I have the following file structure:
components
user
index.js
userModel.js
userRouter.js
auth
index.js
authRouter.js
authController.js
const passport = require('passport')
const VKontakteStrategy = require('passport-vkontakte').Strategy;
const config = require('config')
passport.use(new VKontakteStrategy({
clientID: config.get('auth.vk.clientID'),
clientSecret: config.get('auth.vk.clientSecret'),
callbackURL: `${config.get('domain')}/api/web/auth/vkontakte/callback`
},
function(accessToken, refreshToken, params, profile, done) {
console.log(profile)
// Зачем мне подключать компоненты друг к другу напрямую?
User.findOrCreate({ vkontakteId: profile.id }, function (err, user) {
return done(err, user);
});
}
));
module.exports = passport
Answer the question
In order to leave comments, you need to log in
Your question is not very clear.
Here you have an authController, in it you initialize the authorization strategy through VK, through new
VKontakteStrategy, which takes two arguments - an object with data and a callback function that will be executed after successful initialization. The components are more than connected.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question