-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
85 lines (64 loc) · 2.9 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var vsts = require('./modules/vsts');
const express = require('express')
const app = express()
const path = require('path')
const exphbs = require('express-handlebars')
var bodyParser = require('body-parser');
var urlencodedParser = bodyParser.urlencoded({ extended: true });
const port = 8888
app.engine('.hbs', exphbs({
defaultLayout: 'main',
extname: '.hbs',
layoutsDir: path.join(__dirname, 'views/layouts')
}))
app.set('view engine', '.hbs')
app.set('views', path.join(__dirname, 'views'))
app.get('/', (request, response) => {
response.render('home', {
name: 'Rodrigo Brandão'
})
})
app.get('/workItem/add', (request, response) => {
response.render('workItemAdd', {})
})
app.post('/workItem/Created', urlencodedParser, (request, response) => {
var form = request.body;
var workitem = {
Id: 0,
Title: form.txtTitle,
AssignedTo: form.txtAssignedTo,
AreaPath: "AtentoBR\\Estudo",
IterationPath:"AtentoBR\\Estudo",
Description: form.txtDescription,
Content: ""
};
var attach;
var workItemAdded = vsts.workItemAdd(workitem);
workItemAdded.then(wi=> {
var content = 'protocolo número ' + wi.id + '\n' +
'area path ' + wi.fields["System.AreaPath"] + '\n' +
'AssignTo ' + wi.fields["System.AssignedTo"] + '\n' +
'Acompanhe sua solicitação em: https://atentoalm.visualstudio.com/AtentoBR/_boards/board/t/Estudo/Requirements';
workitem.Id = wi.id;
workitem.Content = content;
//email.sendEmail('Solicitação criada com sucesso', content);
})
.then(()=>{
attachmentAdded = vsts.attachmentAdd();
attachmentAdded.then(attach=> {
vsts.workItemAtt({id: workitem.Id, url: attach.url})
});
})
.then(()=> {
response.render('workItemCreated', {WorkItem:workitem});
})
})
app.get('/workItem/get', (request, response) => {
response.render('workItemGet', {})
})
app.listen(port, (err) => {
if (err) {
return console.log('something bad happened', err)
}
console.log(`server is listening on ${port}`)
})