Recommit everything because of credentials

This commit is contained in:
Maciej Małecki 2014-03-07 23:15:56 +01:00
commit 11fb50a2f1
11 changed files with 267 additions and 0 deletions

24
.gitignore vendored Normal file
View file

@ -0,0 +1,24 @@
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
node_modules
npm-debug.log
mochahelper.js
.idea/
.settings/
dist
.tmp
.sass-cache
app/bower_components
options.mine.js

35
.jshintrc Normal file
View file

@ -0,0 +1,35 @@
{
"white": false,
"node": true,
"browser": true,
"esnext": true,
"bitwise": true,
"camelcase": true,
"curly": true,
"eqeqeq": true,
"immed": true,
"indent": 2,
"latedef": true,
"newcap": true,
"noarg": true,
"quotmark": "single",
"regexp": true,
"undef": true,
"unused": true,
"strict": true,
"trailing": true,
"smarttabs": true,
"globals": {
"angular": true,
"document": true,
"nf": true,
"$":true,
"_":true,
"Highcharts": true,
"timeseries": true,
"describe": true,
"beforeEach": true,
"afterEach": true,
"it": true
}
}

1
Procfile Normal file
View file

@ -0,0 +1 @@
web: node lib/app.js

38
README.md Normal file
View file

@ -0,0 +1,38 @@
# lamassu-server
Lamassu remote server.
## Installation
```sh
git clone git@github.com:lamassu/lamassu-server.git
cd lamassu-server
npm install
```
If you're working on this stack, you probably want to `npm link`
[`lamassu-atm-protocol`](https://github.com/lamassu/lamassu-atm-protocol).
```sh
git clone git@github.com:lamassu/lamassu-atm-protocol.git
cd lamassu-atm-protocol
npm install
npm link
```
```sh
# Back in lamassu-server
npm link lamassu-atm-protocol
```
## Running
```sh
node lib/app.js --https
```
The https flag is required for local testing. When deployed to a PAAS environment - such as heroku, the https flag is not required,
as the SSL connection typically terminates on the load balancer and the application will see http only.
## Deployment
Deployment of this application is described in
[`lamassu-admin`](https://github.com/lamassu/lamassu-admin) documentation.

6
config/postgres.json Normal file
View file

@ -0,0 +1,6 @@
{
"user": "lamassu",
"pwd": "lamassu",
"host": "localhost",
"db": "lamassu"
}

15
deploy.sh Executable file
View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
git remote | grep heroku
if [ $? -ne 0 ]; then
echo "Creating Heroku application..."
heroku apps:create
fi
if [ -n "$DATABASE_URL" ]; then
echo "Setting DATABASE_URL..."
heroku config:set DATABASE_URL="$DATABASE_URL"
fi
echo "Deploying..."
git push heroku master

69
lib/app.js Normal file
View file

@ -0,0 +1,69 @@
/*jshint globalstrict: true, white: false, unused:false */
/*globals require, exports, console, module, process */
/*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
'use strict';
var path = require('path');
var express = require('express');
var argv = require('optimist').argv;
var app = express();
var fs = require('fs');
var argv = require('optimist').argv;
var LamassuConfig = require('lamassu-config');
var atm = require('lamassu-atm-protocol');
var format = require('util').format;
var conString, dbConfig, config;
if (process.env.DATABASE_URL) {
conString = process.env.DATABASE_URL;
}
else {
dbConfig = require('../config/postgres.json');
conString = format('postgres://%s:%s@%s/%s', dbConfig.user, dbConfig.pwd, dbConfig.host, dbConfig.db);
}
config = new LamassuConfig(conString);
var port = process.env.PORT || 3000;
app.use(express.logger());
app.use(express.favicon());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('your secret here'));
app.use(express.session());
config.load(function(err, conf) {
if (err) { console.log(err); process.exit(1); }
atm.init(app, conf.config);
if (argv.https) {
var https = require('https');
var testkeys = path.join(__dirname, '..', 'testkeys');
var privateKey = fs.readFileSync(path.join(testkeys, 'privatekey.pem'));
var certificate = fs.readFileSync(path.join(testkeys, 'certificate.pem'));
var credentials = {key: privateKey, cert: certificate};
https.createServer(credentials, app).listen(port, function () {
console.log('Express server listening on port ' + port + ' (https)');
});
}
else {
var http = require('http');
http.createServer(app).listen(port, function () {
console.log('Express server listening on port ' + port + ' (http)');
});
}
});

34
package.json Normal file
View file

@ -0,0 +1,34 @@
{
"name": "lamassu-server",
"description": "bitcoin atm client server protocol module",
"keywords": [],
"version": "0.0.1",
"license": "MIT",
"author": "Peter Elger (http://nearform.com/)",
"contributors": [
"Peter Elger <elger.peter@gmail.com> (http://peterelger.com/)"
],
"engines": {
"node": "0.10.x"
},
"dependencies": {
"express": "~3.4.7",
"optimist": "~0.6.0",
"lamassu-config": "~0.1.1",
"lamassu-atm-protocol": "git+https://github.com/lamassu/lamassu-atm-protocol.git"
},
"repository": {
"type": "git",
"url": "https://github.com/lamassu/lamassu-server.git"
},
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.6.0",
"load-grunt-tasks": "~0.1.0",
"chai": "~1.8.1",
"matchdep": "~0.3.0",
"mocha": "~1.13.0",
"grunt-mocha-test": "~0.7.0",
"grunt-mocha-cov": "0.0.7"
}
}

17
testkeys/certificate.pem Normal file
View file

@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICozCCAgwCCQCSX2bhri8GETANBgkqhkiG9w0BAQUFADCBlTELMAkGA1UEBhMC
SUUxEjAQBgNVBAgTCVdhdGVyZm9yZDESMBAGA1UEBxMJV2F0ZXJmb3JkMREwDwYD
VQQKEwhuZWFyRm9ybTEMMAoGA1UECxMDZGV2MRQwEgYDVQQDEwtQZXRlciB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381KEAqePpKn+RhF70R8QJADqwEUtt0sZmjjFSXrAMTXehK3GO+
QgYmpYQl7Xa5bh4J6xDtv85Bk+aVykTvcbUw6pfOFZM/Hwk11rpak7vE0QJAEFGD
mvppm3WQk55G3AfKi/t3kw68nnbg4YCaQ30MIjqtv0O8djdR2Wcb9FBtFY/BR9Ol
bCGAYGUq7HFLo041wQJBAL2x2OvwnYYtXXOBY27tox3B1hDye7jRI5Q/IvcRB7YE
00q8L0XVaV4lmyd7tfFDQq/bfDUgTuwvkSPnQcpJDDw=
-----END RSA PRIVATE KEY-----