Skip to content

Commit

Permalink
Merge pull request #3 from lupas/dev
Browse files Browse the repository at this point in the history
Fixed before 1.1.0
  • Loading branch information
lupas authored Nov 18, 2018
2 parents a130cbe + e06c83d commit f465459
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
# Nuxt-Fire
# 🔥 Nuxt-Fire

> Easily intergrate Firebase into your Nuxt 2 project.
> ## Easily intergrate Firebase into your Nuxt 2 project.
## Demo

[Demo](https://nuxt-fire-demo.firebaseapp.com/)

## Requirements

Make sure to have Nuxt 2+ installed:
Make sure you have Nuxt and Firebase installed in your project.

- Nuxt.js >= 2.x
```json
"dependencies": {
"nuxt": "^2.3.1",
"firebase": "^5.5.8"
}
```

## Install

Expand Down Expand Up @@ -79,13 +84,13 @@ You can access the various Firebase products with **\$foo** in almost any contex

Firebase products supported by nuxt-fire so far:

| Firebase Product | Shortcut |
| ----------------- | --------------- |
| Authentication | \$fireAuth |
| RealTime Database | \$fireDb |
| Firestore | \$fireStore |
| Storage | \$fireStorage |
| Functions | \$fireFunctions |
| Firebase Product | Shortcut |
| ----------------- | ------------- |
| Authentication | \$fireAuth |
| RealTime Database | \$fireDb |
| Firestore | \$fireStore |
| Storage | \$fireStorage |
| Functions | \$fireFunc |

See [Firebase's official docs](https://firebase.google.com/docs/) for more usage information.

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nuxt-fire",
"version": "0.0.3",
"version": "1.0.0",
"license": "MIT",
"description": "Intergrate Firebase into your Nuxt project.",
"main": "index.js",
Expand Down
24 changes: 11 additions & 13 deletions plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'firebase/database'
import 'firebase/storage'
import 'firebase/auth'

export default function({ app }, inject) {
export default (ctx, inject) => {

const options = <%= serialize(options) %>

Expand All @@ -18,32 +18,30 @@ export default function({ app }, inject) {
}
}

let _fireStore, _fireFunc, _fireStorage, _fireAuth, _fireDb

if (!options.useOnly || options.useOnly.includes('firestore')) {
firebase.firestore().settings({ timestampsInSnapshots: true })
_fireStore = firebase.firestore()
inject('fireStore', _fireStore)
const fireStore = firebase.firestore()
inject('fireStore', fireStore)
}

if (!options.useOnly || options.useOnly.includes('realtimeDb')) {
_fireDb = firebase.database()
inject('fireDb', _fireDb)
const fireDb = firebase.database()
inject('fireDb', fireDb)
}

if (!options.useOnly || options.useOnly.includes('functions')) {
_fireFunc = firebase.functions()
inject('fireFunc', _fireFunc)
const fireFunc = firebase.functions()
inject('fireFunc', fireFunc)
}

if (!options.useOnly || options.useOnly.includes('storage')) {
_fireStorage = firebase.storage()
inject('fireStorage', _fireStorage)
const fireStorage = firebase.storage()
inject('fireStorage', fireStorage)
}

if (!options.useOnly || options.useOnly.includes('auth')) {
const _fireAuth = firebase.auth()
inject('fireAuth', _fireAuth)
const fireAuth = firebase.auth()
inject('fireAuth', fireAuth)
}

}

0 comments on commit f465459

Please sign in to comment.