Building Locker Apps

From C-Aware Project Wiki
Jump to navigationJump to search

Apps are stored in their own directories in the Apps directory of the locker root, within each container. (E.g. from the 'DB1' root: /lockers/containers/cce25/USERNAME/locker/Apps).

A good way to start another app is to copy the 'HelloPhotos' app directory, and edit the files to reflect your new app, as it contains a basic setup that is fairly easy to understand by looking through the existing files.

Both the package.json and hello photos.app files within each apps root directory contain information that tell locker what to call the app internally and how to start it up when it is requested over the web interface.

The files in the static directory include the app pages served up to the user and javascript and CSS files, which all behave as normal static site pages served from a web server.

You will need to inform the locker code the presence of any new app you create by adding the new app path relative to the locker root in Config/config.json in the "Apps" array.

Locker Push API

Within each locker, there are 'Connectors', which fetch or accept data from various sources. This includes presenting the push endpoint that the mobile app uses to upload the commutes it records. Each locker includes information and documentation on using these endpoints, specificly the API explorer can be used to trial requests of data from the locker, and can be found at username.locker.cam.ac.uk/dashboard/develop#Develop-ApiExplorer.

The /push/getCurrent endpoint is used to request data from the push service within the locker, currently the collection used is "test5" to request data recorded by the Carbon Commute app.