forked from dmolchanenko/RedwoodHQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
205 lines (167 loc) · 7.23 KB
/
app.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**
* Module dependencies.
*/
var express = require('express')
, routes = require('./routes')
, variables = require('./routes/variables')
, scripts = require('./routes/scripts')
, folder = require('./routes/folder')
, script = require('./routes/script')
, users = require('./routes/users')
, projects = require('./routes/projects')
, variableTags = require('./routes/variableTags')
, userTags = require('./routes/userTags')
, userStates = require('./routes/userStates')
, machines = require('./routes/machines')
, machinetags = require('./routes/machineTags')
, actions = require('./routes/actions')
, actiontags = require('./routes/actionTags')
, machineroles = require('./routes/machineRoles')
, fileupload = require('./routes/fileupload')
, common = require('./common')
, auth = require('./routes/auth')
, terminal = require('./routes/terminal')
, realtime = require('./routes/realtime')
, testsets = require('./routes/testsets')
, testcases = require('./routes/testcases')
, testcaseTags = require('./routes/testcaseTags')
, executions = require('./routes/executions')
, executionTags = require('./routes/executionTags')
, executiontestcases = require('./routes/executiontestcases')
, executionengine = require('./routes/executionengine')
, heartbeat = require('./routes/heartbeat')
, results = require('./routes/results')
, methodFinder = require('./routes/methodFinder');
var app = express.createServer(
//express.bodyParser(),
//express.cookieParser(),
//express.session({ secret: 'redwoodsecrect' })
);
// Configuration
app.configure(function(){
//app.use(express.logger());
//app.use(express.errorHandler());
app.use(express.bodyParser());
app.use(express.cookieParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.configure('production', function(){
app.use(express.errorHandler());
});
//DB
// Routes
app.post('/login',auth.logIn,auth.logInSucess);
app.get('/login',auth.loginPage);
app.get('/',auth.auth, routes.index);
app.get('/index.html',auth.auth,function(req,res){res.sendfile('index.html');});
//variables
app.get('/variables', auth.auth, variables.variablesGet);
app.put('/variables/:id',auth.auth, variables.variablesPut);
app.post('/variables',auth.auth, variables.variablesPost);
app.del('/variables/:id',auth.auth, variables.variablesDelete);
//variableTags
app.get('/variableTags',auth.auth, variableTags.variableTagsGet);
app.post('/variableTags',auth.auth, variableTags.variableTagsPost);
//start execution
app.post('/executionengine/startexecution',auth.auth, executionengine.startexecutionPost);
//stop
app.post('/executionengine/stopexecution',auth.auth, executionengine.stopexecutionPost);
app.post('/executionengine/actionresult',executionengine.actionresultPost);
app.post('/executionengine/logmessage',executionengine.logPost);
//heartbeat
app.post('/heartbeat',heartbeat.heartbeatPost);
//results
app.get('/results/:id',results.resultsGet);
//machines
app.get('/machines',auth.auth, machines.machinesGet);
app.put('/machines/:id',auth.auth, machines.machinesPut);
app.post('/machines',auth.auth, machines.machinesPost);
app.del('/machines/:id',auth.auth, machines.machinesDelete);
//machineTags
app.get('/machinetags',auth.auth, machinetags.machineTagsGet);
app.post('/machinetags',auth.auth, machinetags.machineTagsPost);
//actions
app.get('/actions',auth.auth, actions.actionsGet);
app.put('/actions/:id',auth.auth, actions.actionsPut);
app.post('/actions',auth.auth, actions.actionsPost);
app.del('/actions/:id',auth.auth, actions.actionsDelete);
//actionTags
app.get('/actiontags',auth.auth, actiontags.actionTagsGet);
app.post('/actiontags',auth.auth, actiontags.actionTagsPost);
//testcases
app.get('/testcases',auth.auth, testcases.testcasesGet);
app.put('/testcases/:id',auth.auth, testcases.testcasesPut);
app.post('/testcases',auth.auth, testcases.testcasesPost);
app.del('/testcases/:id',auth.auth, testcases.testcasesDelete);
//testcaseTags
app.get('/testcasetags',auth.auth, testcaseTags.testcaseTagsGet);
app.post('/testcasetags',auth.auth, testcaseTags.testcaseTagsPost);
//executions
app.get('/executions',auth.auth, executions.executionsGet);
app.put('/executions/:id',auth.auth, executions.executionsPut);
app.post('/executions/:id',auth.auth, executions.executionsPost);
app.del('/executions/:id',auth.auth, executions.executionsDelete);
//executionTags
app.get('/executiontags',auth.auth, executionTags.executionTagsGet);
app.post('/executiontags',auth.auth, executionTags.executionTagsPost);
//executiontestcases
app.get('/executiontestcases/:id',auth.auth, executiontestcases.executiontestcasesGet);
app.put('/executiontestcases/:id',auth.auth, executiontestcases.executiontestcasesPut);
app.post('/executiontestcases',auth.auth, executiontestcases.executiontestcasesPost);
app.post('/executiontestcases/udatetestset',auth.auth, executiontestcases.executionsTestSetUpdatePost);
app.del('/executiontestcases/:id',auth.auth, executiontestcases.executiontestcasesDelete);
//machineRoles
app.get('/machineroles',auth.auth, machineroles.machineRolesGet);
app.post('/machineroles',auth.auth, machineroles.machineRolesPost);
//users
app.get('/users', auth.auth, users.usersGet);
app.put('/users/:id',auth.auth, users.usersPut);
app.post('/users',auth.auth, users.usersPost);
app.del('/users/:id',auth.auth, users.usersDelete);
//testsets
app.get('/testsets', auth.auth, testsets.testsetsGet);
app.put('/testsets/:id',auth.auth, testsets.testsetsPut);
app.post('/testsets',auth.auth, testsets.testsetsPost);
app.del('/testsets/:id',auth.auth, testsets.testsetsDelete);
//userStates
app.get('/userStates', auth.auth, users.userStatesGet);
app.put('/userStates/:id',auth.auth, users.userStatesPut);
app.post('/userStates',auth.auth, users.userStatesPost);
app.del('/userStates/:id',auth.auth, users.userStatesDelete);
//projects
app.get('/projects', auth.auth, projects.projectsGet);
app.put('/projects/:id',auth.auth, projects.projectsPut);
app.post('/projects',auth.auth, projects.projectsPost);
app.del('/projects/:id',auth.auth, projects.projectsDelete);
//userTags
app.get('/userTags',auth.auth, userTags.userTagsGet);
app.post('/userTags',auth.auth, userTags.userTagsPost);
//scripts
app.get('/scripts/root',auth.auth, scripts.scriptsGet);
app.post('/scripts/delete',auth.auth, scripts.scriptsDelete);
app.post('/scripts/copy',auth.auth, scripts.scriptsCopy);
//script
app.post('/script/get',auth.auth, script.scriptGet);
app.post('/script',auth.auth, script.scriptPost);
app.put('/script',auth.auth, script.scriptPut);
//folder
app.post('/folder',auth.auth, folder.folderPost);
app.put('/folder',auth.auth, folder.folderPut);
//folder
app.post('/fileupload',auth.auth, fileupload.upload);
//methodFinder
app.post('/methodFinder',auth.auth, methodFinder.methodFinderPost);
common.parseConfig(function(){
common.initDB(common.Config.DBPort,function(){
common.cleanUpExecutions();
});
realtime.initSocket(app);
app.listen(common.Config.AppServerPort, function(){
console.log("Express server listening on port %d in %s mode", common.Config.AppServerPort, app.settings.env);
});
});