Skip to content

odch/flightbox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1,353 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

open digital Flightbox

GitHub release

Getting Started

Required Node Versions

Node Version for building the app: 22

Node Version for deploying to Firebase and for the cloud functions: 22

Start locally

$ npm install
$ npm start [--project={PROJECT_NAME}]

Then open http://0.0.0.0:8080/webpack-dev-server/ in your browser.

Parameters

  • project (optional): Name of the project. There must a configuration file called {PROJECT_NAME}.json be available in the projects directory. The default project is lszt.

How to Test

$ npm test

How to Deploy

Install the required node modules

$ npm install

Build

Parameters
  • project (optional): Name of the project. There must a configuration file called {PROJECT_NAME}.json be available in the projects directory. The default project is lszt.
Development or test environment
$ npm run build [--project={PROJECT_NAME}]
Production environment
$ npm run build:prod [--project={PROJECT_NAME}]

Push to Firebase

Node version for this step: 22

Prerequisites: Firebase Tools must be installed (npm install -g firebase-tools@13).

Caution: Ensure that you have selected the right Firebase project (list all projects by typing firebase list and change it if necessary (with firebase use)).

Set up env
Database
Flightbox

Code:

In project conf JSON file, set the following properties:

  • environments.(test|production).firebaseDatabaseName
  • environments.(test|production).firebaseDatabaseUrl

Functions:

Set the realtime database name for the cloud functions:

firebase functions:config:set rtdb.instance={RTDB NAME}

(e.g. firebase functions:config:set rtdb.instance=lszt-test)

If the database is not in the default location and the database URL is not {instance}.firebaseio.com, you also have to set the database URL additionally:

firebase functions:config:set rtdb.url={RTDB URL}

(e.g. firebase functions:config:set rtdb.url=https://lszt-test-eu.europe-west1.firebasedatabase.app)

Flightbox-Stripe repository

In the https://github.com/odch/flightbox-stripe repository, set the following Github-Workflow environment variables:

  • FIREBASE_RTDB_NAME
  • FIREBASE_RTDB_URL
Deploy app

Before executing this command, make sure the correct project was built using the Node version mentioned at the beginning of this document.

$ firebase target:apply database main {RTDB NAME}
$ firebase deploy --only hosting,database:main

(e.g. lszt-test for {RTDB NAME})

Deploy cloud functions

Use the following commands to deploy the cloud functions.

Before executing these commands, make sure you selected the correct Node version for the cloud functions, which is mentioned at the beginning of this document.

$ cd functions && npm ci && cd ..
$ firebase deploy --only functions

Cloud functions

auth

Can be called to create a custom authentication token. Has to be called via POST.

The following authentication modes are implemented: static, guest_token and kiosk_token.

Mode static

Returns a token if the given username and password match one of the configured static credentials. The credentials are configured via the AUTH_STATIC_CREDENTIALS environment variable as a comma-separated list of username:password pairs (e.g. AUTH_STATIC_CREDENTIALS="foo:bar,admin:12345"). If no credentials are configured, authentication always fails.

Request example:

$ curl \
    -X POST \
    -H "Content-Type: application/json" \
    -d '{"mode": "static", "username": "<USERNAME>", "password": "<PASSWORD>"}' \
    https://europe-west1-<PROJECT_ID>.cloudfunctions.net/auth

API

URL: https://europe-west1-<PROJECT_ID>.cloudfunctions.net/api

Aerodrome status

Returns the current aerodrome status.

GET /api/aerodrome/status

Returns (example):

{
  status: "closed",
  last_update_by: "Hans Meier",
  last_update_date: "2020-04-12T22:29:01.565Z",
  message: "Flugplatz geschlossen. Kinderspielplatz und Restaurant geschlossen."
}

If no status is set, {} is returned.

Import users

Request

POST an array of users to this endpoint to sync the users list.

New users are added, existing ones are updated, and those which are saved in the database, but not present in the given users array are removed from the database.

Example payload:

POST /api/users/import

{
  "users": [
    {
      "memberNr": "48434",
      "firstname": "John",
      "lastname": "Doe",
      "phone": "+41791234567",
      "email": "john.doe@example.com"
    },
    {
      "memberNr": "30443",
      "firstname": "Jane",
      "lastname": "Smith",
      "phone": "+41791234568",
      "email": "jane.smith@example.com"
    },
    ...
  ]
}
Auth

This endpoint requires a Basic Auth header (username and password to use set in the function config: api.serviceuser.username and api.serviceuser.password).

About

Fluganmeldung & Startliste für BAZL Statistik

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors