@hwr-berlin-scheduler/database-updater
v0.0.5
Published
This library is part of an [open source project](https://github.com/hwr-berlin-scheduler). An effort to improve access to relevant information for affiliated persons at Hochschule fuer Wirtschaft und Recht Berlin, such as students and lecturers.
Downloads
3
Readme
HWR Berlin scheduler
This library is part of an open source project. An effort to improve access to relevant information for affiliated persons at Hochschule fuer Wirtschaft und Recht Berlin, such as students and lecturers.
database updater
This library written in TypeScript is used to simplify data updates of the remote database. It does not include the data retrieval itself but rather expects the data to be passed in an certain format. This data is then processed and finally persisted to the remote database.
As the current architecture is build around Firebase and its services the implementation stores the data into the Firebase Realtime Database. Thus the library expects a valid credential to be passed in order to access the database.
The used Firebase Cloud Functions service only runs on Node.js 6.x and thus all of the generated JavaScript is compatible with EC2015. This may change in the future when the Node runtime of Firebase is updated.
Usage
The library is available as npm package for direct use. If you want to take a look at and tinker with the source code read the contribution section below.
npm install @hwr-berlin-scheduler/database-updater
After installation you can run an update by retrieving an updater and passing it the lesson data, e.g.:
import * as functions from "firebase-functions";
import {DatabaseUpdaterProvider} from '@hwr-berlin-scheduler/database-updater'
// A valid firebase admin credential. If used in a cloud function one can retrieve one by calling:
let credential = functions.config().firebase.credential;
// the name of the database as in https://<databaseName>.firebaseio.com
let databaseName = "example";
// the user id the client should use if you don't want to use full admin privileges
// see https://firebase.google.com/docs/database/admin/start#authenticate-with-limited-privileges.
let userId = "bot";
let lessonData = ...
await DatabaseUpdaterProvider.getFirebaseDatabaseUpdater(credential, databaseName, userId).updateDatabase(lessonData)
Contribution
In case you found a bug or have a feature request open an issue on GitHub.
The full source code is available at GitHub aswell. Feel free to fork, tinker with it and make a PR to add features.
git clone https://github.com/hwr-berlin-scheduler/database-updater.git