forked from 1andee/space-apps-hackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
34 lines (29 loc) · 972 Bytes
/
index.js
File metadata and controls
34 lines (29 loc) · 972 Bytes
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
"use strict";
const PORT = process.env.PORT || 8080;
const ENV = process.env.NODE_ENV || 'development';
const express = require("express");
const bodyParser = require('body-parser');
const app = express();
const cors = require('cors');
const knexConfig = require('./knexfile');
const knex = require('knex')(knexConfig[ENV]);
const morgan = require('morgan');
const knexLogger = require('knex-logger');
const data = require('./chartData');
app.set("view engine", "ejs");
app.use(express.static("public"));
app.use(cors());
app.use(morgan('dev'));
app.use(knexLogger(knex));
app.use(bodyParser.json())
app.get("/", (req, res) => {
res.render("index", data);
});
const reportApi = require('./api/report');
const notificationApi = require('./api/notification');
app.use('/api/report', reportApi(knex));
app.use('/api/notification', notificationApi(knex));
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});
module.exports = app.listen(8081);