-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (24 loc) · 844 Bytes
/
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
const express = require('express');
const bodyParser = require('body-parser')
const cors = require('cors');
const massive = require('massive');
// const configs = require('./config.js');
var app = module.exports = express();
app.use(express.static(__dirname));
app.use(bodyParser.json());
app.use(cors());
var connectionString = 'postgres://tesladb1:password@localhost/tesla'
var db = massive.connectSync({connectionString : connectionString})
app.set('db', db);
var db = app.get('db')
var serverCtrl = require('./serverCtrl.js');
const port = 80;
app.listen(port, function(){
console.log("Yoda Lay Hee Whoo", port)
db.createTables(function(x){
console.log("!!!!!!!!!! Tables Created !!!!!!!!!!");
console.log(x);
});
})
app.get('/api/cars', serverCtrl.getAllCars)
app.get('/api/cars/:id', serverCtrl.getCarById)