var express = require('express');
var bodyParser = require('body-parser');
var Database = require('./db');
var db = new Database();

var app = express();
app.use(bodyParser.json());

app.get('/api', function (req, res) {
    var payload = {user: 1};
    db.find(payload, function(results){
        return res.json(results);
    });
});

app.post('/api', function (req, res) {
    var payload = {user: 1};
    var data = {user: 1, led: true};
    if (req.body.led === true) {
        data.led = true;
    }

    db.find(payload, function(results){
        if(results.length>0){
            db.update(data);
            res.send({db: "update"});
        } else {
            db.insert(data);
            res.send({db: "insert"});
        }
    });
});

app.put('/api', function (req, res) {
    var payload = {user: 1};
    var data = {user: 1, led: true};
    if (req.body.led === true) {
        data.led = true;
    }

    db.find(payload, function(results){
        if(results.length>0){
            db.update(data);
            res.send({db: "update"});
        } else {
            db.insert(data);
            res.send({db: "insert"});
        }
    });
});

app.delete('/api', function (req, res) {
    data.method = 'delete';
    data = {};
    res.send(data);
});

app.listen(3000);
@@ -185,24 +185,33 @@
 pp.get('/api
+/:user_id
 ', function 
@@ -244,25 +244,42 @@
 ad = %7Buser: 
-1
+req.params.user_id
 %7D;%0A    db.fi
@@ -366,24 +366,33 @@
 p.post('/api
+/:user_id
 ', function 
@@ -421,33 +421,50 @@
 ayload = %7Buser: 
-1
+req.params.user_id
 %7D;%0A    var data 
@@ -464,33 +464,50 @@
 r data = %7Buser: 
-1
+req.params.user_id
 , led: true%7D;%0A  
@@ -822,24 +822,33 @@
 pp.put('/api
+/:user_id
 ', function 
@@ -885,17 +885,34 @@
  %7Buser: 
-1
+req.params.user_id
 %7D;%0A    v
@@ -932,9 +932,26 @@
 er: 
-1
+req.params.user_id
 , le

Add support for user id