forked from Castrogiovanni20/api-dolar-argentina
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.js
30 lines (24 loc) · 765 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 helmet = require('helmet');
const router = require('./routes/router');
const PORT = process.env.PORT || 7070;
const app = express();
const auth = require('./util/auth');
const authInstance = new auth();
const util = require('./util/util');
const utilInstance = new util();
app.get('/', utilInstance.getHome);
// Settings
app.set('port', PORT);
app.use('/favicon.ico', express.static('favicon.ico'));
app.use(helmet());
app.use(express.urlencoded({ extended: false }));
app.use(express.json());
app.use(authInstance.validateApiKey);
app.use('/', router);
// CORS
app.use('*', utilInstance.setCorsHeaders);
// Starting the server
app.listen(app.get('port'), () => {
console.log('Server running on port ' + PORT)
});