'use strict'

let pkgs = require('../../extensions/registry').load()

module.exports = {
  getAvailableTypes: function getAvailableTypes(req, res) {
    let stages = []

    for (let vendor in pkgs) {
      for (let ext in pkgs[vendor]) {
        for (let stage in pkgs[vendor][ext].stages) {
          stages.push({
            id: [vendor, ext, stage].join('.'),
            name: stage
          })
        }
      }
    }

    res.status(201).send({data: stages})
  }
}

@@ -11,20 +11,24 @@
 t'%0A%0Alet 
-pkgs
+registry
  = requi
@@ -62,15 +62,8 @@
 ry')
-.load()
 %0A%0Amo
@@ -79,16 +79,195 @@
 rts = %7B%0A
+  createStageConfig: function createStageConfig(req, res) %7B%0A    const STAGE_ID = req.body.stage_id%0A    const STAGE = registry.get(STAGE_ID)%0A%0A    console.log('stage', STAGE)%0A%0A  %7D,%0A
   getAva
@@ -314,24 +314,55 @@
 req, res) %7B%0A
+    let pkgs = registry.load()%0A
     let stag
@@ -489,24 +489,187 @@
 %5D.stages) %7B%0A
+          let vendorName = pkgs%5Bvendor%5D%5Bext%5D.vendor%0A          let extName = pkgs%5Bvendor%5D%5Bext%5D.name%0A          let stageName = pkgs%5Bvendor%5D%5Bext%5D.stages%5Bstage%5D.name%0A%0A
           st
@@ -707,20 +707,32 @@
 ndor
+Name
 , ext
+Name
 , stage
+Name
 %5D.jo

save sage config