Fastify Firebase Auth
Switch branches/tags
Nothing to show
Clone or download
Vasco Amaral
Vasco Amaral v0.0.3
Latest commit b27168e Jun 15, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Add Firebase Auth plugin for fastify Nov 2, 2017
.travis.yml Add Firebase Auth plugin for fastify Nov 2, 2017
LICENSE Add Firebase Auth plugin for fastify Nov 2, 2017
README.md Add Firebase Auth plugin for fastify Nov 2, 2017
index.js Removed setError Jun 15, 2018
package.json v0.0.3 Jun 15, 2018
test.js Removed setError Jun 15, 2018

README.md

fastify-firebase-auth

js-standard-style

Fastify Firebase Auth API plugin.
Under the hood the firebase is used, the options that you pass to register will be passed to the Firebase service.

Install

npm i fastify-firebase-auth --save

Usage

Add it to you project with register and you are done!
This plugin will add the auth namespace in your Fastify instance, with the all functions in the Firebase Auth API:

Example:

const fastify = require('fastify')

fastify.register(require('fastify-firebase-auth'), {
    apiKey: <FIREBASE_API_KEY>,
    databaseURL: <DATABASE_URL>,
    projectId: <PROJECT_ID>,
    storageBucket: <URL_STORAGE_BUCKET>
})

fastify.post('/signin', async (request, reply) => {
    const {email, password} = request.body;
    const response = await fastify.auth.signInWithEmailAndPassword(email, password);
    return response;
});

fastify.listen(3000, err => {
  if (err) throw err
  console.log(`server listening on ${fastify.server.address().port}`)
})

License

Licensed under MIT.