Backend code (API server) for the Lokki project.
For developing the software, you will need:
- Recent version of node.js (tested with 0.10.33) – the distribution includes npm, which you will also need
- Recent version of Redis – follow installation and running instructions on Redis website
After these dependencies are installed, go to repository root and run:
$ npm install
This will install JavaScript dependencies of the project. If you have your Redis server running (on default port), you can run server with:
$ node lokki-server.js
Server can be run with different configurations by setting NODE_ENV
environment variable (development
is used by default). For example:
$ NODE_ENV=production node lokki-server.js
Server loads matching configuration from config/
directory – see lib/config.js
for details about all available configuration options.
Tests can be run with (always uses NODE_ENV=test
):
$ node unittest-runner.js
See the Lokki main repository for more information on development.
eslint is used to spot mistakes and to make sure coding style is consistent. Rules used in addition to default rules can be found from .eslintrc
. Any eslint errors will fail the Travis CI build.
During development, easiest way is to make sure you won't have eslint errors is to have eslint integration in your IDE or text editor. Sublime Text 3 supports this with SublimeLinter-eslint. You can also put eslint .
to your Git pre-commit hook to make sure you won't make commits that have lint errors.
This repository has been configured to use Heroku for continuous delivery. Whenever a new commit is pushed to this repository Travis CI will run tests and eslint to ensure that commit doesn't break anything. After successfully running all tests Travis will deploy the lokki-server to Heroku.
If you're deploying your version of the server, you want to take note of few things:
- Application is transferring location data over network, so you should use HTTPS.
- There are a few configuration variables you want to change – at least
adminUserId
,googleCloudMessagingApiKey
andredis.url
. If you want email to work, setsendGrid.username
andsendGrid.password
too. All of these can be provided as an environment variable, seelib/config.js
for details.
Setting up your own server is pretty simple, as the repository includes Procfile
needed to run the application in Heroku – just enable the required addons (some kind of Redis server and SendGrid) and set the configuration variables.
Some files and directories of interest include:
lokki-server.js
: Node.js + express app, exposing REST API. You can run the application withnode lokki-server.js
.unittest-runner.js
: Unit test runner. Unit tests are run withnode unittest-runner.js
command.lib/dbSetup.js
: Setting up database for testing.locmap/
: Folder containing logic related to location sharing.locmap/locmap-server.js
: REST API for locmaplocmap/test
: Tests for locmap
test/
: General tests
The base URL is /api/locmap/v1/
POST
/user/:userId/locationPOST
/user/:userId/allowDELETE
/user/:userId/allow/:targetUserIdPOST
/user/:userId/ignoreDELETE
/user/:userId/ignore/:targetUserIdPUT
/user/:userId/visibilityPUT
/user/:userId/languagePOST
/user/:userId/apnTokenPOST
/user/:userId/gcmTokenPOST
/user/:userId/wp8NotificationURLGET
/user/:userId/dashboardGET
/user/:userId/contactsDELETE
/user/:userId/contacts/:targetUserIdPOST
/user/:userId/rename/:targetUserIdPOST
/user/:userId/update/locationsPOST
/user/:userId/placePUT
/user/:userId/place/:placeIdDELETE
/user/:userId/place/:placeIdGET
/user/:userId/places
GET
/admin/:userId/crashReport/:osType/:year/:monthPOST
/admin/:userId/accountRecoveryGET
/admin/:userId/userStats
Lokki is available to the open source community under Apache v2 license AS IS.