-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
45 lines (35 loc) · 897 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
36
37
38
39
40
41
42
43
44
45
const express = require('express');
const path = require('path');
const app = express();
var cors = require('cors');
const database = require('./lib/database');
app.use(cors()); // Don't do this in production :)
app.use(express.static(path.join(__dirname, 'build'))); // Serves build production files
app.use(express.json());
app.get('/vehicles', (req, res) => {
// TODO
res.json([]);
});
app.get('/vehicles/:id', (req, res) => {
// TODO
res.json({});
});
app.post('/vehicles', (req, res) => {
// TODO
res.json({});
});
app.put('/vehicles/:id', (req, res) => {
// TODO
res.json({});
});
app.delete('/vehicles/:id', (req, res) => {
// TODO
res.json({});
});
// Serves build production files
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});
app.listen(3001, () => {
console.log('Server is now listening on port 3001');
});