// var restful = require('node-restful'),
//     path = require('path'),
//     mongoose = restful.mongoose;

var express = require('express');


module.exports = function register(app){
    console.log('REGISTER models');

    var restful = require('../lib/restful');
    var models = require('./device');

    restful.addResource({
        app: app,
        urlPrefix: 'api',
        resourceName: 'devices',
        collection: models.Device
    });

    restful.addResource({
        app: app,
        urlPrefix: 'api',
        resourceName: 'locations',
        collection: models.Location
    });

    restful.addResource({
        app: app,
        urlPrefix: 'api',
        resourceName: 'sublocations',
        collection: models.Sublocation
    });

    restful.addResource({
        app: app,
        urlPrefix: 'api',
        resourceName: 'device-types',
        collection: models.DeviceType
    });

    return
    //curl -H "Content-Type: application/json" -d '{"uuid":"xyz","token":"AD90ADF90ADF88ADF0ADF", "timestamp":1423761255422}' http://localhost:3000/api/devices
    var Device = app.Device = restful.model('device', mongoose.Schema({
        uuid: 'string',
        type: 'string',

        // token:'string',
        // objectId: mongoose.Schema.ObjectId,
        timestamp:  'number',
    }))
    .methods(['get', 'post', 'put', 'delete']);

    Device.route('scan.get', function(req, res, next) {
        res.send('DEVICE:I have a recommendation for you!');
    });

    Device.register(app, '/api/devices');
};

process.on('SIGINT', function() {
    mongoose.connection.close(function () {
        console.log('SIGINT: Mongoose default connection disconnected.');
        process.exit(0);
    });
});

// var db = require('./../mongooseModels'),
//     restful = require('../restful');

// restful.addResource({
//   app: app,
//   urlPrefix: 'api',
//   resourceName: 'users',
//   collection: db.user
// });

@@ -1,113 +1,4 @@
-// var restful = require('node-restful'),%0A//     path = require('path'),%0A//     mongoose = restful.mongoose;%0A
 %0Avar
@@ -1427,403 +1427,4 @@
 %0A%7D;%0A
-%0Aprocess.on('SIGINT', function() %7B%0A    mongoose.connection.close(function () %7B%0A        console.log('SIGINT: Mongoose default connection disconnected.');%0A        process.exit(0);%0A    %7D);%0A%7D);%0A%0A// var db = require('./../mongooseModels'),%0A//     restful = require('../restful');%0A%0A// restful.addResource(%7B%0A//   app: app,%0A//   urlPrefix: 'api',%0A//   resourceName: 'users',%0A//   collection: db.user%0A// %7D);%0A

index remove cruft