Skip to content

Instantly share code, notes, and snippets.

@luandevpro
Created October 13, 2019 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luandevpro/b524574d5228de7bcdb46df843c51492 to your computer and use it in GitHub Desktop.
Save luandevpro/b524574d5228de7bcdb46df843c51492 to your computer and use it in GitHub Desktop.
import * as admin from 'firebase-admin';
const serviceAccount = require('./serviceAccountKey.json');
try {
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://nextjs-graphql-firebase-redux.firebaseio.com',
});
} catch (err) {
console.log('firebase initializeApp');
}
const withFirebase = (handle) => (req, res) => {
req.admin = admin;
return handle(req, res);
};
export default withFirebase;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment