API server for Leerstandsmelder.de based on restify and written in ES6 JavaScript for Node.js.
This software is part of a complete relaunch of the platform, now making it open source and independent from Google's map service. The API has a pretty standard JSON-over-HTTP CRUD interface and adds an interface to basic geospatial queries through the 2D-index in MongoDB.
You can find the accompanying frontend and API client in the Leerstandsmelder GitHub repositories.
- NodeJS 6.x or 8.x
- MongoDB 3.x
- Redis 3.x
Install dependencies with npm install
, copy config.default.json
to config.json
. You can then create an admin user by running ./bin/setup.js
.
Start the server with
node app.js
./bin/add-user-scope.js --email=user@host.com --scope=SCOPE_TO_SET
adds the specified scope (e.g. admin
, editor
or a region admin with region-REGION_UUID
) to the API Key associated with the supplied email address.
./bin/backup.sh /path/to/dir/
dumps the DB to the specified location (do not omit the trailing slash)
./bin/rebuild-acls.js
purges and rebuilds all ACLs (caution: maybe make a backup before running this...)
There is a bundled redirect-server which can be mapped to legacy-style URLs and redirect them accordingly. Set it up in config.json
and start it with
node ./legacy-redirect.js
Then map it with a regular expression as shown in this example for Nginx:
location ~* ^/[a-z,0-9,-]+/places/[a-z,0-9,-]+$ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://localhost:7070;
proxy_redirect off;
proxy_buffering off;
}
The API is documented using Swagger and is served at /api-docs
at the respective API host. You can start a webserver to view the documentation by running
gulp swagger
The project uses ES6 JavaScript and you are encouraged to lint the code using JSHint before pushing it or creating a pull request.
Uses Mocha and Chai. Run tests with npm test
(tests are far from complete).