-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
30 lines (24 loc) · 932 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
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const massive = require('massive');
require('dotenv').config();
const controller = require('./controller');
const app = express();
massive( process.env.CONNECTION_STRING ).then( (dbInstance) =>
{
app.set('db', dbInstance);
// dbInstance.new_planes()
// .then( planes => console.log( planes ) )
// .catch( err => console.log( err ) );
// dbInstance.get_planes(req, res)
// .then( planes => res.json( planes ) )
// .catch( err => console.log( err ) );
});
app.use( bodyParser.json() );
app.use( cors() );
app.get('/api/plane/:id', controller.getPlane);
app.get('/api/planes', controller.getPlanes);
app.post('/api/post/plane', controller.postPlane);
const port = process.env.PORT || 3000
app.listen( port , () => { console.log(`Server listening on port ${port}`); } );