-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
55 lines (34 loc) · 1.07 KB
/
app.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
47
48
49
50
51
52
53
54
55
// importing required packages
var express = require('express');
var cors = require('cors');
var bodyParser = require('body-parser');
// importing controllers
var timestamp = require('./controllers/timestamp');
var whoami = require('./controllers/whoami');
var getFileMeta = require('./controllers/get-file-meta');
var shortenURL = require('./controllers/url-shortener');
var imageSearch = require('./controllers/image-search');
var app = express();
// adding middlewares
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cors());
app.use(express.static(__dirname + '/public'));
// MICROSERVICES:
// timestamp microservice
timestamp(app);
// request-header-parser microservice
whoami(app);
// file-metadata microservice
getFileMeta(app);
// URL shortener microservice
shortenURL(app);
// image search microservice
imageSearch(app);
// index route
app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
})
app.listen(process.env.port || 3000, function() {
console.log('Server started on localhost:3000');
});