var epilogue = require('epilogue');
var db = require('../models');
var middlewares = require('./middlewares')

// Init Epilogue
var initialize = function(app) {
  epilogue.initialize({
    app: app,
    sequelize: db.sequelize
  });

  // Create REST resources
  var attributeResource = epilogue.resource({
    model: db.attribute,
    endpoints: ['/api/v2/attribute', '/api/v2/attribute/:id']
  });

  var refResource = epilogue.resource({
    model: db.ref,
    endpoints: ['/api/v2/ref', '/api/v2/ref/:id']
  });

  var userResource = epilogue.resource({
    model: db.user,
    endpoints: ['/api/v2/users', '/api/v2/user/:id']
  });

  var traitResource = epilogue.resource({
    model: db.trait,
    endpoints: ['/api/v2/trait', '/api/v2/trait/:id']
  });

  var environmentResource = epilogue.resource({
    model: db.environment,
    endpoints: ['/api/v2/environment', '/api/v2/environment/:id']
  });

  var taxonResource = epilogue.resource({
    model: db.taxon,
    endpoints: ['/api/v2/taxa', '/api/v2/taxa/:id']
  });

  var datasetResource = epilogue.resource({
    model: db.dataset,
    endpoints: ['/api/v2/dataset', '/api/v2/dataset/:id']
  });

  var networkResource = epilogue.resource({
    model: db.network,
    endpoints: ['/api/v2/network', '/api/v2/network/:id']
  });

  var interactionResource = epilogue.resource({
    model: db.interaction,
    endpoints: ['/api/v2/interaction', '/api/v2/interaction/:id']
  });

  var taxaBackResource = epilogue.resource({
    model: db.taxo_back,
    endpoints: ['/api/v2/taxa_back', '/api/v2/taxa_back/:id']
  });

  // Protections ressources with middlewares
  attributeResource.use(middlewares);
  refResource.use(middlewares);
  userResource.use(middlewares);
  traitResource.use(middlewares);
  environmentResource.use(middlewares);
  taxonResource.use(middlewares);
  datasetResource.use(middlewares);
  networkResource.use(middlewares);
  interactionResource.use(middlewares);
  taxaBackResource.use(middlewares);

};

module.exports = {
  initialize: initialize
};

@@ -481,16 +481,22 @@
 i/v2/ref
+erence
 ', '/api
@@ -502,16 +502,22 @@
 i/v2/ref
+erence
 /:id'%5D%0A 
@@ -612,17 +612,16 @@
 /v2/user
-s
 ', '/api
@@ -1546,22 +1546,21 @@
 i/v2/tax
-a_back
+onomy
 ', '/api
@@ -1570,14 +1570,13 @@
 /tax
-a_back
+onomy
 /:id

Change endpoints