# firebase-init

> Firebase Initializer with configuration variable via config file, environment variable, package, npm or cli

Latest version **1.3.2** (published 2015-04-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install firebase-init
pnpm add firebase-init
yarn add firebase-init
bun add firebase-init
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2015-04-12 |
| First published | 2015-01-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | yieme |

## Links

- npm: https://www.npmjs.com/package/firebase-init
- npm.io page: https://npm.io/package/firebase-init

## Dependencies (4)

- [convar](https://npm.io/package/convar.md) ^1.1.1
- [jsonic](https://npm.io/package/jsonic.md) ^0.1.2
- [firebase](https://npm.io/package/firebase.md) ^2.2.3
- [firebase-token-generator](https://npm.io/package/firebase-token-generator.md) ^2.0.0

## Recent versions

- 1.3.2 (latest) — 2015-04-12
- 1.3.1 — 2015-02-07
- 1.2.3 — 2015-02-05
- 1.2.2 — 2015-02-05
- 1.2.1 — 2015-02-05
- 1.0.3 — 2015-01-19
- 1.0.2 — 2015-01-19
- 1.0.1 — 2015-01-19
- 1.0.0 — 2015-01-17

## README

# firebase-init

Firebase Initializer with configuration variable via config file, environment variable, package, npm or cli

## Install

```js
npm install firebase-init --save
```

## Supported ```firebase``` config variables

- ```url```: full firebase url, ex: ```https://example.firebaseio.com```
- ```name```: firebase name, ex: ```example```
- ```token```: custom authentication token
- ```custom```: custom authentication data, optional with ```token```
- ```path```: child path within firebase url

Or as individual variables

- ```firebase.url```: full firebase url, ex: ```https://example.firebaseio.com```
- ```firebase.name```: firebase name, ex: ```example```
- ```firebase.token```: custom authentication token
- ```firebase.custom```: custom authentication data, optional with ```token```
- ```firebase.path```: child path within firebase url

## Use

### Config via passed in values

```js
var Firebase = require('firebase-init')
var config = {
  "firebase": {
    "url":  "https://example.firebaseio.com"
  }
}
Firebase(config, function(error, initializedFirebaseReference) {
  if (error) throw error
  // start using initializedFirebaseReference
})
```


### Config via cli parameter:

```sh
node app.js --firebase.url https://example.firebaseio.com
```

Example NodeJS:

```js
var Firebase = require('firebase-init')
Firebase(function(error, initializedFirebaseReference) {
  if (error) throw error
  // start using initializedFirebaseReference
})
```


### Config via environment variable

```sh
firebase.url=https://example.firebaseio.com
firebase.token=dda8c65b-b0ea-423d-9a44-e17c4f6f09a9

node app.js
```

### Ignore case

This will also work

```sh
FIREBASE.URL=https://example.firebaseio.com
FIREBASE.TOKEN=dda8c65b-b0ea-423d-9a44-e17c4f6f09a9
```

### Value via JSON config value

```sh
config='{ "firebase": {"name":"example", "token":"dda8c65b-b0ea-423d-9a44-e17c4f6f09a9" }}'
```

### Config via JSON config file

```sh
config='pathTo/myConfig.json'
```

```myConfig.json``` :

```js
{
  "firebase": {
    "name":  "example-store",
    "token": "dda8c65b-b0ea-423d-9a44-e17c4f6f09a9",
    "custom": {
      uid:      "eastcoast-manager",
      isAdmin : true
    },
    "path": "east-coast/inventory"
  }
}
```

### Config via [JSONIC](http://github.com/rjrodger/jsonic) simplified JSON

```sh
firebase=name:example,token:e27d9f2a29b7

node app.js
```

or

```sh
node app.js --firebase=name:example,token:e27d9f2a29b7
```
<!-- EXAMPLES:BEGIN -->
## Examples

### [Read test](examples/read-test.js)

```js
var FirebaseInit = require('firebase-init')
  , config = {
    name: 'pub',
    path: 'AWS/zone/ap-northeast-1/city'
  }

FirebaseInit(config, function (err, firebaseRef) {
  firebaseRef.once('value', function(dataSnapshot) {
    console.log(dataSnapshot.val()) // Tokyo
    process.exit(0)
  }, function(err) {
    console.log(err)
    process.exit(0)
  })
})
```

### [Read test2](examples/read-test2.js)

```js
var FirebaseInit = require('firebase-init')
  , config       = 'name:pub,path:AWS/zone/ap-northeast-1/city' // jsonic


FirebaseInit(config, function (err, firebaseRef) {
  firebaseRef.once('value', function(dataSnapshot) {
    console.log(dataSnapshot.val()) // Tokyo
    process.exit(0)
  }, function(err) {
    console.log(err)
    process.exit(0)
  })
})
```
<!-- EXAMPLES:END -->
## License: MIT

---
_Source: https://npm.io/package/firebase-init · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
