diff --git a/.flowconfig b/.flowconfig new file mode 100644 index 000000000..4a58bdcde --- /dev/null +++ b/.flowconfig @@ -0,0 +1,7 @@ +[ignore] + +[include] + +[libs] + +[options] diff --git a/.travis.yml b/.travis.yml index 24288c6f2..4160b8719 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ node_js: - "6.6.0" before_script: - npm run-script lint - - cp config.js.dist config.js + - cp config.example.js config.js - npm install bower - ./node_modules/bower/bin/bower install - node ./server.js & diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index b1d2515f1..0d1d94873 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -76,7 +76,7 @@ Chainpad can handle out of order messages, but it performs best when its message By architecting your system such that all clients send to a server which then relays to other clients, you guarantee that a particular chain of patches is consistent between the participants of your session. Cryptpad is capable of using a variety of data stores. -Which data store your instance employs can be [easily configured](https://github.com/xwiki-labs/cryptpad/blob/master/config.js.dist). +Which data store your instance employs can be [easily configured](https://github.com/xwiki-labs/cryptpad/blob/master/config.example.js). You simply need to write an adaptor which conforms to a simple API. The documentation for writing such an adaptor, and the complete list of implemented adaptors, is available [here](https://github.com/xwiki-labs/cryptpad/tree/master/storage). @@ -243,5 +243,3 @@ A session could still have difficulty with very large chains, however, in practi ## Conclusion - - diff --git a/config.js.dist b/config.example.js similarity index 99% rename from config.js.dist rename to config.example.js index 6ef7267c1..692a91c59 100644 --- a/config.js.dist +++ b/config.example.js @@ -1,3 +1,4 @@ +/*@flow*/ /* globals module */ diff --git a/container-start.sh b/container-start.sh index 89f3be1f1..2aa4ae10f 100755 --- a/container-start.sh +++ b/container-start.sh @@ -4,12 +4,12 @@ mkdir -p customize [ -z "$(ls -A customize)" ] && echo "Creating customize folder" \ && cp -R customize.dist/* customize/ \ - && cp config.js.dist customize/config.js + && cp config.example.js customize/config.js -# Linking config.js +# Linking config.js [ ! -h config.js ] && echo "Linking config.js" && ln -s customize/config.js config.js -# Configure +# Configure [ -n "$USE_SSL" ] && echo "Using secure websockets: $USE_SSL" \ && sed -i "s/useSecureWebsockets: .*/useSecureWebsockets: ${USE_SSL},/g" customize/config.js diff --git a/readme.md b/readme.md index b3c8a1a61..60da12331 100644 --- a/readme.md +++ b/readme.md @@ -32,8 +32,8 @@ npm install npm install -g bower ## if necessary bower install -## copy config.js.dist to config.js -cp config.js.dist config.js +## copy config.example.js to config.js +cp config.example.js config.js node ./server.js ``` @@ -162,4 +162,3 @@ sales@xwiki.com [fragment identifier]: https://en.wikipedia.org/wiki/Fragment_identifier [active attack]: https://en.wikipedia.org/wiki/Attack_(computing)#Types_of_attacks [Creative Commons Attribution 2.5 License]: http://creativecommons.org/licenses/by/2.5/ - diff --git a/rpc.js b/rpc.js index d68fa78b4..808815d84 100644 --- a/rpc.js +++ b/rpc.js @@ -1,3 +1,4 @@ +/*@flow*/ /* Use Nacl for checking signatures of messages */ var Nacl = require("tweetnacl"); @@ -375,7 +376,8 @@ var resetUserPins = function (store, Sessions, publicKey, channelList, cb) { }); }; -RPC.create = function (config, cb) { +/*::const ConfigType = require('./config.example.js');*/ +RPC.create = function (config /*:typeof(ConfigType)*/, cb /*:(?Error, ?Function)=>void*/) { // load pin-store... console.log('loading rpc module...'); @@ -384,7 +386,11 @@ RPC.create = function (config, cb) { var store; - var rpc = function (ctx, data, respond) { + var rpc = function ( + ctx /*:{ store: Object }*/, + data /*:Array>*/, + respond /*:(?string, ?Array)=>void*/) + { if (!Array.isArray(data)) { return void respond('INVALID_ARG_FORMAT'); } @@ -494,4 +500,3 @@ RPC.create = function (config, cb) { }, 60000); }); }; - diff --git a/storage/README.md b/storage/README.md index 03117d95c..8fabdf53b 100644 --- a/storage/README.md +++ b/storage/README.md @@ -46,14 +46,14 @@ While we migrate to our new Netflux API, only the leveldb adaptor will be suppor ## removeChannel(channelName, callback) -This method is called (optionally, see config.js.dist for more info) some amount of time after the last client in a channel disconnects. +This method is called (optionally, see config.example.js for more info) some amount of time after the last client in a channel disconnects. It should remove any history of that channel, and execute a callback which takes an error message as an argument. ## Documenting your adaptor Naturally, you should comment your code well before making a PR. -Failing that, you should definitely add notes to `cryptpad/config.js.dist` such that people who wish to install your adaptor know how to do so. +Failing that, you should definitely add notes to `cryptpad/config.example.js` such that people who wish to install your adaptor know how to do so. Notes on how to install the back end, as well as how to install the client for connecting to the back end (as is the case with many datastores), as well as how to configure cryptpad to use your adaptor. The current configuration file should serve as an example of what to add, and how to comment.