Last active
October 1, 2019 06:52
-
-
Save keremcankabadayi/182a46cf10d7dd5d5b0e3b94b13f0865 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require("lodash"); | |
var builder = require('xmlbuilder'); | |
const consts = require('./constants'); | |
var xml = builder.create("epConfiguration", {version: '1.0', encoding: 'UTF-8'}); | |
var newVar; | |
function addChild(sqName, sqValue){ | |
newVar.ele(sqName, sqValue).up(); | |
} | |
function addEnvironment(envName){ | |
newVar = xml.ele(envName); | |
} | |
addEnvironment("env"); | |
addChild("asd", consts.getConsts().env); | |
addChild("dweqd", consts.getConsts().env); | |
addEnvironment("dev"); | |
addChild("devSQ", "dsa"); | |
addChild("devsad", "dsdf"); | |
xml = xml.end({ pretty: true}); | |
module.exports = { | |
xml | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var consts = {}; | |
module.exports.setNewConst = function(key, value){ | |
return consts[key] = value; | |
} | |
module.exports.getConsts = function(){ | |
return consts; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
var _ = require("lodash"); | |
const Env = require("../models/env"); | |
const Url = require("../models/urls"); | |
const operations = require('../services/builder'); | |
const fetchData = require('../services/fetchData'); | |
const consts = require('../services/constants'); | |
const router = express.Router(); | |
router.post("/add", (req, res, next) => { | |
const newEnv = new Env({ | |
tagName: req.body.tagName, | |
context: req.body.context, | |
mockContext: req.body.mockContext, | |
test1Version: req.body.test1Version, | |
test2Version: req.body.test2Version, | |
test3Version: req.body.test3Version, | |
test4Version: req.body.test4Version, | |
test5Version: req.body.test5Version, | |
masterVersion: req.body.masterVersion, | |
isActive: req.body.isActive | |
}); | |
newEnv.save().then(result => { | |
res.status(201).json({ | |
returnCode: 100, | |
message: "Added successfully." | |
}); | |
}); | |
}); | |
router.post("/add/url/:env", (req, res, next) => { | |
const newUrl = new Url({ | |
dev: { | |
d1DevOabMock: req.body.d1DevOabMock, | |
d1DevOabInt: req.body.d1DevOabInt, | |
d1DevCamunda: req.body.d1DevCamunda | |
} | |
}); | |
newUrl.save().then(result => { | |
res.status(201).json({ | |
returnCode: 100, | |
data: {message: "Added successfully."} | |
}); | |
}); | |
}); | |
router.post("/build-envEP", (req, res, next) => { | |
consts.setNewConst("env", req.body.env); | |
res.status(201).type('application/xml').send(operations.xml); | |
}); | |
router.get("/all/envs", (req, res, next) => { | |
Env.find().then(documents => { | |
res.status(200).json({ | |
returnCode: 100, | |
data: documents | |
}); | |
}); | |
}); | |
router.get("/all/urls", (req, res, next) => { | |
Url.find().then(documents => { | |
res.status(200).json({ | |
returnCode: 100, | |
data: documents | |
}); | |
}); | |
}); | |
router.get("/find?:env", (req, res, next) => { | |
Env.find({ env: req.query.env }, { _id: 0 }).then(Env => { | |
res.status(200).json({ | |
returnCode: 100, | |
data: Env | |
}); | |
}); | |
}); | |
router.put("/update/:tagName", (req, res, next) => { | |
Env.updateOne({ "tagName": req.params.tagName }, {"context": req.body.context}, (err, doc) => { | |
if (err) { | |
console.log("Something wrong when updating data!"); | |
} | |
res.status(200).json({ | |
returnCode: 100, | |
message: "Updated successfully." | |
}) | |
}); | |
}); | |
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
├── backend | |
| ├── app.js | |
| ├── models | |
| | ├── env.js | |
| | └── urls.js | |
| ├── routes | |
| | └── envep.js | |
| └── services | |
| ├── builder.js | |
| ├── constants.js | |
| └── fetchData.js | |
├── package-lock.json | |
├── package.json | |
├── README.md | |
└── server.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment