-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
62 lines (50 loc) · 2.14 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
/*********************
* Module dependencies.
**********************/
var express = require('express');
var routes = require('./routes');
var errorHandler = require('./routes/errorPage');
var http = require('http');
var path = require('path');
var dataSetter = require('./server/db/dataSetter');
var dataGetter = require('./server/db/dataGetter');
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.static(path.join(__dirname, 'public')));
app.use(express.bodyParser());
app.use(app.router);
// development only
if ('development' == app.get('env')) {
app.use(express.errorHandler());
}
app.get('/', routes.index);
app.get('/404', errorHandler.error);
/*******************************************************************
* every app.get||app.post below returns json with requested obj
* commented lines represents data to be send in request from client
*******************************************************************/
app.get('/user', dataGetter.getPerson); //{id: 'num'}
app.get('/users', dataGetter.getPersons); //{} or {id:'array of ids'}
app.post('/user', dataSetter.addPerson); //{name:'str', surname: 'str', position: 'str', file: 'filepath'}
app.get('/project', dataGetter.getProject); //{id: 'num'}
app.get('/projects', dataGetter.getProjects); //just send req here
app.post('/project', dataSetter.addProject); //{name: 'str'(optional -> startDate: 'date')}
app.post('/project/:id', dataSetter.modifyProject); //{date: 'date')}
app.post('/history', dataSetter.addHistory); //{personID: 'num', projectID: 'num', statusID: 'num', leaving: 'Boolean'(optional date: 'date')}
app.get('/position', dataGetter.getPositions); //just send req here
app.get('/statuses', dataGetter.getStatus); //just send req here
/**
* adds default docs to DB (Statuses, Positions and Default project "SkillUp")
*/
dataSetter.dbFeeler();
http.createServer(app).listen(
3000, '0.0.0.0'
// app.get('port'), function(){
// console.log('Express server listening on port ' + app.get('port'));
//}
);