Skip to content

tstreamDOTh/firebase-swiss

Repository files navigation

firebase-swiss

Build Status License: MIT node All Contributors

Table of contents

Install

Using Yarn

yarn add firebase-swiss

Using NPM

npm i firebase-swiss

Usage

If you are totally new to Firebase or Firebase Cloud Functions then get started here

Once you have created your firebase projects and setup cloud functions, you can start creating your CRUD api's like the following by using simple configuration -

// functions.js
const FireFunctions = require('firebase-swiss');
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const cors = require('cors')({
  origin: true
});

admin.initializeApp(functions.config().firebase);

const firefunctions = new FireFunctions(admin.database());

exports.addApplicant = firefunctions.getFireFunction({
  type: 'CREATE',
  ref: 'applicants',
  extractFromBody: ['name', 'role'],
  enableCors: true
});

exports.getApplicantById = firefunctions.getFireFunction({
  type: 'READ',
  ref: 'applicants',
  enableCors: true
});

exports.updateApplicantById = firefunctions.getFireFunction({
  type: 'UPDATE',
  ref: 'applicants',
  extractFromBody: ['name', 'role'],
  enableCors: true
});

exports.deleteApplicantById = firefunctions.getFireFunction({
  type: 'DELETE',
  ref: 'applicants',
  enableCors: true
});

Contributors ✨

Thanks goes to these wonderful people (emoji key):

T Thiyagaraj
T Thiyagaraj

πŸ’»
Alejandro Baeza
Alejandro Baeza

πŸ“–
Kaspar Arme
Kaspar Arme

πŸ“–
Dmitry Savchenkov
Dmitry Savchenkov

πŸ“–
Bos Eriko Reyes
Bos Eriko Reyes

πŸ“–
Cory Cunningham
Cory Cunningham

πŸ’»
vAporInside
vAporInside

πŸ“–

This project follows the all-contributors specification. Contributions of any kind welcome!