const HydraServiceFactory = require('hydra-integration').HydraServiceFactory;
const config = require('config');
const service = require('restana')();


service.use((req, res, next) => {
    let token = req.headers['authorization'] || '';
    if (!token.endsWith(config.service.accessToken || '')) {
        res.statusCode = 403;
        res.statusMessage = 'Forbidden';
    }

    next();
});
service.start(5000);

const factory = new HydraServiceFactory(config.service);
factory.init().then(factory => {
    let prefix = config.service.routesPrefix;
    service.get(`${prefix}/srv`, require('./actions/all-srv')(factory.getHydra()));
    service.get(`${prefix}/srv/:service/routes`, require('./actions/srv-routes')(factory.getHydra()));
    service.get(`${prefix}/srv/:service/nodes`, require('./actions/srv-nodes')(factory.getHydra()));

    factory.sync(service);
});



// supporting tests coverage
if (process.env.NODE_ENV === 'testing') {
    require('./tests')(factory, describe, it);
}
@@ -4,30 +4,33 @@
 st Hydra
-ServiceFactory
+IntegrationPlugin
  = requi
@@ -62,57 +62,239 @@
 ydra
-ServiceFactory;%0Aconst config = require('config');
+IntegrationPlugin;%0Aconst HydraHttpPlugin = require('hydra-plugin-http').HydraHttpPlugin;%0Aconst config = require('config');%0Aconst hydra = require('hydra');%0A%0Ahydra.use(new HydraIntegrationPlugin());%0Ahydra.use(new HydraHttpPlugin());%0A
 %0Acon
@@ -328,18 +328,16 @@
 na')();%0A
-%0A%0A
 service.
@@ -573,170 +573,111 @@
 %7D);%0A
-service.start(5000);%0A%0Aconst factory = new HydraServiceFactory(config.service);%0Afactory.init().then(factory =%3E %7B%0A    let prefix = config.service.routesPrefix;%0A    
+let prefix = config.service.routesPrefix;%0Aservice.get(%60/_health%60, require('./actions/health')(hydra));%0A
 serv
@@ -734,34 +734,17 @@
 v')(
-factory.getH
+h
 ydra
-()
 ));%0A
-    
 serv
@@ -820,34 +820,17 @@
 s')(
-factory.getH
+h
 ydra
-(
 ))
-)
 ;%0A
-    
 serv
@@ -904,42 +904,222 @@
 s')(
-factory.getHydra()));%0A%0A    factory
+hydra));%0Aservice.get(%60/*%60, require('./actions/proxy-router')(hydra, config));%0Aservice.start(5000);%0A%0A(async() =%3E %7B%0A    await hydra.init(config.service);%0A    await hydra.registerService();%0A    await hydra.integration
 .syn
@@ -1136,13 +1136,15 @@
 ;%0A%7D)
-;
+();%0A
 %0A%0A%0A
-%0A
 // s
@@ -1237,15 +1237,13 @@
 s')(
-factory
+hydra
 , de

structure refactorization