-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
47 lines (36 loc) · 1.13 KB
/
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
46
'use strict';
(function () {
const express = require('express');
const path = require('path');
const http = require('http');
const bodyParser = require('body-parser');
var api = require('./api');
const httpCors = require('cors');
var functions = require('./functions');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(httpCors());
app.use('/api', api.router);
app.post('/api/authorize', functions.authorize);
app.post('/api/search', functions.search);
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, 'dist/index.html'));
});
app.get('/*.js', function (req, res) {
res.sendFile(path.join(__dirname, 'dist/' + req.url));
});
app.get('*.css', function (req, res) {
res.sendFile(path.join(__dirname, 'dist/' + req.url));
});
app.get('/api', function (req, res) {
console.log(api);
console.log(functions);
res.json('API is working!!!!')
});
const port = process.env.PORT || 4200;
app.set('port', port);
app.listen(port, function () {
console.log('API running on localhost:' + port);
});
})();