-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
37 lines (29 loc) · 861 Bytes
/
index.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
'use strict';
const credentials = require('./credentials');
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
const http = require('http').Server(app);
const Sequelize = require('sequelize');
const db = new Sequelize(credentials.DATABASE_URL, {
logging: false
});
//sync all models
db.sync();
const models = db.import(__dirname + '/models');
// parse application/json
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(express.static('public'));
http.listen(credentials.PORT, function(){
console.log('Example app listening on port', credentials.PORT, '!');
});
let apiOptions = {
app: app,
models: models
};
//Load the api versions
require('./api/v1')(apiOptions);
app.get('/', function(req, res){
res.sendFile(__dirname+'/public/html/index.html');
});