Commit a9dd6644 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

Mise en paramètre de configuration du serveur NodeJS

parent c732aa92
Loading
Loading
Loading
Loading
+2 −0
Changes for .gitignore: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,9 +3,11 @@ config/autoload/local.php
config/autoload/unicaen-app.local.php
config/autoload/unicaen-auth.local.php


# Connecteurs
/config/connectors/*.yml
!/config/connector/*.yml.dist
socket/config.json

# Documentation
/doc/*.pdf
+12 −0
Changes for socket/config.json.dist: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
    "bdd": {
        "user": "oscar_empty",
        "host": "localhost",
        "base": "oscar_empty",
        "pass": "azerty"
    },
    "socket": {
        "port": 3000,
        "push_path": "/scr2a548f96E712v54398560125408795"
    }
}
 No newline at end of file
+8 −7
Changes for socket/server.js: 8 added lines, 7 removed lines.
Original line number Diff line number Diff line
@@ -2,7 +2,8 @@ var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var pg = require('pg');
var bodyParser = require('body-parser')
var bodyParser = require('body-parser');
var config = require('./config.json');

app.use( bodyParser.json() );       // to support JSON-encoded bodies
app.use(bodyParser.urlencoded({     // to support URL-encoded bodies
@@ -16,13 +17,13 @@ app.get('/', function(req, res){
    res.sendFile(__dirname + '/index.html');
});

app.post('/push', function(req, res){
app.post(config.socket.push_path, function(req, res){
    var ids = req.body.ids.split(',');
    var client = new pg.Client({
        user: 'oscar_empty',
        host: 'localhost',
        database: 'oscar_empty',
        password: 'azerty'
        user: config.bdd.user,
        host: config.bdd.host,
        database: config.bdd.base,
        password: config.bdd.pass
    });
    client.connect();
    client.query('SELECT * FROM notification WHERE id IN(' +ids.join(',') + ')', function(err, result){
@@ -109,6 +110,6 @@ io.on('connection', function(socket){
    }
});

http.listen(3000, function(){
http.listen(config.socket.port, function(){
    console.log('listening on *:3000');
});
 No newline at end of file