-
Notifications
You must be signed in to change notification settings - Fork 16
/
server.js
34 lines (29 loc) · 1.01 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
var express = require('express');
var path = require('path');
var logger = require('morgan');
var bodyParser = require('body-parser');
var routes = require('./server/index');
var query = require('./server/query');
var startQuery = require('./server/startQuery');
const SERVICE_ACCOUNT = "./config/service_account.json";
const { BigQuery } = require('@google-cloud/bigquery');
global.bigQuery = new BigQuery({
projectId: require(SERVICE_ACCOUNT).project_id,
keyFilename: SERVICE_ACCOUNT
});
var app = express();
app.set('views', path.join(__dirname, '/assets'));
app.set('view engine', 'ejs');
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static(path.resolve(path.join(__dirname, '/assets'))));
// routing setup
app.use('/', routes);
app.use('/query', query);
app.use('/startQuery', startQuery);
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
console.log(`App listening on port ${PORT}`);
console.log('Press Ctrl+C to quit.');
});