-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
36 lines (29 loc) · 967 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
const express = require( 'express' )
const http = require( 'http' )
const app = express( )
app.set('port', ( process.env.PORT || 5000 ));
app.use(( req, res, next ) => {
res.header( "Access-Control-Allow-Origin", "*" );
res.header( "Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept" );
next( );
});
if ( process.env.NODE_ENV === 'production' ) {
app.use(express.static( 'dist' ));
} if ( process.env.NODE_ENV === 'development' ) else {
app.use(express.static( './' ));
app.use(express.static( 'src' ));
}
app.get('/feed/', ( req, res ) => {
http.get( 'http://feeds.nos.nl/nosnieuwsalgemeen?format=xml' ).on('response', ( response ) => {
var body = '';
var i = 0;
response.on('data', ( chunk ) => {
i++;
body += chunk;
});
response.on('end', ( ) => res.send( body ));
});
})
app.listen(app.get( 'port' ), ( ) => {
console.log('Node app is running on port', app.get( 'port' ));
});