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
passport.use( | |
new GoogleStrategy( | |
{ | |
clientID: process.env.GOOGLEAPPCLIENTID, | |
clientSecret: process.env.GOOGLEAPPSECRETKEY, | |
callBackURL: callbackURL | |
}, | |
googleRegistration // Callback function | |
) | |
); |
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
// In here we are just calling the respective passport | |
// strategy, which in our case is google. | |
router.get('/auth/google', passport.authenticate('google')); |
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
// serializeUser is just basically an lifecycle method in PassPortJS. | |
passport.serializeUser((user, done) => { | |
done(null, user); | |
}); |
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
// DeserializeUser gets called everytime when a route is hitted at backend server | |
passport.deserializeUser((req, user, done) => { | |
store.findUser( | |
null, | |
{ userName: user.email }, | |
async (err, existingUser) => { | |
if(err) { | |
return done(err); | |
} |
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
// To destroy the session we use this endpoint | |
router.get('/logout', (req, res) => { | |
req.logout(); | |
req.session.destroy(); | |
res.redirect(process.env.BASEURL); | |
}); |
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
const fs = require('fs'); | |
// const request = require('client-request'); | |
const axios = require('axios').default; | |
const BitPaySDK = require('../index'); | |
const readline = require('readline'); | |
let privateKeyPath = __dirname + '/../secure/private_key'; | |
let ConfFilePath = __dirname + '/../secure/BitPay.config.json'; | |
let keyUtils = new BitPaySDK.KeyUtils(); | |
let keyPair; | |
let ecKey; |
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
{ | |
"BitPayConfiguration": { | |
"Environment": "Test", | |
"EnvConfig": { | |
"Test": { | |
"PrivateKeyPath": "", | |
"PrivateKey": "<Your Private Key>", | |
"ApiTokens": { | |
"merchant": "<Your Bitpay merchant token>", | |
"payroll": "<Your Bitpay payroll token>" |
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
f(g(h(i(j(k(value), j1), i2), h1, h2), g1, g2), f1, f2); |
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
identityMonad(value) | |
.bind(k) | |
.bind(j, j1, j2) | |
.bind(i, i2) | |
.bind(h, h1, h2) | |
.bind(g, g1, g2) | |
.bind(f, f1, f2); |
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
let value = 1; | |
let promise = Promise.resolve(value); | |
let wrapInPromise = (x) => Promise.resolve(x * 2); | |
const boxResult = await promise.then(wrapInPromise); | |
const wrapperResult = await wrapInPromise(value); | |
console.log(boxResult == wrapperResult); | |
// Should log as true ✅ | |
// Thanks to top-level await 🤓 |
OlderNewer