GithubHelp home page GithubHelp logo

baffipelo / flamelink-js-sdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flamelink/flamelink-js-sdk

0.0 1.0 0.0 29.16 MB

๐ŸฆŠ Official Flamelink JavaScript SDK for both the Firebase Realtime database and Cloud Firestore

Home Page: https://flamelink.github.io/flamelink-js-sdk

JavaScript 4.57% TypeScript 94.24% Shell 1.19%

flamelink-js-sdk's Introduction

Flamelink JavaScript SDK

Lerna Conventional Commits NPM version NPM downloads CircleCI jsDelivr

logo

Easily integrate with your Flamelink CMS.

THIS PACKAGE IS CURRENTLY IN ALPHA - PLEASE USE WITH CAUTION OR USE THE CURRENT SDK FOR NOW

This SDK is intended for use in a browser or Node.js 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 a browser or server environment. Take a look at the installation instructions on their README files, but in short, just make sure you add firebase and/or firebase-admin as a dependency to your project.

When running a universal app, you might need to switch been the client and admin SDK depending on where in the stack the code is running.

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

Installation

Install with npm

npm install --save flamelink@next

or with yarn

yarn add flamelink@next

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

jsDelivr

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

<script src="//cdn.jsdelivr.net/npm/flamelink/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/[email protected]/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/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/[email protected]/flamelink.js"></script>

See the unpkg website for more options

Usage

Importing/Adding the dependencies

First ensure that you load the firebase SDK and then the main flamelink app package along with any of the modules you want to you in your project.

The examples below shows you how to quickly get started. Take a look at the Advanced Installation instructions to import only what you need.

In a CommonJS environment:

var flamelink = require('flamelink')

or using ES Modules or TypeScript:

import flamelink from 'flamelink'

Note: You might need to enable the esModuleInterop option in either your tsconfig.json file or provided as a CLI flag when using TypeScript.

Creating your Flamelink app instance

Create your flamelink app instance by passing in an existing firebaseApp instance along with any other flamelink config options:

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

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

const firebaseApp = firebase.initializeApp(firebaseConfig)

const app = flamelink({
  firebaseApp, // required
  dbType: 'rtdb', // can be either 'rtdb' or 'cf' for Realtime DB or Cloud Firestore
  env: 'production', // optional, default shown
  locale: 'en-US', // optional, default shown
  precache: true // optional, default shown. Currently it only precaches "schemas" for better performance
})

Tip: Go to your Firebase console for more info regarding the Firebase app options.

When using the firebase-admin SDK on server-side, it is the same, you only pass in the Firebase admin app instance instead:

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

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

const firebaseApp = admin.initializeApp(config)

const app = flamelink({
  firebaseApp // required
  // same options as above
})

You can use any of the different ways to create the admin firebaseApp instance.

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 either your Firebase Real-time Database or Cloud Firestore. Suppose you want to retrieve all your products created under the "Content" section in flamelink.

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

As easy as that. Read our docs for more specifics.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ Flame on!! ๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅ

History

Discover the release history by heading on over to the HISTORY.md file.

Backers

Maintainers

These amazing people are maintaining this project:

Sponsors

No sponsors yet! Will you be the first?

Contributors

These amazing people have contributed code to this project:

License

Unless stated otherwise all works are:

and licensed under:

flamelink-js-sdk's People

Contributors

jperasmus avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.