/**
 * @module server/lib/routes/get/sequences
 */
'use strict';

var app = require('app');
var log = require('lib/logger')(__filename);
var sequences = require('models/sequences');

var exports = module.exports;

exports._getSequenceTypes = [
  (req, res, next) => {
    var spec = sequences.getSequences();
    res.send(spec);
    next();
  }
];

exports._getSequences = [
  (req, res, next) => {
    sequences.getSequenceDocuments(req.params.sequenceName, (err, sequenceDocuments) => {
      if (err) { return next(err); }
      res.send(sequenceDocuments);
      next();
    });
  }
];

var _routes = exports._routes = [
  ['get', '/sequences', exports._getSequenceTypes],
  ['get', '/sequences/:sequenceName', exports._getSequences],
];

/**
 * Bind route middlewares to request paths
 * @param {Object} app instance of express
 */
exports.initialize = () => {
  _routes.forEach((route) => {
    log.trace([
      'Route loaded:',
    ].concat(route).join(' '));
    app[route[0]]('/api'+route[1], route[2]);
  });
};

@@ -584,16 +584,408 @@
   %7D%0A%5D;%0A%0A
+exports._getSequence = %5B%0A  (req, res, next) =%3E %7B%0A    sequences.getSequenceDocuments(req.params.sequenceName, req.params.sequenceUuid,%0A                                   (err, sequenceDocument) =%3E %7B%0A      if (err) %7B return next(err); %7D%0A      if (!sequenceDocument) %7B%0A        return next(new Error('Sequence not found'));%0A      %7D%0A      res.send(sequenceDocument);%0A      next();%0A    %7D);%0A  %7D%0A%5D;%0A%0A
 var _rou
@@ -1124,16 +1124,90 @@
 ences%5D,%0A
+  %5B'get', '/sequences/:sequenceName/:sequenceUuid', exports._getSequence%5D%0A
 %5D;%0A%0A/**%0A

Add new GET routes