-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (31 loc) · 1.3 KB
/
server.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
var express = require('express')
var path = require('path')
var mongoose = require('mongoose')
var bodyParser = require('body-parser')
var app = express()
var router = require('./router')
var publicPath = path.resolve(__dirname, 'public')
var CronJob = require('cron').CronJob
var collectBills = require('./csv_import').collectBills
var config = require('./config')
app.use(bodyParser())
// parse application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }))
app.use(express.static(publicPath))
router(app)
//connect to heroku
var db = config.dbURI2
mongoose.connect(db)
var Xray = require('x-ray')
var xray = Xray()
var publicPath = path.resolve(__dirname, 'public')
var districts = require(__dirname, '/districts.js')
var fetch = require('isomorphic-fetch')
var polyfill = require('babel-polyfill')
//cronjob runs every day at 9am Pacific Time
new CronJob('00 00 09 * * *', () => {
// Collects bills to be debated before House and Senate and send them to the database
collectBills('https://www.govtrack.us/api/v2/bill?sort=-introduced_date&bill_type=house_bill', congressBill)
collectBills('https://www.govtrack.us/api/v2/bill?sort=-introduced_date&bill_type=senate_bill', senateBill)
// Add any other data collecting functions we want automated here
}, true, 'America/Los_Angeles')