A RFC 5222 compatible node.js based LoST server.
Basic idea for this project was to have a very lightwight implementation of a RFC 5222 lost server to perform tests with. At the time as development starts there where no public implementations for my testing purposes available so lost-node was born.
lost-node should be:
- very lightwight and performant. So node.js and mongodb are used.
- easy to develop and play with (even just on an USB-stick on the go)
- should use Open Data Protocol (oData) to connect to the backend database as well as use oData to clients (e.g. for a management client). See the following links for more infos:
- should include a testing application to play with lost request
- should be easily deployable to the cloud (e.g. amazon, azure, mongolab ...)
- should use the XML relax ng schema for request validation directly from the RFC (hence libxml which provides relax ng support). For more infos see:
First ensure that all dependencies are available on the server:
- mongodb
- node.js
To install lost-node first place the distribution zip file
"lost.zip" which is created during buid somewhere on your
server and unzip it. Then install all required node.js
modules with npm install --production
inside the dist
folder. This also triggers some native build
processes for some node modules (e.g. xmllib).
If you use Windows see the notes section for more infos.
Next change folder to dist/config/env/
and modify an existing
configuration (production.js, development.js) or create a
new one. After this change the start_server
shell script
to match your configuration.
First start the mongodb server (if it is not already running) with the
start_mongo.[sh|cmd]
shell script. Then in another shell start
the server with start_server.[sh|cmd]
. Now open your browser
and navigate to http://locahost:8080.
start_server -i
creates an empty (or deletes an existing) lost mongodb database.
start_server -f filename
imports a JSON file into the database.
start_server -d directory
imports all JSON files in the specified
directory into the database.
start_server -t
creates some testing data. At the moment 4
areas (all inside Austria: Vienna, Linz and Salzburg) and two
services (urn:service:sos.police and urn:service:sos.fire)
are created. The test data JSON files are located in the testdata
directory. You can use it as examples how to import data using the
-f
or -d
options. start_server -t
is equivalent to start_server -d testdata
.
start_server --help
displays a help text.
start_server
without options just starts the LoST server itself.
To change TCP port, url etc. edit config/env/development.js
or
config/env/production.js
.
If you run the server in an environment like Microsoft IISNODE as used
in the Microsoft Azure cloud the environment variables
LISTEN
and PORT
overrule all other settings from config files.
To play with LoST request and responses the included lost-tester allows to select one of the four LoST reuests (findService, getServiceBoundary, listServices and listServicesByLocation), a location on the map and a requested service which are integrated into the request. The service response is then displayed.
If you want to try out lost-node live, a demo instance can be reached here: http://lost-node.azurewebsites.net. There are only very few areas available at the moment. The Cities of Vienna, Linz and Salzburg in Austria (Europe) with service types urn:service:sos.fire and urn:service:sos.police.
If you have a LoST client available yourself the service URL is http://lost-node.azurewebsites.net/lost.svc. Just http post your LoST requests there.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
To start development ensure you have the following dependecies installed:
- node.js
Download and install node from https://nodejs.org/en/ - grunt-cli
Install usingnpm install -g grunt-cli
- bower
Install usingnpm install -g bower
- tsd
Install usingnpm install -g tsd
- For some node modules a native build environment is needed
- gcc for linux
- Visual Studio (Express) on windows.
- optional: Visual Studio Code (vscode)
Download and install from https://code.visualstudio.com/
Then inside the lost-node folder issue the following commands:
npm install
If you use Windows see the notes section for more infos.bower install
tsd install
- open lost-node folder with vscode and start coding
- CTRL+SHIFT+B in vscode builds project - or -
to build project from command line enter
grunt build
- After build
dist
folder contains redistributable built project (also available in compressedlost.zip
archive in project root folder) grunt release
builds project in "mangled/encrypted" form- To run project enter:
start_mongo
and thenstart_server
start_server -t
creates testing data.- F5 in vscode starts server (and server debugging)
It would also be great to have more (international, maybe real life) testing data available. So controbutions her are very wolcome.
##Notes
-
lost-node is developed with:
- node.js version 4.2.2 (64bit)
- mongodb version 3.0.7
- Visual Studio Code version 0.10.3
-
JayData odata-server / jaydata 1.3.6 node module does not work with mongodb client >= 2.0 (see https://www.mongodb.com/blog/post/introducing-nodejs-mongodb-20-driver) So use the latest 1 version (1.4.39) instead. This is also defined in package.json
-
You can use
- LINQPad https://www.linqpad.net/
- Sesame Data Browser http://metasapiens.com/sesame/data-browser/preview/
to access the LoST database using odata via
-
Also note that this version is not complete und highly untested. Feel free to contribute to make lost-node better. Especially missing in this version are forward and redirect functionalities and a management frontend.
-
For windows, binaries for mongodb, the VUE admin tool and the libxmljs node modules are included. So you dont need mongodb or Visual Studio installed on windows. The precompiled windows module binaries are 64bit versions! If you use a 32bit node you have to compile 32bit modules yourself. To use it follow this instructions:
- before running
npm install
copy thepackage.json
file to a safe place. Next remove the following lines in the dependencies section frompackage.json
:- libxml-to-js
- libxmljs
- mongodb
- odata-server
- run
npm install
- inside the
build
folder you will findwindows_prebuilt_modules.zip
. Extract its contents into thenode_modules
folder. - Restore the
package.json
backup from point 1. - Run
npm install
again to install the remaining dependencies. - Now you should have all dependencies installed.
- before running
-
The LoST testing application supports multiple map providers. For Google and Microsoft BING Maps you will need an API key. See the notes in the corresponding soures files:
- source/client/test.html - Google Maps
- source/client/assets/js/nl.map.js - BING Maps
- Alpha Version 15.4.2015
- First Beta 21.11.2015
Credits go to all used components like node modules or libraries.
This project is under GNU GPLv3. See file gpl-3.0.txt in this project or http://www.gnu.org/licenses/gpl-3.0.html