-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
31 lines (21 loc) · 803 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
'use strict';
var port = process.env.PORT || 1337;
var express = require("express");
var bodyParser = require('body-parser');
var cors = require('cors');
var functions = require('./functions');
let path = require('path');
var app = express();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors());
app.use(express.static(path.join(__dirname, 'client/dist')));
// Api paths
app.post('/api/authorize', functions.authorize);
app.post('/api/search', functions.search);
// Catch all other routes and return the index file
//This catch all route, denoted with *, MUST come last after all other API routes have been defined
app.use('*', (req, res) => {
res.sendFile(path.join(__dirname, 'client/dist/index.html'));
});
app.listen(port);
console.log("Server listening on port " + port);