0.19.16 • Published 1 year ago

flamelink v0.19.16

Weekly downloads
798
License
ISC
Repository
github
Last release
1 year ago

Flamelink JavaScript SDK

logo

Easily integrate with your Flamelink CMS.

THIS PACKAGE IS IN BETA - Please report any issues!

This SDK is intended to be used in a browser or on a NodeJS server environment.

If you are unfamiliar with Flamelink, please visit our flamelink.io website for more info on features, pricing and more.

Prerequisites

It goes without saying that you will need to have a Flamelink project for this SDK to be of any use to you.

Apart from the Flamelink project, the only real hard dependency is either the Firebase JavaScript SDK or Firebase Admin SDK, depending on whether you use Flamelink from the browser or server. Take a look at the installation instructions on their README, but in short, just make sure you add firebase or firebase-admin as a dependency to your project.

Once you have firebase installed, you can install flamelink using any of the following options (we recommend installing with npm or yarn):

Installation

Install with npm

npm install --save flamelink

or with yarn

yarn add flamelink

or with a <script> tag hosted from any of these CDN's

jsDelivr

npm.io

Add the following script tag to the <body> of your index.html file:

<script src="//cdn.jsdelivr.net/npm/flamelink/dist/flamelink.js"></script>

This will always load the latest version of this SDK for you. If you want to load a specific version, you can specify the version number as well (1.0.0 in the example):

<script src="//cdn.jsdelivr.net/npm/flamelink@1.0.0/dist/flamelink.js"></script>

See the jsDelivr website for more options

unpkg

Add the following script tag to the <body> of your index.html file:

<script src="//unpkg.com/flamelink/dist/flamelink.js"></script>

This will always load the latest version of this SDK for you. If you want to load a specific version, you can specify the version number as well (1.0.0 in the example):

<script src="//unpkg.com/flamelink@1.0.0/dist/flamelink.js"></script>

See the unpkg website for more options

Usage

Importing/Adding the dependencies

First ensure that you load the flamelink package to your file. When using the <script> tag version, you will need to load both firebase and flamelink which will then be globally available on the browser's window object.

Depending on your app setup, you can import the package using require() statements:

var flamelink = require('flamelink');

or using ES2015/ES6 imports:

import flamelink from 'flamelink';

Creating your Flamelink app instance

You can either create your flamelink app instance by passing in all the required config options that you would normally use to instantiate a firebase application:

const app = flamelink({
  apiKey: '<your-api-key>',                     // required
  authDomain: '<your-auth-domain>',             // required
  databaseURL: '<your-database-url>',           // required
  projectId: '<your-project-id>',               // required
  storageBucket: '<your-storage-bucket-code>',  // required
  messagingSenderId: '<your-messenger-id>',     // optional
});

?> Tip: Go to your Firebase console to find these config settings.

Or you can pass in an existing firebaseApp instance along with all the other flamelink config options (if using this option you need to remember to import firebase yourself):

import * as firebase from 'firebase';
import flamelink from 'flamelink';

const firebaseConfig = {
  apiKey: '<your-api-key>',                     // required
  authDomain: '<your-auth-domain>',             // required
  databaseURL: '<your-database-url>',           // required
  projectId: '<your-project-id>',               // required
  storageBucket: '<your-storage-bucket-code>',  // required
  messagingSenderId: '<your-messenger-id>'      // optional
};

const firebaseApp = firebase.initializeApp(firebaseConfig);

const app = flamelink({ firebaseApp });

When using the firebase-admin SDK on server-side, you need to specify a isAdminApp property along with your firebaseApp instance, like this:

const admin = require('firebase-admin');
const flamelink = require('flamelink');
const serviceAccount = require('path/to/serviceAccountKey.json');

const firebaseConfig = {
  credential: admin.credential.cert(serviceAccount), // required
  databaseURL: '<your-database-url>',                // required
  storageBucket: '<your-storage-bucket-code>',       // required if you want to your any Storage functionality
};

const firebaseApp = admin.initializeApp(config);

const app = flamelink({ firebaseApp, isAdminApp: true }); // Remember `isAdminApp: true` here!!!

You can use any of the different ways to create the admin firebaseApp instance, as long as you remember to set the isAdminApp: true option.

Using your flamelink app

Once you have an instance of the flamelink app, you can start using it to interact with your data stored in your firebase database. Suppose you want to retrieve all your products created under the "Content" section in flamelink.

Using standard Promises:

app.content.get('products')
  .then(products => console.log('All of your products:', products))
  .catch(error => // handle any errors)

Using async-await:

const products = await app.content.get('products');
console.log('All of your products:', products);

Read our docs for more specifics!

🔥🔥🔥 Flame on!! 🔥🔥🔥

1.0.0-rc.2

1 year ago

1.0.0-rc.1

2 years ago

0.19.16

3 years ago

0.19.15

3 years ago

1.0.0-alpha.34

4 years ago

1.0.0-alpha.33

4 years ago

1.0.0-alpha.32

4 years ago

1.0.0-alpha.31

4 years ago

1.0.0-alpha.30

4 years ago

1.0.0-alpha.29

4 years ago

1.0.0-alpha.28

4 years ago

1.0.0-alpha.27

4 years ago

1.0.0-alpha.26

5 years ago

1.0.0-alpha.25

5 years ago

0.19.14

5 years ago

1.0.0-alpha.24

5 years ago

1.0.0-alpha.23

5 years ago

1.0.0-alpha.22

5 years ago

1.0.0-alpha.21

5 years ago

1.0.0-alpha.20

5 years ago

1.0.0-alpha.19

5 years ago

1.0.0-alpha.18

5 years ago

1.0.0-alpha.17

5 years ago

1.0.0-alpha.16

5 years ago

1.0.0-alpha.15

5 years ago

1.0.0-alpha.14

5 years ago

1.0.0-alpha.13

5 years ago

1.0.0-alpha.12

5 years ago

1.0.0-alpha.11

5 years ago

1.0.0-alpha.10

5 years ago

1.0.0-alpha.9

5 years ago

1.0.0-alpha.8

5 years ago

1.0.0-alpha.7

5 years ago

1.0.0-alpha.6

5 years ago

1.0.0-alpha.5

5 years ago

1.0.0-alpha.4

5 years ago

1.0.0-alpha.3

5 years ago

1.0.0-alpha.2

5 years ago

1.0.0-alpha.1

5 years ago

0.19.13

5 years ago

1.0.0-alpha.0

5 years ago

0.19.12

5 years ago

0.19.11

5 years ago

0.19.10

5 years ago

0.19.9

5 years ago

0.19.8

5 years ago

0.19.7

5 years ago

0.19.6

5 years ago

0.19.5

5 years ago

0.19.3

6 years ago

0.19.2

6 years ago

0.19.1

6 years ago

0.19.0

6 years ago

0.18.10

6 years ago

0.18.9

6 years ago

0.18.8

6 years ago

0.18.7

6 years ago

0.18.6

6 years ago

0.18.5

6 years ago

0.18.4

6 years ago

0.18.3

6 years ago

0.18.2

6 years ago

0.18.1

6 years ago

0.18.0

6 years ago

0.17.1

6 years ago

0.17.0

6 years ago

0.15.1

6 years ago

0.15.0

6 years ago

0.14.3

6 years ago

0.14.2

6 years ago

0.14.1

6 years ago

0.14.0

6 years ago

0.13.5

6 years ago

0.13.4

6 years ago

0.13.2

6 years ago

0.12.0

6 years ago

0.11.0

6 years ago

0.10.1

7 years ago

0.10.0

7 years ago

0.9.0

7 years ago

0.8.0

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.3

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago