forked from civictechdc/dc-campaign-finance-watch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
43 lines (34 loc) · 1.81 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
'use strict';
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var config = require('./config/environment');
// Restify
var restify = require('restify');
var server = restify.createServer({name: 'dc-campaign-finance'});
server.use(restify.queryParser());
server.use(function crossOrigin(req, res, next){
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
return next();
});
//Mongoose
var mongoose = require('mongoose');
mongoose.connect(config.mongo.uri);
// Candidate
var candidateController = require('./api/candidate/candidate.controller');
server.get('/dc-campaign-finance/api/candidate/:id', candidateController.getCandidateById);
server.get('/dc-campaign-finance/api/electedOfficials/:year', candidateController.getElectedOfficials);
server.get('/dc-campaign-finance/api/candidate', candidateController.searchForCandidate);
// Company
var contributorController = require('./api/contributor/contributor.controller');
server.get('/dc-campaign-finance/api/contributor/:id', contributorController.getCompanyInformation);
server.get('/dc-campaign-finance/api/contributor/contributors/:limit', contributorController.getTopContributingCompanies);
server.get('/dc-campaign-finance/api/contributor', contributorController.searchForCompany);
// Election
var electionController = require('./api/election/election.controller');
server.get('/dc-campaign-finance/api/electionCountdown', electionController.getNextElection);
// Contribution
var contributionController = require('./api/contribution/contribution.controller');
server.get('/dc-campaign-finance/api/individual/contributors/:limit', contributionController.getTopIndividaulContributors);
server.listen(process.env.PORT || 3000, function(){
console.log('%s listening at %s', server.name, server.url);
});