Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git
node_modules
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
npm-debug.log
node_modules
.idea
.dockerrun.sh
.vscode
17 changes: 17 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
FROM node:4.4.1-slim
MAINTAINER Rob Humphris

# Copy the source to the Docker's usr directory
COPY . /usr/src/app

# Set the working directory accordingly
WORKDIR /usr/src/app

#Run npm install
RUN npm install

#Expose node port
EXPOSE 3000

#Start mongo and node
CMD node appAcra.js
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
ACRA Node Server (v. 0.0.3)
ACRA Node Server (v. 0.0.4)
================

Server [ACRA](http://acra.ch/) for [Node.js](http://nodejs.org/) with data base [Mongodb](http://www.mongodb.org/)

Save all the crash reports in your own server.

### version 0.0.4
* Updated to work with Express 4.x
* Updated to work with newer MongoDB


### version 0.0.3
* Statistics by android version.
* Statistics by date error.
Expand All @@ -15,14 +20,12 @@ Save all the crash reports in your own server.

Technologies Used
------------

Server = [node.js, express, ejs, mongodb, emailjs, node-properties-parser, colors, moment, async]

Client = [bootstrap, jquery, tablesorter, jqplot]

Installation
------------

1. Download and unzip (or git clone) into a directory.
2. Run "$ npm install"
3. Configure /acra_server.properties with mongodb, port web, user and password access and email credentials.
Expand All @@ -31,15 +34,13 @@ Installation

Philosophy
------------

* Build a Server to replace Google Docs.
* Write using modern tecnologies as Node.js and Mongodb.
* Simple configuration with a only one properties file.
* Interface using Bootstrap.

Features
------------

* Basic front end web pages.
* Send emails when receive ACRA report.
* Login system to protect access.
Expand Down Expand Up @@ -145,15 +146,13 @@ date_format=YYYY-MM-DD hh:mm:ss
```

## Configuration Mongodb

Automatic configuration:

* Creation of DB automatic
* Creation collection automatic
* Independent collections by App

## Access server

* http://my_server:port_server (and login)


Expand Down
7 changes: 4 additions & 3 deletions acra_server.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ secret = b29a25fe160453b475d4243d12yrty342345752eeaa5bc
# port mongodb
mongodb_port = 27017
# Ip mongodb
mongodb_ip = localhost
#mongodb_ip = localhost
mongodb_ip = db.checkit-develop.elektron-dev.com
# Name Data base
name_database = acraloggerdb


# CONFIGURATION MAIL
# yes or no if want send email if acra error recive
send_mail = yes
send_mail = no

# config connection email server
user_mail= [email protected]
password_mail = password_mail_gmail
host =smtp.gmail.com
host = smtp.gmail.com
ssl = true

# config email
Expand Down
106 changes: 68 additions & 38 deletions appAcra.js
Original file line number Diff line number Diff line change
@@ -1,55 +1,85 @@
var express = require('express');
var colors = require('colors');
var prop = require('./properties.js');
var logger = require('./logger');
var logger = require('morgan');
var acraLogger = require('./logger.js');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser')
var favicon = require('serve-favicon');
var session = require('express-session');
var basicAuth = require('basic-auth');

//function control errors
function clientErrorHandler(err, req, res, next) {
console.log('client error handler found in ip:'+req.ip, err);
res.sendStatus(500);
res.render('error', {locals: {"error":err} });
}

var app = express();

app.configure(function () {
app.use(express.logger('default')); /* 'default', 'short', 'tiny', 'dev' */
app.use(express.bodyParser());
});

app.use(express.static(__dirname + '/public'));
app.use(express.favicon());
app.use(express.cookieParser());
app.use(express.cookieSession({
key:prop.key,
secret :prop.secret,
cookie:{ path: '/', httpOnly: true, maxAge: null }
}));

app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(cookieParser());
app.use(clientErrorHandler);
app.use( express.bodyParser());
app.set('views', __dirname + '/views');
app.set('view engine', 'ejs');
app.use(app.router);
app.use(logger('dev'));
app.use(bodyParser.json());

function auth (req, res, next) {
function unauthorized(res) {
res.set('WWW-Authenticate', 'Basic realm=Authorization Required');
return res.sendStatus(401);
};
var user = basicAuth(req);

//function control errors
function clientErrorHandler(err, req, res, next) {
console.log('client error handler found in ip:'+req.ip, err);
res.status(500);
res.render('error', {locals: {"error":err} });
}
if (!user || !user.name || !user.pass) {
return unauthorized(res);
};

if (user.name === prop.username && user.pass === prop.password) {
return next();
} else {
return unauthorized(res);
};
};

var basicAuth = express.basicAuth(function(username, password) {
return (username == prop.username && password == prop.password);
}, 'Restrict area, please identify');

//Mobile without auth
app.post('/logs/:appid', logger.addLog);
app.post('/logs/:appid', acraLogger.addLog);
app.put('/logs/:appid', acraLogger.addLog);

//Administration with auth
app.get('/logs/:appid/:id', basicAuth, logger.findByIdDetail);
app.get('/logsexport/:appid/:id', basicAuth, logger.findByIdDetailExport);
app.get('/logs/:appid', basicAuth, logger.findAll);
app.get('/logsexport/:appid', basicAuth, logger.findAllExport);
app.get('/mobiles', basicAuth, logger.findAllCollections);
app.get('/logs/:appid/:id/delete', basicAuth, logger.deleteLog);
app.get('/logout', logger.logout);
app.get('/logs/:appid/:id', auth, acraLogger.findByIdDetail);
app.get('/logsexport/:appid/:id', auth, acraLogger.findByIdDetailExport);
app.get('/logs/:appid', auth, acraLogger.findAll);
app.get('/logsexport/:appid', auth, acraLogger.findAllExport);
app.get('/mobiles', auth, acraLogger.findAllCollections);
app.get('/logs/:appid/:id/delete', auth, acraLogger.deleteLog);
app.get('/logout', acraLogger.logout);

prop.loadProperties(() => {
acraLogger.open(prop, function(err) {
app.use(session({
secret: prop.secret,
resave: false,
saveUninitialized: false,
cookie: { path: '/', httpOnly: true, secure: true, maxAge: null }
}));
console.log("------------------".yellow);
app.listen(prop.portWeb);
console.log('Listening on port '.yellow+prop.portWeb.red);
});
});









console.log("------------------".yellow);
app.listen(prop.portWeb);
console.log('Listening on port '.yellow+prop.portWeb.red);



1 change: 1 addition & 0 deletions dockerrun.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker run -d --name acra-node-server --link mongo:mongodb elektron/acra-node-server
7 changes: 5 additions & 2 deletions email.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var server = email.server.connect({
ssl: prop.ssl
});

exports.send = function send (mobile,log) {
exports.send = function send(mobile,log) {
if (prop.send_mail == 'yes') {
console.log('Send email with error model:'+log.PHONE_MODEL);
// send the message and get a callback with an error or details of the message that was sent
Expand All @@ -24,7 +24,10 @@ exports.send = function send (mobile,log) {
to: prop.to,
cc: "",
subject: prop.subject+ " from Mobile "+mobile
}, function(err, message) { console.log(err || message); });
}, (err, message) =>
{
console.log(err || message);
});
}
}

Expand Down
Loading